https://gcc.gnu.org/g:f9c223ae1f57321fbc87722d8cd35ec484739037
commit r17-5539-gf9c223ae1f57321fbc87722d8cd35ec484739037 Author: David Malcolm <[email protected]> Date: Sat Oct 24 11:51:01 2026 -0400 testsuite: avoid dropping last character of pytest output in DejaGnu I noticed that our DejaGnu output seems to be dropping the final character of names of test functions in pytest scripts. For example, my gcc.sum has: PASS: gcc.dg/analyzer/state-diagram-1.c state-diagram-1-sarif.py::test_state_grap where the test name "test_state_graph" has lost its final 'h' character. run-gcov-pytest was added to gcov.exp by Martin Liska in r11-6577-g4e275dccfc2467. I copied the logic into scansarif.exp as run-sarif-pytest in r15-2354-g4d1f71d49e396c and into scanhtml.exp as run-html-pytest in r16-487-g1a2c62212bd912. The code in question looks like e.g.: set prefix "\[^\r\n\]*" [...snip...] expect { -re "FAILED($prefix)\[^\r\n\]+\r\n" { set output [gcov-pytest-format-line $testcase $pytest_script $expect_out(1,string)] [...snip...] so we capture everything that matched $prefix. $prefix is greedy, but has to omit at least one character for the trailing "\[^\r\n\]+" In other words, we're matching on (a) "FAILED" followed by (b) $prefix (zero or more non-line-ending chars) followed by (c) \[^\r\n\]+ (one or more non-line-ending chars) followed by (d) \r\n (a line ending) and capturing (b). It's not clear to me what the intent of (c) is. (b) is greedy, but has to omit at least one character for the trailing "\[^\r\n\]+". I believe it's a bug This patch removes (c) from the various regexps. With this patch, the above gcc.sum changes to: PASS: gcc.dg/analyzer/state-diagram-1.c state-diagram-1-sarif.py::test_state_graph capturing the final 'h' of the test function name from the pytest script. Successfully bootstrapped & regrtested on aarch64-unknown-linux-gnu, which showed 14 fixed test names in g++.sum, 75 in gcc.sum, 3 in gfortran.sum, 16 in libgdiagnostics.sum, and 17 in sarif-replay.sum. gcc/testsuite/ChangeLog: * lib/gcov.exp (run-gcov-pytest): Drop excess non-newline pattern after parentheses in regexps. * lib/scanhtml.exp (run-html-pytest): Likewise. * lib/scansarif.exp (run-sarif-pytest): Likewise. Signed-off-by: David Malcolm <[email protected]> Diff: --- gcc/testsuite/lib/gcov.exp | 6 +++--- gcc/testsuite/lib/scanhtml.exp | 6 +++--- gcc/testsuite/lib/scansarif.exp | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gcc/testsuite/lib/gcov.exp b/gcc/testsuite/lib/gcov.exp index 6d6c6abb9b57..6bb977ea152f 100644 --- a/gcc/testsuite/lib/gcov.exp +++ b/gcc/testsuite/lib/gcov.exp @@ -827,17 +827,17 @@ proc run-gcov-pytest { args } { set prefix "\[^\r\n\]*" set timeout 300 expect { - -re "FAILED($prefix)\[^\r\n\]+\r\n" { + -re "FAILED($prefix)\r\n" { set output [gcov-pytest-format-line $testcase $pytest_script $expect_out(1,string)] fail $output exp_continue } - -re "ERROR($prefix)\[^\r\n\]+\r\n" { + -re "ERROR($prefix)\r\n" { set output [gcov-pytest-format-line $testcase $pytest_script $expect_out(1,string)] fail $output exp_continue } - -re "PASSED($prefix)\[^\r\n\]+\r\n" { + -re "PASSED($prefix)\r\n" { set output [gcov-pytest-format-line $testcase $pytest_script $expect_out(1,string)] pass $output exp_continue diff --git a/gcc/testsuite/lib/scanhtml.exp b/gcc/testsuite/lib/scanhtml.exp index d5aa20a2e1ca..7f9035a195bf 100644 --- a/gcc/testsuite/lib/scanhtml.exp +++ b/gcc/testsuite/lib/scanhtml.exp @@ -71,17 +71,17 @@ proc run-html-pytest { args } { set prefix "\[^\r\n\]*" set timeout 300 expect { - -re "FAILED($prefix)\[^\r\n\]+\r\n" { + -re "FAILED($prefix)\r\n" { set output [html-pytest-format-line $testcase $pytest_script $expect_out(1,string)] fail $output exp_continue } - -re "ERROR($prefix)\[^\r\n\]+\r\n" { + -re "ERROR($prefix)\r\n" { set output [html-pytest-format-line $testcase $pytest_script $expect_out(1,string)] fail $output exp_continue } - -re "PASSED($prefix)\[^\r\n\]+\r\n" { + -re "PASSED($prefix)\r\n" { set output [html-pytest-format-line $testcase $pytest_script $expect_out(1,string)] pass $output exp_continue diff --git a/gcc/testsuite/lib/scansarif.exp b/gcc/testsuite/lib/scansarif.exp index a1fe90c41d57..bb28e836398a 100644 --- a/gcc/testsuite/lib/scansarif.exp +++ b/gcc/testsuite/lib/scansarif.exp @@ -182,17 +182,17 @@ proc run-sarif-pytest { args } { set prefix "\[^\r\n\]*" set timeout 300 expect { - -re "FAILED($prefix)\[^\r\n\]+\r\n" { + -re "FAILED($prefix)\r\n" { set output [sarif-pytest-format-line $testcase $pytest_script $expect_out(1,string)] fail $output exp_continue } - -re "ERROR($prefix)\[^\r\n\]+\r\n" { + -re "ERROR($prefix)\r\n" { set output [sarif-pytest-format-line $testcase $pytest_script $expect_out(1,string)] fail $output exp_continue } - -re "PASSED($prefix)\[^\r\n\]+\r\n" { + -re "PASSED($prefix)\r\n" { set output [sarif-pytest-format-line $testcase $pytest_script $expect_out(1,string)] pass $output exp_continue
