0

Is there a common utility (Ubuntu, perhaps OSX) that can run a server serve ./public, then run some tests ./run-chrome-tests.sh, and once the tests are finished, kills the serve ./public.

This can be done in bash, but I'd rather create configuration, than code if it is feasible.

2

There is to my knowledge no such utility, but it is easily implemented in a shell script.

A short shell script that implements what you described:

#!/bin/sh

serve ./public & serve_pid=$!
./run-chrome-tests.sh

kill "$serve_pid"

You may want to insert a sleep 3 call (or similar) after starting serve in the background, to allow it to initialize properly before running the testing script.

$! will be the PID of the most recently started background job (the serve process). When the run-chrome-tests.sh script finishes, the script above will explicitly terminate the serve process by signalling using kill.

  • Ah, that is even simpler than the bash I had envisioned...very nice. Accepted because this is what I'll end up doing even though it wasn't exactly what i asked for. – Ashley Coolman Feb 8 '18 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.