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.

1 Answers1

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.

Kusalananda
  • 333,661
  • 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 08 '18 at 11:25