[gcc r15-2389] Polish libstdc++ 'dg-final' action 'file-io-diff'
Thomas Schwinge
tschwinge@gcc.gnu.org
Mon Jul 29 21:47:39 GMT 2024
https://gcc.gnu.org/g:0544db1a4f8f250edb7f25eb0fa4dcfd569ec805
commit r15-2389-g0544db1a4f8f250edb7f25eb0fa4dcfd569ec805
Author: Thomas Schwinge <tschwinge@baylibre.com>
Date: Mon Jul 29 13:32:36 2024 +0200
Polish libstdc++ 'dg-final' action 'file-io-diff'
Follow-up to recent commit 515da03a838db05443ebcc4c543a405bed764188
"libstdc++: Add file-io-diff to replace @diff@ markup in I/O tests".
Currently, if a 'dg-final' action 'file-io-diff' passes, we print nothing
(should: 'PASS: [...]'), but if it fails, we just print: 'FAIL: files differ',
for example ('*.log' file):
[...]
FAIL: 27_io/basic_ostream/inserters_other/wchar_t/2.cc -std=gnu++17 (test for excess errors)
[...]
UNRESOLVED: 27_io/basic_ostream/inserters_other/wchar_t/2.cc -std=gnu++17 compilation failed to produce executable
diff: wostream_inserter_other_in.txt: No such file or directory
diff: wostream_inserter_other_out.txt: No such file or directory
FAIL: files differ
diff: wostream_inserter_other_in.txt: No such file or directory
diff: wostream_inserter_other_out.txt: No such file or directory
When later the '*.sum' files get sorted, these 'FAIL: files differ' instances
aren't grouped anymore with the other test cases' results, but they appear en
bloc, lexically sorted between ('e[...]' and 's[...]'), for example:
[...]
PASS: ext/vstring/types/23767.cc -std=gnu++17 (test for excess errors)
FAIL: files differ
FAIL: files differ
FAIL: files differ
PASS: special_functions/01_assoc_laguerre/check_nan.cc -std=gnu++17 (test for excess errors)
[...]
Also, we shouldn't emit the actual 'diff' into the '*.sum' file, but just into
the '*.log* file, and there's no need for 'spawn'/'expect', as we're not
matching any specific messages.
libstdc++-v3/
* testsuite/lib/libstdc++.exp (file-io-diff): Polish.
Diff:
---
libstdc++-v3/testsuite/lib/libstdc++.exp | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index c11e752ecfb1..18331c80bc27 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -1671,6 +1671,8 @@ if { [info exists env(GCC_RUNTEST_PARALLELIZE_DIR)] \
}
+# Utility functions, invoked via dg-final.
+
# Compare output file written by test to expected result.
# With two arguments the comparison is done via 'diff arg1 arg2'.
# With one argument the comparison is done via 'diff arg1.tst arg1.txt'.
@@ -1682,6 +1684,10 @@ proc file-io-diff { args } {
if { $nargs > 2 } {
error "too many arguments to file-io-diff"
}
+
+ set testcase [testname-for-summary]
+ set description "$testcase file-io-diff $args"
+
if { $nargs == 1 } {
set file1 [lindex $args 0]
set file2 "${file1}.txt"
@@ -1691,14 +1697,11 @@ proc file-io-diff { args } {
set file2 [lindex $args 1]
}
- spawn -noecho diff -u $file1 $file2
- expect {
- -re ".+" {
- set msg "files differ\n"
- append msg $expect_out(0,string)
- fail $msg
- exp_continue
- }
+ if { [catch { exec diff -u $file1 $file2 } msg] } {
+ fail $description
+ verbose -log "'diff':\n$msg"
+ } else {
+ pass $description
}
return
}
More information about the Libstdc++-cvs
mailing list