Skip to content

test(detach): ask the marker rule, not the machine the suite runs on - #14

Merged
whackur merged 1 commit into
code0xff:devfrom
whackur:test/detach-marker-independent-of-env
Aug 1, 2026
Merged

test(detach): ask the marker rule, not the machine the suite runs on#14
whackur merged 1 commit into
code0xff:devfrom
whackur:test/detach-marker-independent-of-env

Conversation

@whackur

@whackur whackur commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

cargo test fails on a_process_with_no_marker_is_the_foreground_copy
when the suite is run from inside a nightcrow pane. Not a flake and not
a Windows quirk: the pane's shell inherits NIGHTCROW_DETACHED from the
daemon that spawned it, and the test read that same variable through
is_detached_child().

thread 'daemon::detach::tests::a_process_with_no_marker_is_the_foreground_copy'
panicked at src\daemon\detach_tests.rs:15:5:
assertion failed: !is_detached_child()

So the test asserted a fact about the machine it ran on rather than
about the rule it names. CI never saw it, because CI is not inside a
nightcrow pane — but anyone dogfooding the tool hits it on every run,
including through the pre-push gate.

The change

is_detached_child read the environment and decided in one step. Those
are now two steps, the way child_args and background_command are
already split from spawning:

pub fn is_detached_child() -> bool {
    marker_says_detached(std::env::var_os(ALREADY_DETACHED).as_deref())
}

fn marker_says_detached(marker: Option<&OsStr>) -> bool {
    marker.is_some()
}

The tests pass the marker in. Both answers are stated outright instead
of one of them depending on ambient state, and a third case the rule
quietly carried is pinned: presence is what counts, so an empty value is
still a marker and must not send the child off to detach again.

Verification

Full suite green with NIGHTCROW_DETACHED=1 still set in the shell
1419 passed, 0 failed — which is the case that used to fail. clippy -D warnings and fmt --check pass; the pre-push gate now runs clean from
inside a pane without clearing the variable first.

`is_detached_child` read the environment and decided in one step, so the
foreground case could only be tested by having no marker set — which is
a fact about the machine. Running the suite from inside a nightcrow pane
inherits `NIGHTCROW_DETACHED` from the daemon that spawned the pane, and
the test then failed while saying nothing about the rule it names.

Split the read from the rule, the way `child_args` and
`background_command` are already split from spawning. Both answers are
now stated outright, and the third case the rule quietly carries — that
presence is what counts, so an empty value is still a marker and must
not send the child off to detach again — is pinned rather than implied.
@whackur
whackur merged commit c916263 into code0xff:dev Aug 1, 2026
6 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.

1 participant