Skip to content

test(share): use an immutable cloudflared fixture entrypoint - #1334

Merged
yyjeqhc merged 1 commit into
yyjeqhc:mainfrom
skygunner:contrib/cloudflared-immutable-entrypoint-20261028
Oct 28, 2026
Merged

yyjeqhc merged 1 commit into
yyjeqhc:mainfrom
skygunner:contrib/cloudflared-immutable-entrypoint-20261028

Conversation

@skygunner

Copy link
Copy Markdown
Contributor

Problem

The fake_cloudflared test fixture wrote each test's shell script directly to the executable path and executed it. When any process still held a writable handle to that inode (for example a concurrent test fork inheriting the descriptor, or the writing test itself), exec failed with ETXTBSY (ExecutableFileBusy). This is a fixture/stability problem, not a production cloudflared behavior change.

Change

The fixture now executes a checked-in, immutable entrypoint (tests/fixtures/cloudflared.sh) through a symlink and keeps each test's script body in a sibling cloudflared.script data file that the entrypoint sources. Writable handles can only ever target the data file, never the executable inode. $0-relative paths keep working, including the existing <path>.descendant-pid and <path>.script conventions, and quoting keeps them correct in directories containing spaces.

Test-only: no production code, no real Cloudflare access, no credentials, no services are started.

Validation

cargo test --locked -p webcodex --lib fake_cloudflared
  -> 1 passed; 3835 filtered out

With the previous write-to-executable fixture restored, the same regression fails:
  called `Result::unwrap()` on an `Err` value: Os { code: 26, kind: ExecutableFileBusy, message: "Text file busy" }
  test result: FAILED. 0 passed; 1 failed; 3835 filtered out

cargo test --locked -p webcodex --lib cloudflare
  -> 33 passed; 5 ignored; 0 failed (includes the tunnel lifecycle/descendant cleanup tests that use this fixture)

The regression keeps writable handles open on every regular file in the fixture directory while invoking the fake binary, then asserts the expected stdout and exit status.

Platform: #[cfg(unix)], matching the existing fixture. Not run here: Windows and macOS lanes (no environment available).

The fake cloudflared executable could fail with ETXTBSY when a writable handle to its executable inode remained open. Execute a checked-in immutable entrypoint and keep each test's script body in a separate data file, with a regression that holds writers open while invoking the fixture.

@yyjeqhc yyjeqhc left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the scoped implementation and regression coverage against its source baseline; CI and diff checks pass. No blocking issue identified.

@yyjeqhc
yyjeqhc merged commit 91500c8 into yyjeqhc:main Oct 28, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants