Repository navigation
Fail CI on xcodebuild hard failures #4523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
41ae7a4
7307196
1c8aa6c
4536cb9
7526947
c4efce2
7198d4d
2e6337b
45283a0
4cf6fd3
b290fa9
2632c10
dbee03e
188cb69
df70495
901f4ab
55207d5
d8ee907
e946810
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| #!/usr/bin/env bash | ||
| # Regression test for CI unit-test hard-failure detection. | ||
| set -euo pipefail | ||
|
|
||
| ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)" | ||
| SCRIPT="$ROOT_DIR/scripts/ci-unit-test-output-guard.sh" | ||
| WORKFLOW_FILE="$ROOT_DIR/.github/workflows/ci.yml" | ||
| TMP_DIR="$(mktemp -d)" | ||
| trap 'rm -rf "$TMP_DIR"' EXIT | ||
|
|
||
| if [ ! -x "$SCRIPT" ]; then | ||
| echo "FAIL: missing executable hard-failure guard at $SCRIPT" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! grep -Fq './tests/test_ci_unit_test_output_guard.sh' "$WORKFLOW_FILE"; then | ||
| echo "FAIL: ci.yml must run the unit-test hard-failure guard test" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! grep -Fq './scripts/ci-unit-test-output-guard.sh "$EXIT_CODE" /tmp/test-output.txt' "$WORKFLOW_FILE"; then | ||
| echo "FAIL: ci.yml must run the hard-failure guard before parsing XCTest summaries" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| write_log() { | ||
| local name="$1" | ||
| shift | ||
| printf '%s\n' "$@" > "$TMP_DIR/$name.log" | ||
| } | ||
|
|
||
| expect_pass() { | ||
| local exit_code="$1" | ||
| local log_name="$2" | ||
| if ! "$SCRIPT" "$exit_code" "$TMP_DIR/$log_name.log" > "$TMP_DIR/$log_name.out" 2>&1; then | ||
| echo "FAIL: expected $log_name to pass guard" >&2 | ||
| cat "$TMP_DIR/$log_name.out" >&2 | ||
| exit 1 | ||
| fi | ||
| } | ||
|
|
||
| expect_fail() { | ||
| local exit_code="$1" | ||
| local log_name="$2" | ||
| local expected="$3" | ||
| if "$SCRIPT" "$exit_code" "$TMP_DIR/$log_name.log" > "$TMP_DIR/$log_name.out" 2>&1; then | ||
| echo "FAIL: expected $log_name to fail guard" >&2 | ||
| exit 1 | ||
| fi | ||
| if ! grep -Fq "$expected" "$TMP_DIR/$log_name.out"; then | ||
| echo "FAIL: $log_name did not report expected reason: $expected" >&2 | ||
| cat "$TMP_DIR/$log_name.out" >&2 | ||
| exit 1 | ||
| fi | ||
| } | ||
|
|
||
| write_log expected-fail \ | ||
| "Test Suite 'Selected tests' failed." \ | ||
| "Executed 1 test, with 1 failure (0 unexpected) in 0.1 seconds" | ||
| expect_pass 65 expected-fail | ||
|
|
||
| write_log timeout-after-summary \ | ||
| "Executed 1 test, with 1 failure (0 unexpected) in 0.1 seconds" \ | ||
| "xcodebuild unit test timeout after 900s; terminating" \ | ||
| "** BUILD INTERRUPTED **" | ||
| expect_fail 124 timeout-after-summary "xcodebuild watchdog timeout" | ||
|
Comment on lines
+72
to
+76
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed by adding a timeout-string-only case with a non-124 exit code, so the log pattern is covered independently of the process timeout status. — Claude Code
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Already addressed in current head: tests/test_ci_unit_test_output_guard.sh includes timeout-string-only with exit code 65, which exercises timeout detection from log text without relying on exit code 124. — Claude Code |
||
|
|
||
| write_log build-interrupted \ | ||
| "Executed 1 test, with 1 failure (0 unexpected) in 0.1 seconds" \ | ||
| "** BUILD INTERRUPTED **" | ||
| expect_fail 65 build-interrupted "xcodebuild build interruption" | ||
|
|
||
| write_log swift-crash \ | ||
| "Executed 1 test, with 1 failure (0 unexpected) in 0.1 seconds" \ | ||
| "Program crashed: Signal 11: Backtracing from 0x18b5c4028..." | ||
| expect_fail 65 swift-crash "Swift crash output" | ||
|
|
||
| write_log swift-backtrace-prompt \ | ||
| "Executed 1 test, with 1 failure (0 unexpected) in 0.1 seconds" \ | ||
| "Press space to interact, D to debug, or any other key to quit (1s)" | ||
| expect_fail 65 swift-backtrace-prompt "Swift crash output" | ||
|
|
||
| echo "PASS: CI unit-test output guard fails hard-failure logs" | ||
Uh oh!
There was an error while loading. Please reload this page.