- Notifications
You must be signed in to change notification settings - Fork17
Running commands with a timeout
Coreutilstimeout command
During a reduction it can happen that a variant is produced that never finishes. Unless you are actively reducing for this condition, you'll probably want DustMite to ignore this variant, which is why the-s 0 option is used to change the default error code from124 to0. If the process is seriously locked up it won't likely react to the defaultEXIT signal, and require aKILL signal as well. Options-k 5s 30s will send the process theEXIT signal after 30 seconds and theKILL signal after an additional 5 seconds.
Replacetestdir with your test directory andsleep 60 with your test command:
dustmite testdir"timeout -s 0 -k 5s 30s sleep 60"You can also use a script as the test command:
dustmite testdir"timeout -s 0 -k 5s 30s ../testscript.sh"With Homebrew:
brew install coreutilsdustmite testdir"gtimeout -s 0 -k 5s 30s ../testscript.sh"or with Macports:
port install timeoutdustmite testdir"timeout -s 0 -k 5s 30s ../testscript.sh"If you have installed Git, thetimeout command is likely available asc:\Program Files\Git\usr\bin\timeout.exe. However, if you are using a batch file to run the compiler and usetimeout on the batch file, thentimeout will kill the script when the compiler times out, but the compiler will keep on running nonetheless. So in order to kill the compiler,timeout should be part of the script as follows. If you invoke DustMite as
dustmite testdir ..\testscript.batandtestscript.bat looked like
dmd main.d2>&1|"c:\Program Files\Git\usr\bin\grep.exe" -F -e"Error: out of memory" -e"Memory allocation failed"
then the script should become
"c:\Program Files\Git\usr\bin\timeout.exe" -s0 -k 5s 30s dmd main.d2>&1|"c:\Program Files\Git\usr\bin\grep.exe" -F -e"Error: out of memory" -e"Memory allocation failed"