git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2] tests: print failed test numbers at the end of the test run

From
Jens Lehmann <jens.lehmann@web.de>
Date
Jul 24, 2011, 13:35 UTC
Message-ID
<4E2C1FBA.3010606@web.de>
In-Reply-To
<7vmxg4w2fm.fsf@alter.siamese.dyndns.org>

On modern multi-core processors "make test" is often run in multiple jobs. If one of them fails the test run does stop, but the concurrently running tests finish their run. It is rather easy to find out which test failed by doing a "ls -d t/trash*". But that only works when you don't use the "-i" option to "make test" because you want to get an overview of all failing tests. In that case all thrash directories are deleted end and the information which tests failed is lost.

If one or more tests failed, print a list of them before the test summary:
failed test(s): t1000 t6500

fixed 0 success 7638 failed 3 broken 49 total 7723

This makes it possible to just run the test suite with -i and collect all failed test scripts at the end for further examination.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
---
Am 24.07.2011 09:41, schrieb Junio C Hamano:
Show 6 quoted lines
> Jens Lehmann <Jens.Lehmann@web.de> writes:
> 
>> Maybe I'm missing something completely obvious, but I always have a hard
>> time finding out which test scripts did fail in a test run with -j30.
> 
> I run "ls -d t/trash*" for that ;-)

Yup. But that won't work when you use "-i" to continue to run all tests even when some fail, as all trash directories get deleted in the end. Or did I manage to overlook an option which stops that? ;-)

I rephrased the commit message to make it clear my patch only changes the behavior when "-i" is used and one or more tests fail, as the code in question isn't executed otherwise.

Show 10 quoted lines
>> +			if test $value != 0; then
>> +				testnum=$(echo $file | cut -b 14-18)
>> +				failed_tests="$failed_tests $testnum"
>> +			fi
> 
> Somehow "cut" here feels dirty, as it hardcodes a mysterious offset that
> cannot be guessed without knowing what string it is cutting from by
> looking at t/Makefile.
> 
> 	testnum=$(expr "$file" : 'test-results/\(t[0-9]*\)-')
Thanks, this version is using that expression.
 t/aggregate-results.sh |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/t/aggregate-results.sh b/t/aggregate-results.sh
index d206b7c..60465fa 100755
--- a/t/aggregate-results.sh
+++ b/t/aggregate-results.sh
@@ -1,5 +1,6 @@
 #!/bin/sh

+failed_tests=
 fixed=0
 success=0
 failed=0
@@ -18,7 +19,12 @@ do
 		success)
 			success=$(($success + $value)) ;;
 		failed)
-			failed=$(($failed + $value)) ;;
+			failed=$(($failed + $value))
+			if test $value != 0; then
+				testnum=$(expr "$file" : 'test-results/\(t[0-9]*\)-')
+				failed_tests="$failed_tests $testnum"
+			fi
+			;;
 		broken)
 			broken=$(($broken + $value)) ;;
 		total)
@@ -27,6 +33,10 @@ do
 	done <"$file"
 done

+if [ -n "$failed_tests" ]; then
+	printf "\nfailed test(s):$failed_tests\n\n"
+fi
+
 printf "%-8s%d\n" fixed $fixed
 printf "%-8s%d\n" success $success
 printf "%-8s%d\n" failed $failed
-- 
1.7.6.346.g940def.dirty
Previous: Junio C HamanoNext: Jeff King
Message 3 of 9 in “tests: print failed test numbers at the end of the test run”
  1. tests: print failed test numbers at the end of the test runJens Lehmann, Jul 23, 2011
  2. Junio C HamanoJul 24, 2011
  3. tests: print failed test numbers at the end of the test runJens Lehmann, Jul 24, 2011
  4. Jeff KingJul 24, 2011
  5. Jens LehmannJul 24, 2011
  6. Sverre RabbelierJul 25, 2011
  7. Nguyen Thai Ngoc DuyJul 26, 2011
  8. Jeff KingJul 26, 2011
  9. Jeff KingJul 26, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.