testers.testBuildFailure: Read last log line without final newline

This commit is contained in:
Robert Hensing 2022-12-02 16:11:59 +00:00
parent 6be5bb3172
commit dbdd8fad26
2 changed files with 11 additions and 2 deletions

View File

@ -21,7 +21,7 @@ set -eu
echo "testBuildFailure: Expecting non-zero exit from builder and args: ${*@Q}"
("$@" 2>&1) | @coreutils@/bin/tee $TMPDIR/testBuildFailure.log \
| while read ln; do
| while IFS= read -r ln; do
echo "original builder: $ln"
done

View File

@ -29,15 +29,24 @@ lib.recurseIntoAttrs {
happy = runCommand "testBuildFailure-happy" {
failed = testers.testBuildFailure (runCommand "fail" {} ''
echo ok-ish >$out
echo failing though
echo also stderr 1>&2
echo 'line\nwith-\bbackslashes'
printf "incomplete line - no newline"
exit 3
'');
} ''
grep -F 'ok-ish' $failed/result
grep -F 'failing though' $failed/testBuildFailure.log
grep -F 'also stderr' $failed/testBuildFailure.log
grep -F 'ok-ish' $failed/result
grep -F 'line\nwith-\bbackslashes' $failed/testBuildFailure.log
grep -F 'incomplete line - no newline' $failed/testBuildFailure.log
[[ 3 = $(cat $failed/testBuildFailure.exit) ]]
touch $out
'';