diff --git a/scripts/check-phase14.2.sh b/scripts/check-phase14.2.sh index 1b0e105..76e9d74 100755 --- a/scripts/check-phase14.2.sh +++ b/scripts/check-phase14.2.sh @@ -200,7 +200,9 @@ scan_go_log() { echo "refuse: Go log $file not found" >&2 return 1 } - if ! tail -c "+$((offset + 1))" "$file" | grep -q 'msg="http request"'; then + # grep reads the whole tail (-c, not -q): an early exit would end tail + # with SIGPIPE, which pipefail turns into a false refusal. + if [[ "$(tail -c "+$((offset + 1))" "$file" | grep -c 'msg="http request"' || true)" == 0 ]]; then echo "refuse: $file has no http request record from this run; set SUMMER_HTTP__ACCESS_LOG=true in the env file" >&2 return 1 fi @@ -388,6 +390,11 @@ run_self_test() { expect_status go-log-old-records 1 scan_go_log "$dir/old-records.log" "$(stat -c '%s' "$dir/clean.log")" cat "$dir/no-records.log" "$dir/clean.log" >"$dir/new-records.log" expect_status go-log-new-records 0 scan_go_log "$dir/new-records.log" "$(stat -c '%s' "$dir/no-records.log")" + # A long log after an early record: the search for it must not fail when + # it stops reading early (SIGPIPE under pipefail). + cp "$dir/clean.log" "$dir/long.log" + python3 -c 'import sys; sys.stdout.write("[go] level=INFO msg=\"http request\" method=GET pattern=\"GET /a\" status=200 duration_ms=1\n" * 20000)' >>"$dir/long.log" + expect_status go-log-long 0 scan_go_log "$dir/long.log" printf '# tests 9\n# pass 9\n# fail 0\n# cancelled 0\n# skipped 0\n# todo 0\n' >"$dir/tap-clean" printf '# tests 9\n# pass 8\n# fail 1\n# cancelled 0\n# skipped 0\n# todo 0\n' >"$dir/tap-fail" printf '# tests 9\n# pass 8\n# fail 0\n# cancelled 0\n# skipped 1\n# todo 0\n' >"$dir/tap-skip"