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 <noreply@anthropic.com>
This commit is contained in:
@@ -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)"
|
||||
}
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user