From 523c5b9b152553de81b492a26392f9fb08bf43bb Mon Sep 17 00:00:00 2001 From: David Young Date: Thu, 5 Nov 2026 07:28:10 -0700 Subject: [PATCH] smoketest: write run_in_vm's log as the command runs So a long command (install.sh takes an hour or more) can be followed with tail -f; run_in_vm prints the log's path when it starts. Co-Authored-By: Claude Opus 5.5 --- smoketest/lib/scenario.sh | 9 +++++---- tests/smoketest.bats | 6 ++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/smoketest/lib/scenario.sh b/smoketest/lib/scenario.sh index aa934b4..4fe7aeb 100644 --- a/smoketest/lib/scenario.sh +++ b/smoketest/lib/scenario.sh @@ -47,14 +47,15 @@ skip() { # run_in_vm NAME SCRIPT: run SCRIPT in the VM, keeping its output in $OUTPUT, # its exit status in $STATUS, and both in NN-NAME.log. Doesn't fail on its own: -# check with assert_status. +# check with assert_status. The log is written as SCRIPT runs, so a long one +# (install.sh takes an hour or more) can be followed with tail -f. run_in_vm() { RUN_COUNT=$((RUN_COUNT + 1)) LAST_RUN="$1" LAST_LOG="$SMOKETEST_RESULTS/$(printf '%02d' "$RUN_COUNT")-$1.log" - echo "== $1" - OUTPUT="$(vm_exec "$2" 2>&1)" && STATUS=0 || STATUS=$? - printf '%s\n' "$OUTPUT" > "$LAST_LOG" + echo "== $1 (to follow it: tail -f $LAST_LOG)" + vm_exec "$2" > "$LAST_LOG" 2>&1 && STATUS=0 || STATUS=$? + OUTPUT="$(cat "$LAST_LOG")" echo "== $1 exited $STATUS (log: $LAST_LOG)" } diff --git a/tests/smoketest.bats b/tests/smoketest.bats index 8bb3508..94fd9cd 100644 --- a/tests/smoketest.bats +++ b/tests/smoketest.bats @@ -131,6 +131,12 @@ upstream_main() { [ -f "$SMOKETEST_RESULTS/02-second.log" ] } +@test "run_in_vm writes its log while the script runs" { + run_in_vm slow 'echo early; cat "$SMOKETEST_RESULTS/01-slow.log" > "$HOME/seen"' + [ "$STATUS" -eq 0 ] + [ "$(cat "$HOME/seen")" = early ] +} + @test "cd_update passes its variables to update" { mkdir -p "$HOME/.local/bin" printf '%s\n' '#!/bin/bash' 'echo "force=$UPDATE_FORCE"' > "$HOME/.local/bin/update"