Run OS prpcess while running tests

I need to run the Stripe CLI listener to forward webhooks to the application when testing my integration.

My understanding is that System.cmd would leave running processes when tests shut down.

Muontrap does not run on Windows where I’m currently working (don’t ask, it’s ok, but it is a stopgap solution). There is an issue for Windows support.

Other options that will terminate the os process when I’m done?

System.cmd shouldn’t give you phantom processes, instead it should block the current process until the command exited.

1 Like

From reading it wouldn’t shut a long-running process down if the application shuts down which would lead to a phantom process right?

So if I spawn a process that runs that os command, will it end that command when I end my session? I haven’t verified, but docs made me believe it wouldn’t.

The program you start via System.cmd is a chjild process of the BEAM, unless it forks itself, it should be killed when the BEAM is shut down.

Due to the way MicroSoft designed things, behaviour in widows can be different in unexplainable ways though…

1 Like

Ok, thanks :slight_smile:
I guess I should try that then and see if it actually does solve my problem.

That worked. I tried to get it to a point where I could check that I get the expected initial output using StringIO and the into option for System.cmd. But I’m not finding the right way to do it, if it is supposed to work. So I’ll settle with a lesser solution for now. But System.cmd seems to behave well.

StringIO does return a pid, pids are not implementing the Collectable protocol, so you can’t use them as a target for :into.

1 Like

But an IO.stream() taking the pid from StringIO as the device seems like it should work from my reading. I might be doing it wrong. Should experiment more but need to restrain myself from yak shaving since it is client work.