-
Notifications
You must be signed in to change notification settings - Fork 2
test(daemon): pin the dev daemon-namespace contract, and correct its docs #1378
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
Merged
+93
−5
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # `fbuild-build-engine` integration tests | ||
|
|
||
| Tests that need a separate final executable, or that exercise a contract | ||
| spanning this crate and one of its external dependencies. | ||
|
|
||
| - **`dev_daemon_namespace_isolation.rs`** — proves the dev daemon-identity | ||
| stamp `fbuild-paths` exports actually changes the zccache IPC endpoint | ||
| (FastLED/fbuild#1285). It lives here because this is the crate that depends | ||
| on both sides: `fbuild-paths` produces the stamp but cannot see zccache, and | ||
| zccache consumes it but is a pinned external dependency. A repin that | ||
| dropped endpoint namespacing would otherwise pass every other test in the | ||
| tree while quietly restoring the `displace-stale` daemon war. |
68 changes: 68 additions & 0 deletions
68
crates/fbuild-build-engine/tests/dev_daemon_namespace_isolation.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| //! The dev daemon-identity stamp actually isolates the compile daemon | ||
| //! (FastLED/fbuild#1285). | ||
| //! | ||
| //! `fbuild-paths` derives a per-checkout stamp and exports it as | ||
| //! `ZCCACHE_DAEMON_NAMESPACE`; zccache folds that value into the IPC endpoint | ||
| //! its daemons rendezvous on. Neither half can prove the other works — the | ||
| //! producer lives in a crate that does not depend on zccache, and the | ||
| //! consumer is a pinned external dependency — so the contract *between* them | ||
| //! was asserted only in prose, and the prose was wrong: both #1285's tracking | ||
| //! comment and `fbuild_paths::dev_daemon_namespace`'s module doc claimed the | ||
| //! export was inert until fbuild repinned zccache. It is not; it has been | ||
| //! live since the stamp landed. | ||
| //! | ||
| //! This test is the place that can tell. It lives in `fbuild-build-engine` | ||
| //! because that is the crate depending on both sides. A zccache repin that | ||
| //! silently dropped endpoint namespacing would take the `displace-stale` war | ||
| //! from zackees/soldr#2352 with it, and nothing else in the tree would | ||
| //! notice. | ||
|
|
||
| use fbuild_paths::dev_daemon_namespace::ZCCACHE_DAEMON_NAMESPACE_ENV; | ||
|
|
||
| /// One test, not three: the variable is process-global, so parallel cases | ||
| /// would race each other's `set_var`. | ||
| #[test] | ||
| fn the_exported_stamp_changes_the_zccache_daemon_endpoint() { | ||
| // SAFETY: this test binary contains one test, so no peer thread can | ||
| // observe the process-wide environment change. | ||
| unsafe { std::env::remove_var(ZCCACHE_DAEMON_NAMESPACE_ENV) }; | ||
| let bare = zccache::ipc::default_endpoint(); | ||
|
|
||
| unsafe { std::env::set_var(ZCCACHE_DAEMON_NAMESPACE_ENV, "2.5.0-aaaaaaaaaaaaaaaa") }; | ||
| let first = zccache::ipc::default_endpoint(); | ||
|
|
||
| unsafe { std::env::set_var(ZCCACHE_DAEMON_NAMESPACE_ENV, "2.5.0-bbbbbbbbbbbbbbbb") }; | ||
| let second = zccache::ipc::default_endpoint(); | ||
|
|
||
| unsafe { std::env::remove_var(ZCCACHE_DAEMON_NAMESPACE_ENV) }; | ||
| let bare_again = zccache::ipc::default_endpoint(); | ||
|
|
||
| // The property that matters: two checkouts with different stamps do not | ||
| // meet on one pipe. Without this, each displaces the other as | ||
| // "stale-version" on every invocation and the compile daemon wedges. | ||
| assert_ne!( | ||
| first, second, | ||
| "two stamps must rendezvous on two different endpoints" | ||
| ); | ||
| assert_ne!( | ||
| first, bare, | ||
| "a stamped endpoint must differ from the unstamped one" | ||
| ); | ||
|
|
||
| // An unset stamp must keep the historical endpoint, or release builds | ||
| // would silently move off the daemon they share on upgrade — the | ||
| // single-daemon-on-upgrade semantics #1285 deliberately preserves for | ||
| // non-dev invocations. | ||
| assert_eq!( | ||
| bare, bare_again, | ||
| "clearing the stamp must restore the original endpoint exactly" | ||
| ); | ||
|
|
||
| // The stamp is expected to appear in the endpoint rather than merely | ||
| // perturb a hash of it: an operator reading `\\.\pipe\...` or a socket | ||
| // path should be able to see which checkout owns the daemon. | ||
| assert!( | ||
| second.contains("bbbbbbbbbbbbbbbb"), | ||
| "the stamp should be legible in the endpoint, got {second}" | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Keep the documented test path contiguous.
Lines 18-19 split an inline code span. Rustdoc renders the line break as a space. The displayed path does not identify
dev_daemon_namespace_isolation.rs. Keep the path on one line.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents