test: シナリオの setup.sh 失敗時に出力末尾を CI ログへ残す - #172
Conversation
シナリオテストは run_setup / run_setup_update の出力を >/dev/null 2>&1 で 捨てているため、setup.sh が失敗しても CI ログには「(setup failed)」か、 `|| rc=$?` のない呼び出しでは set -e による runner の無言中断しか残らず、 原因を追えなかった。macOS ジョブの先頭シナリオで 2026-09-06〜08 に 3 回 起きた一過性失敗(約 20 秒で setup.sh が非ゼロ終了)がこの状態で、 再実行でしか回復できていない。 - tests/helpers.sh: runner の元 stdout を fd 3 に複製し、setup.sh の出力を 一時ファイルへ取ってから stdout に再生する。非ゼロ終了時は末尾 _TEST_SETUP_LOG_TAIL 行(既定 20)を fd 3 へ出す。呼び出し側の fd 1/2 リダイレクトや `$(...)` 取り込みは影響を受けない - tests/unit/test-helpers-run-setup.sh: 偽の setup.sh で失敗時の tail 出力、 成功時の無出力、run_setup_update の引数と取り込み出力の不変を検証 ローカル確認: SCENARIO_GROUP=core 14 PASS / 1 SKIP(bash4 既定)、 新規単体テスト 3/3、shellcheck、/bin/bash -n Claude-Session: https://claude.ai/code/session_01C9mrbbXQgV9fJ8Zy5UoEYc
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
🟡 Changes recommended
set -euo pipefail 下で mktemp/tail 周りが失敗すると診断出力を残す前に runner 自体が中断し得るため、失敗時に確実に「原因追跡に必要な出力」が残るようガードを入れたいです。
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
シナリオテストが run_setup / run_setup_update の出力を捨てているため、setup.sh 失敗時に原因が CI ログから追えない問題を、失敗時のみ stdout とは別経路でログ末尾を残す形で診断可能にする PR です。
Changes:
run_setup/run_setup_updateを、setup.shの結合出力を一旦一時ファイルに収集→完了後に stdout へ再生する方式に変更setup.shが非ゼロ終了した場合、ログ末尾_TEST_SETUP_LOG_TAIL行を runner の元 stdout を指す fd 3 に出力する診断を追加- 上記の挙動(失敗時 tail が fd 3 に出る/成功時 fd 3 は無出力/呼び出し側の出力キャプチャに混ざらない)を unit test で検証
File summaries
| File | Description |
|---|---|
| tests/helpers.sh | setup.sh 出力の収集・再生と、失敗時の fd 3 への tail 出力を追加して CI ログ診断性を向上 |
| tests/unit/test-helpers-run-setup.sh | run_setup / run_setup_update の新しい診断挙動を fake setup.sh で検証する unit test を追加 |
Review details
Suppressed comments (1)
tests/helpers.sh:130
log="$(mktemp)"and thetail | sedpipeline can fail underset -euo pipefail(e.g., mktemp failure or an unexpected tail error), which would terminate the runner and skip returning the original setup.sh exit code. It’s safer to guard mktemp and ensure the tail formatting can’t abort the test run.
_run_setup_logged() {
local log rc=0
log="$(mktemp)"
bash "$PROJECT_DIR/setup.sh" "$@" >"$log" 2>&1 || rc=$?
if [[ "$rc" -ne 0 ]]; then
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| _TEST_SETUP_LOG_TAIL="${_TEST_SETUP_LOG_TAIL:-20}" | ||
|
|
概要
シナリオテストは
run_setup/run_setup_updateの出力を>/dev/null 2>&1で捨てているため、setup.sh が失敗しても CI ログには「(setup failed)」か、|| rc=$?のない呼び出しでは set -e による runner の無言中断しか残らず、原因を追えない。macOS ジョブの先頭シナリオで 2026-09-06〜08 に 3 回起きた一過性失敗(#170 attempt 1 の
update-no-changes (setup failed)、#171 のupdate-merge無言中断とupdate-no-changes (setup failed)。いずれも step 開始から約 20 秒で setup.sh が非ゼロ終了し、再実行では通る)がこの状態で、現状は再実行でしか回復できていない。変更
tests/helpers.sh: runner の元 stdout を fd 3 に複製し、setup.sh の出力を一時ファイルへ取ってから stdout に再生する。非ゼロ終了時は末尾_TEST_SETUP_LOG_TAIL行(既定 20)を fd 3 へ出す。呼び出し側の fd 1/2 リダイレクトや$(...)取り込みは影響を受けない(成功時の挙動は出力がストリーミングではなく完了後の一括再生になる点だけが変わる)tests/unit/test-helpers-run-setup.sh: 偽の setup.sh で、失敗時の tail 出力(fd 3)、成功時の無出力、run_setup_updateの引数と$(...)取り込み出力に tail が混ざらないことを検証確認
SCENARIO_GROUP=core bash tests/run-scenarios.sh(brew bash 5.3): 14 PASS / 1 SKIP(bash4-noninteractive-unavailable、Bash 4+ 環境の既定)shellcheck -S warning、/bin/bash -n(Bash 3.2): 指摘 0補足
この PR 自体は失敗の原因を直すものではなく、次に同じ失敗が起きたときに setup.sh の出力末尾が CI ログに残るようにするもの。原因が特定でき次第、別 PR で対処する。
https://claude.ai/code/session_01C9mrbbXQgV9fJ8Zy5UoEYc