From: Karl Berry Date: Tue, 24 Nov 2020 02:04:56 +0000 (-0800) Subject: tests: create log file before running the test script. X-Git-Tag: v1.16.4~42 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a5af212ccd20da0ee772709dfc2019c30666bef5;p=thirdparty%2Fautomake.git 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. --- diff --git a/NEWS b/NEWS index ec6915fcb..df978a54d 100644 --- 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. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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"