From 6d1fa4d2c572a4ecd3c5d216885301fd86ef3267 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 16 Oct 2026 08:18:47 -0400 Subject: [PATCH 1/2] testtools/testrunner.pl: double-quote newlines In string equality comparisons, newlines must be double-quoted. In perl, single-quoted '\n' typically produces a literal two-character string, though by some miracle the construct my @lines = split('\n', $input) appears to be working as intended. Later comparisons such as $lastchar ne '\n' however, are not. If you are unlucky, this can lead to test failures like the following in libcss: Running .../test_parse-auto .../test/data/parse/properties.dat Test 1: PASSTest 2: PASS Test 3: PASS Test 4: PASS ... Test 555: PASSPASS Earlier misconcatenated lines do not cause a problem, but the first four characters of the final line must be "PASS" for the test to pass. --- testtools/testrunner.pl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/testtools/testrunner.pl b/testtools/testrunner.pl index 3a75605..f39f74b 100644 --- a/testtools/testrunner.pl +++ b/testtools/testrunner.pl @@ -156,7 +156,7 @@ sub run_test # Skip bare new line. } else { # Split into lines - my @lines = split('\n', $input); + my @lines = split("\n", $input); # Grab the last character of the input my $lastchar = substr($input, -1, 1); @@ -173,9 +173,9 @@ sub run_test print LOG "$l\n"; $last .= $l; # Last char of this read was - # not '\n', so don't terminate + # not "\n", so don't terminate # line in log. - } elsif ($lastchar ne '\n' && + } elsif ($lastchar ne "\n" && $l eq $lines[-1]) { print LOG " $l"; $last = $l; @@ -189,7 +189,7 @@ sub run_test # Flag whether last line was incomplete # for next time. - if ($lastchar ne '\n') { + if ($lastchar ne "\n") { $outcont = 1; } else { $outcont = 0; @@ -210,7 +210,7 @@ sub run_test } # Flag need for continuation - if ($lastchar ne '\n') { + if ($lastchar ne "\n") { $errcont = 1; } else { $errcont = 0; -- 2.56.0