Some tests need to configure the test environment prior to performing the actual test and restore the original settings after that. To properly support interrupting tests later on we should explicitly split out those parts into dedicated command sections.
My proposal is to add two new optional fields.
pre-command:
post-command:
(alternative spelling, setup-command and teardown-command)
If those fields are specified they should be used in pairs (validate enhancement to detect that would be nice).
Before starting the test we will run the pre-command program. Now, the outcome of the test is still going to be derived from the exit code of the main command block. However, regardless of what the outcome code is we will always run post-command program.
Using those commands we can start to look at an reliable interrupt feature where we kill the main test process (or process group, more on that later in anther bug) with SIGINT, SIGQUIT and finally SIGKILL.