]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
tests: create log file before running the test script.
authorKarl Berry <karl@freefriends.org>
Tue, 24 Nov 2020 02:04:56 +0000 (18:04 -0800)
committerKarl Berry <karl@freefriends.org>
Tue, 24 Nov 2020 02:05:55 +0000 (18:05 -0800)
This change partially fixes https://bugs.gnu.org/35762.

* lib/test-driver: create $log_file before running the
test script. Also quote $log_file. Combined suggestions
from howaboutsynergy and Eric Blake.

NEWS
lib/test-driver

diff --git a/NEWS b/NEWS
index ec6915fcb25e07078eb7f0a8aef9c1107636a7e3..df978a54d95babac3bd472dfb07198e59acb14bb 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -64,6 +64,9 @@
 
 New in ?.?.?:
 
+* Bugs fixed
+
+  - test-driver less likely to clash with tests writing to the same file.
 
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
index 9759384aa72c4e4a80362a046b3e71d496e15651..00c468073a5a8953f05744db97b91d57caa266ba 100755 (executable)
@@ -105,8 +105,11 @@ trap "st=130; $do_exit" 2
 trap "st=141; $do_exit" 13
 trap "st=143; $do_exit" 15
 
-# Test script is run here.
-"$@" >$log_file 2>&1
+# Test script is run here. We create the file first, then append to it,
+# to ameliorate tests themselves also writing to the log file. Our tests
+# don't, but others can (automake bug#35762).
+: >"$log_file"
+"$@" >>"$log_file" 2>&1
 estatus=$?
 
 if test $enable_hard_errors = no && test $estatus -eq 99; then
@@ -128,7 +131,7 @@ esac
 # know whether the test passed or failed simply by looking at the '.log'
 # file, without the need of also peaking into the corresponding '.trs'
 # file (automake bug#11814).
-echo "$res $test_name (exit status: $estatus)" >>$log_file
+echo "$res $test_name (exit status: $estatus)" >>"$log_file"
 
 # Report outcome to console.
 echo "${col}${res}${std}: $test_name"