From 1d2f41a8a334fa824bc8bb41a1e94914e14c06bd Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 25 Aug 2023 12:37:32 +0200 Subject: [PATCH] tests/runner: fix %else handling Getting the show state proper for %else and %endif did not properly work in nested cases. Follow-up to 3d089c41ea9 Closes #11731 --- tests/runner.pm | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/runner.pm b/tests/runner.pm index 5626c39da2..0a288c4138 100644 --- a/tests/runner.pm +++ b/tests/runner.pm @@ -301,6 +301,7 @@ sub prepro { my @out; my $data_crlf; my @pshow; + my @altshow; my $plvl; my $line; for my $s (@entiretest) { @@ -317,7 +318,18 @@ sub prepro { $rev ^= $feature{$cond} ? 1 : 0; push @pshow, $show; # push the previous state $plvl++; - $show = $rev; + if($show) { + # only if this was showing before we can allow the alternative + # to go showing as well + push @altshow, $rev ^ 1; # push the reversed show state + } + else { + push @altshow, 0; # the alt should still hide + } + if($show) { + # we only allow show if already showing + $show = $rev; + } next; } elsif($s =~ /^ *%else/) { @@ -325,7 +337,8 @@ sub prepro { print STDERR "error: test$testnum:$line: %else no %if\n"; last; } - $show ^= 1; + $show = pop @altshow; + push @altshow, $show; # put it back for consistency next; } elsif($s =~ /^ *%endif/) { @@ -334,6 +347,7 @@ sub prepro { last; } $show = pop @pshow; + pop @altshow; # not used here but we must pop it next; } if($show) { -- 2.47.3