summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-08-29 20:59:06 +0100
committerRichard W.M. Jones <rjones@redhat.com>2012-08-29 20:59:06 +0100
commit8742713050dd20a1f11d5d32b468ae2beb644a80 (patch)
treedfc0092f51a6c75a97d84ee7cf58e0819a56ef93
parent1ac36e4f3692c256159d3e8b9c7d7b04923e02fd (diff)
downloadlibguestfs-8742713050dd20a1f11d5d32b468ae2beb644a80.tar.gz
libguestfs-8742713050dd20a1f11d5d32b468ae2beb644a80.tar.xz
libguestfs-8742713050dd20a1f11d5d32b468ae2beb644a80.zip
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.
-rw-r--r--run.in27
1 files 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