[Parallelized re-testing of failed tests.
tobias@goedderz.info**20140721142946
 Ignore-this: 25604d3c18ac273b2d758d801a0bba63
] addfile ./run_failed_test.bash
hunk ./run_failed_test.bash 1
+#!/bin/bash
+
+# memory limit per process.
+# passed to bash's ulimit -v, so specified in kibi.
+memlimit="$((1024*1024))"
+
+# in seconds
+timelimit=60
+
+batch_fn="$1"
+
+log() {
+    echo "[$(date +"%F %X")]" "$@"
+}
+
+tmpfn="$(tempfile -s .out)"
+echo "[$(date +"%F %X")] Executing:" ulimit -v $memlimit\; timeout $timelimit ./igor2 -b "${batch_fn}" \> "$tmpfn"
+(   ulimit -v "$memlimit"
+    timeout "$timelimit" \
+    ./igor2 -b "$batch_fn" > "$tmpfn" 2>&1 )
+
+if [ $? = 0 ]
+then
+    output_fn="$(dirname "$batch_fn")/$(basename -s .bat "$batch_fn").out"
+    log '!!!' Unexpected success: "$batch_fn" / "$output_fn"
+    mv -v "$tmpfn" "$output_fn"
+else
+    log Expected failure: "$batch_fn"
+    rm "$tmpfn"
+fi
hunk ./run_failed_tests.bash 5
-# memory limit per process.
-# passed to bash's ulimit -v, so specified in kibi.
-memlimit="$((1024*1024))"
-
-# in seconds
-timelimit=60
-
-log() {
-    echo "[$(date +"%F %X")]" "$@"
-}
-
-for batch_fn in "${tests_dir}"/*.bat
-do
-    output_fn="${tests_dir}/$(basename -s .bat "$batch_fn").out"
-    echo "[$(date +"%F %X")] Executing:" ulimit -v $memlimit\; timeout $timelimit ./igor2 -b "${batch_fn}" \> "$output_fn"
-    (   ulimit -v "$memlimit"
-        timeout "$timelimit" \
-        ./igor2 -b "$batch_fn" 2>&1 \
-            | grep -v '^File loaded in [0-9.]\+s$\|^\s*CPU: [0-9.]\+s$' \
-            > "$output_fn" )
-    if [ $? = 0 ]
-    then
-        log '!!!' Unexpected success: "$batch_fn" / "$output_fn"
-    else
-        log Expected failure: "$batch_fn"
-    fi
-done
+parallel ./run_failed_test.bash ::: "${tests_dir}"/*.bat