From 6502e30cfd71dc8435e8da220936752c2bec1599 Mon Sep 17 00:00:00 2001 From: Ed Santiago Date: Thu, 25 Jul 2024 13:05:10 -0600 Subject: [PATCH] bats log: differentiate parallel tests from sequential For tests run in parallel, show file number as |nnn| (vs [nnn]) Teach logformatter to distinguish the two, adding 'p' to anchors in parallel tests. Necessary because in this scheme we run bats twice, thus see 'ok 1' twice, and we want to differentiate them. Signed-off-by: Ed Santiago --- contrib/cirrus/logformatter | 11 ++++++++--- test/system/helpers.bash | 7 ++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/contrib/cirrus/logformatter b/contrib/cirrus/logformatter index 78ac1850d7..ed7135e8d2 100755 --- a/contrib/cirrus/logformatter +++ b/contrib/cirrus/logformatter @@ -349,7 +349,7 @@ END_HTML # BATS handling. This will recognize num_tests both at start and end if ($line =~ /^1\.\.(\d+)$/) { $looks_like_bats = 1; - $bats_count{expected_total} = $1; + $bats_count{expected_total} += $1; undef $looks_like_python; } # Since the number of tests can't always be predicted, recognize @@ -445,9 +445,14 @@ END_HTML if ($css) { # Make it linkable, e.g. foo.html#t--00001 if ($line =~ /^(not\s+)?ok\s+(\d+)\s+(.*)/) { - $line = sprintf("%s", $2, $line); + my ($notok, $num, $name) = ($1, $2, $3); + # Parallel system tests are shown as |nnn| instead of [nnn] + my $p = ''; + $p = 'p' if $name =~ /^\s*\|\d+\|/; - push @{$bats_count{__fail_list}}, [ $2, $3 ] if $1; + $line = sprintf("%s", $num, $p, $line); + + push @{$bats_count{__fail_list}}, [ $num, $name ] if $notok; } $bats_count{$css}++; $css = "bats-$css"; diff --git a/test/system/helpers.bash b/test/system/helpers.bash index c38273d78b..3b6b5b00ed 100644 --- a/test/system/helpers.bash +++ b/test/system/helpers.bash @@ -160,7 +160,12 @@ function basic_setup() { # Test filenames must match ###-name.bats; use "[###] " as prefix run expr "$BATS_TEST_FILENAME" : "^.*/\([0-9]\{3\}\)-[^/]\+\.bats\$" - BATS_TEST_NAME_PREFIX="[${output}] " + # If parallel, use |nnn|. Serial, [nnn] + if [[ -n "$PARALLEL_JOBSLOT" ]]; then + BATS_TEST_NAME_PREFIX="|${output}| " + else + BATS_TEST_NAME_PREFIX="[${output}] " + fi # By default, assert() and die() cause an immediate test failure. # Under special circumstances (usually long test loops), tests