summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-11-23 18:04:56 -0800
committerKarl Berry <karl@freefriends.org>2020-11-23 18:05:55 -0800
commita5af212ccd20da0ee772709dfc2019c30666bef5 (patch)
tree3aa1edd34d7a5b8cc9ca5f3f3129a0cfbf627a30 /lib
parentdd616e2dd21943486580ebc0e235aac2bb48b834 (diff)
downloadautomake-a5af212ccd20da0ee772709dfc2019c30666bef5.tar.gz
tests: create log file before running the test script.
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.
Diffstat (limited to 'lib')
-rwxr-xr-xlib/test-driver9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/test-driver b/lib/test-driver
index 9759384aa..00c468073 100755
--- a/lib/test-driver
+++ b/lib/test-driver
@@ -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"