Skip to content

Commit 9bf941d

Browse files
committed
ci: replace global RUST_TEST_THREADS=1 with per-crate --test-threads=1
On musl, fork() is unsafe when other threads exist — even threads sleeping on a futex leave musl internal state that the child inherits in an inconsistent form, causing SIGSEGV between fork and exec. A process-wide mutex (PTY_LOCK) cannot fix this because the test harness still spawns multiple threads (one per test). The real fix is --test-threads=1 for PTY test binaries, which ensures only one thread exists during fork. Split `cargo test` into: - Non-PTY tests: run in parallel (default thread count) - PTY tests (pty_terminal, pty_terminal_test, vite_task_bin): run with --test-threads=1 This removes the global RUST_TEST_THREADS=1 that forced ALL tests to run sequentially, improving CI speed for non-PTY tests. https://claude.ai/code/session_011H8UR3gS6hoyQAf2x7Dfw8
1 parent ef64d0f commit 9bf941d

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,6 @@ jobs:
149149
# -crt-static: vite-task is shipped as a NAPI module in vite+, and musl Node
150150
# with native modules links to musl libc dynamically, so we must do the same.
151151
RUSTFLAGS: --cfg tokio_unstable -D warnings -C target-feature=-crt-static
152-
# On musl, concurrent PTY operations can trigger SIGSEGV in musl internals.
153-
# Run test threads sequentially to avoid the race.
154-
RUST_TEST_THREADS: 1
155152
steps:
156153
- name: Install Alpine dependencies
157154
shell: sh {0}
@@ -175,7 +172,15 @@ jobs:
175172
corepack enable
176173
pnpm install
177174
178-
- run: cargo test
175+
# Run non-PTY tests in parallel (default thread count).
176+
- run: cargo test --workspace --exclude pty_terminal --exclude pty_terminal_test --exclude vite_task_bin
177+
178+
# PTY tests must run single-threaded: musl's fork() is not safe when
179+
# other threads exist (even sleeping on a futex), because musl internal
180+
# state inherited by the child can be inconsistent.
181+
- run: cargo test -p pty_terminal -- --test-threads=1
182+
- run: cargo test -p pty_terminal_test -- --test-threads=1
183+
- run: cargo test -p vite_task_bin -- --test-threads=1
179184

180185
fmt:
181186
name: Format and Check Deps

0 commit comments

Comments
 (0)