From 8742713050dd20a1f11d5d32b468ae2beb644a80 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 29 Aug 2012 20:59:06 +0100 Subject: run: Make --test flag print the time taken to run the test. This is useful because it lets us see which tests take the longest. --- run.in | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/run.in b/run.in index 7422c1ab..413d7f7b 100644 --- a/run.in +++ b/run.in @@ -115,19 +115,24 @@ if [ -z "$test_mode" ]; then else # For tests (./run --test), redirect all output to a file, and # only print the file if the test fails. - fail=0 pid=$$ rm -f $b/run.$pid - $libtool "$@" > $b/run.$pid 2>&1 || { - fail=$? - if [ "$fail" -eq 77 ]; then - cat $b/run.$pid - else - echo "$b/run --test" "$@" - cat $b/run.$pid - echo "$b/run: command failed with exit code $fail" - fi - } + start_t="$(date +'%s')" + $libtool "$@" > $b/run.$pid 2>&1 + fail=$? + end_t="$(date +'%s')" + if [ "$fail" -eq 0 ]; then + # Test successful. + echo $(($end_t - $start_t)) seconds: "$@" + elif [ "$fail" -eq 77 ]; then + # Tests return 77 to mean skipped. + cat $b/run.$pid + else + # Test failed. + echo "$b/run --test" "$@" + cat $b/run.$pid + echo "$b/run: command failed with exit code $fail" + fi rm -f $b/run.$pid exit $fail fi -- cgit