Skip to content

Commit ad1ee65

Browse files
KSXGitHubclaude
andauthored
chore: "no fail fast" test mode (#367)
* feat(test): add `PDU_NO_FAIL_FAST` mode to `test.sh` Add a no-fail-fast mode activated by `PDU_NO_FAIL_FAST=true` that continues running all checks instead of stopping at the first failure, then reports a summary at the end. This helps AI environments that may fail on some checks but need to see which ones pass. Update AI instruction templates to document the new flag. https://claude.ai/code/session_01VHRbHsz8VJFdNioSj6dyxe * fix(test): move no-fail-fast logic into `run_if` and use single quotes https://claude.ai/code/session_01VHRbHsz8VJFdNioSj6dyxe * fix(test): add comment and error message in no-fail-fast mode Add a comment explaining why a temporary file is used instead of a variable for the failure marker, and log the failed command with its exit code when no-fail-fast mode catches a failure. https://claude.ai/code/session_01VHRbHsz8VJFdNioSj6dyxe * docs(ai): remove conditional preamble from no-fail-fast instruction https://claude.ai/code/session_01VHRbHsz8VJFdNioSj6dyxe * docs(ai): remove conditional preamble from no-fail-fast instruction in template Update the source template and regenerate all AI instruction files. https://claude.ai/code/session_01VHRbHsz8VJFdNioSj6dyxe * fix(test): address review feedback on test.sh - Use mktemp -d with a marker file inside to avoid path reuse - Quote $failure_marker in the final check for consistency - Use $* instead of $@ in error message for unambiguous logging https://claude.ai/code/session_01VHRbHsz8VJFdNioSj6dyxe * fix(test): use EXIT trap to clean up temporary directory Replace explicit rm -rf calls with a trap to ensure cleanup happens even when errexit terminates the script early in fail-fast mode. https://claude.ai/code/session_01VHRbHsz8VJFdNioSj6dyxe * fix(test): improve error logging for failed commands in no-fail-fast mode Use `printf '%q'` with `"$@"` to preserve argument quoting and capture exit status into a variable for reliability. https://claude.ai/code/session_01VHRbHsz8VJFdNioSj6dyxe --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 800e537 commit ad1ee65

5 files changed

Lines changed: 39 additions & 1 deletion

File tree

.github/copilot-instructions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ Read and follow the CONTRIBUTING.md file in this repository for all code style c
1717
- Install toolchain before running tests: `rustup toolchain install "$(< rust-toolchain)" && rustup component add --toolchain "$(< rust-toolchain)" rustfmt clippy`
1818
- Run `FMT=true LINT=true BUILD=true TEST=true DOC=true ./test.sh` to validate changes. If a test fails with a hint about `RUSTFLAGS` and `--cfg pdu_test_skip_*`, follow the hint and rerun with the suggested flags.
1919
- **ALWAYS run the full test suite** (`FMT=true LINT=true BUILD=true TEST=true DOC=true ./test.sh`) before committing, regardless of how trivial the change seems — this includes documentation-only changes, comment edits, config changes, and refactors. The test suite checks formatting, linting, building, tests, and docs across multiple feature combinations; any type of change can break any of these checks.
20+
- Set `PDU_NO_FAIL_FAST=true` to run all checks instead of stopping at the first failure — this lets you see which checks pass and which fail

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ Read and follow the CONTRIBUTING.md file in this repository for all code style c
1717
- Install toolchain before running tests: `rustup toolchain install "$(< rust-toolchain)" && rustup component add --toolchain "$(< rust-toolchain)" rustfmt clippy`
1818
- Run `FMT=true LINT=true BUILD=true TEST=true DOC=true ./test.sh` to validate changes. If a test fails with a hint about `RUSTFLAGS` and `--cfg pdu_test_skip_*`, follow the hint and rerun with the suggested flags.
1919
- **ALWAYS run the full test suite** (`FMT=true LINT=true BUILD=true TEST=true DOC=true ./test.sh`) before committing, regardless of how trivial the change seems — this includes documentation-only changes, comment edits, config changes, and refactors. The test suite checks formatting, linting, building, tests, and docs across multiple feature combinations; any type of change can break any of these checks.
20+
- Set `PDU_NO_FAIL_FAST=true` to run all checks instead of stopping at the first failure — this lets you see which checks pass and which fail

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ Read and follow the CONTRIBUTING.md file in this repository for all code style c
1717
- Install toolchain before running tests: `rustup toolchain install "$(< rust-toolchain)" && rustup component add --toolchain "$(< rust-toolchain)" rustfmt clippy`
1818
- Run `FMT=true LINT=true BUILD=true TEST=true DOC=true ./test.sh` to validate changes. If a test fails with a hint about `RUSTFLAGS` and `--cfg pdu_test_skip_*`, follow the hint and rerun with the suggested flags.
1919
- **ALWAYS run the full test suite** (`FMT=true LINT=true BUILD=true TEST=true DOC=true ./test.sh`) before committing, regardless of how trivial the change seems — this includes documentation-only changes, comment edits, config changes, and refactors. The test suite checks formatting, linting, building, tests, and docs across multiple feature combinations; any type of change can break any of these checks.
20+
- Set `PDU_NO_FAIL_FAST=true` to run all checks instead of stopping at the first failure — this lets you see which checks pass and which fail
2021
- `gh` (GitHub CLI) is not installed — do not attempt to use it

template/ai-instructions/shared.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ Read and follow the CONTRIBUTING.md file in this repository for all code style c
1717
- Install toolchain before running tests: `rustup toolchain install "$(< rust-toolchain)" && rustup component add --toolchain "$(< rust-toolchain)" rustfmt clippy`
1818
- Run `FMT=true LINT=true BUILD=true TEST=true DOC=true ./test.sh` to validate changes. If a test fails with a hint about `RUSTFLAGS` and `--cfg pdu_test_skip_*`, follow the hint and rerun with the suggested flags.
1919
- **ALWAYS run the full test suite** (`FMT=true LINT=true BUILD=true TEST=true DOC=true ./test.sh`) before committing, regardless of how trivial the change seems — this includes documentation-only changes, comment edits, config changes, and refactors. The test suite checks formatting, linting, building, tests, and docs across multiple feature combinations; any type of change can break any of these checks.
20+
- Set `PDU_NO_FAIL_FAST=true` to run all checks instead of stopping at the first failure — this lets you see which checks pass and which fail

test.sh

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
#! /bin/bash
22
set -o errexit -o pipefail -o nounset
33

4+
# Validate PDU_NO_FAIL_FAST
5+
no_fail_fast="${PDU_NO_FAIL_FAST:-false}"
6+
case "$no_fail_fast" in
7+
true | false) ;;
8+
*)
9+
echo "error: Invalid value for PDU_NO_FAIL_FAST: $no_fail_fast (expected 'true' or 'false')" >&2
10+
exit 1
11+
;;
12+
esac
13+
14+
# A temporary file is used instead of a variable because run_if and unit are
15+
# subshells, so variable assignments inside them don't propagate to the parent.
16+
failure_dir=$(mktemp -d)
17+
trap 'rm -rf "$failure_dir"' EXIT
18+
failure_marker="$failure_dir/failed"
19+
420
run() (
521
echo >&2
622
echo "exec> $*" >&2
@@ -16,7 +32,19 @@ run_if() (
1632
condition="$1"
1733
shift
1834
case "$condition" in
19-
true) run "$@" ;;
35+
true)
36+
if [[ $no_fail_fast == 'true' ]]; then
37+
run "$@" || {
38+
exit_status=$?
39+
printf 'error: Command failed with exit code %d: ' "$exit_status" >&2
40+
printf '%q ' "$@" >&2
41+
printf '\n' >&2
42+
touch "$failure_marker"
43+
}
44+
else
45+
run "$@"
46+
fi
47+
;;
2048
false) skip "$@" ;;
2149
*)
2250
echo "error: Invalid condition: $condition" >&2
@@ -39,3 +67,9 @@ unit --all-features "$@"
3967
unit --features cli "$@"
4068
unit --features cli-completions "$@"
4169
unit --features ai-instructions "$@"
70+
71+
if [[ -f "$failure_marker" ]]; then
72+
echo >&2
73+
echo 'error: Some checks have failed. Review the output above for details.' >&2
74+
exit 1
75+
fi

0 commit comments

Comments
 (0)