test-lib: show missing prereq summary

When running the full test suite many tests can be skipped because of missing prerequisites. It not easy right now to get an overview of which ones are missing. When switching to a new machine or environment some libraries and tools might be missing or maybe a dependency broke completely. In this case the tests would indicate nothing since all dependant tests are simply skipped. This could hide broken behaviour or missing features in the build. Therefore this patch summarizes the missing prereqs at the end of the test run making it easier to spot such cases. - Add failed prereqs to the test results. - Aggregate and then show them with the totals. Signed-off-by: Fabian Stelzer <fs@gigacodes.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Fabian Stelzer committed Nov 20, 2021 at 16:03 UTC 49da4040701f6d3dd480c6d007109c9a2fc2cb7a
2 files changed +28
t/aggregate-results.sh
+17
@@ -6,6 +6,7 @@ success=0
6 failed=0
7 broken=0
8 total=0
9 +missing_prereq=
10
11 while read file
12 do
@@ -30,10 +31,26 @@ do
31 broken=$(($broken + $value)) ;;
32 total)
33 total=$(($total + $value)) ;;
34 + missing_prereq)
35 + missing_prereq="$missing_prereq,$value" ;;
36 esac
37 done <"$file"
38 done
39
40 +if test -n "$missing_prereq"
41 +then
42 + unique_missing_prereq=$(
43 + echo $missing_prereq |
44 + tr -s "," "\n" |
45 + grep -v '^$' |
46 + sort -u |
47 + paste -s -d ' ')
48 + if test -n "$unique_missing_prereq"
49 + then
50 + printf "\nmissing prereq: $unique_missing_prereq\n\n"
51 + fi
52 +fi
53 +
54 if test -n "$failed_tests"
55 then
56 printf "\nfailed test(s):$failed_tests\n\n"
t/test-lib.sh
+11
@@ -669,6 +669,8 @@ test_fixed=0
669 test_broken=0
670 test_success=0
671
672 +test_missing_prereq=
673 +
674 test_external_has_tap=0
675
676 die () {
@@ -1069,6 +1071,14 @@ test_skip () {
1071 of_prereq=" of $test_prereq"
1072 fi
1073 skipped_reason="missing $missing_prereq${of_prereq}"
1074 +
1075 + # Keep a list of all the missing prereq for result aggregation
1076 + if test -z "$missing_prereq"
1077 + then
1078 + test_missing_prereq=$missing_prereq
1079 + else
1080 + test_missing_prereq="$test_missing_prereq,$missing_prereq"
1081 + fi
1082 fi
1083
1084 case "$to_skip" in
@@ -1175,6 +1185,7 @@ test_done () {
1185 fixed $test_fixed
1186 broken $test_broken
1187 failed $test_failure
1188 + missing_prereq $test_missing_prereq
1189
1190 EOF
1191 fi