Commit Graph

4 Commits

Author SHA1 Message Date
Maximilian Roos 715af4cd72 fix(tests): pin the spawned wt binary against concurrent cargo uplifts (#3784)
Two test-suite flakes fixed at the root, both dependencies on machine
load and concurrent builds.

**Concurrent-cargo spawn `NotFound`.** Cargo uplifts `target/debug/wt`
by removing the path and recreating it, so a second `cargo` against the
same target directory leaves the binary every test spawns absent for a
fraction of a millisecond per rebuild — the one-off `NotFound` spawn
failures that pass on re-run. `wt_bin()` now returns a hardlink pinned
under `target/debug/wt-test-bin/<mtime>-<len>/`: the uplift unlinks only
the uplifted name, so the pin keeps serving the observed binary through
any number of concurrent rebuilds, at no disk cost beyond the `deps/`
artifact whose inode it shares. `test_wt_spawns_are_pinned` keeps every
spawn routed through it. Reproduced by re-creating the uplift every 200
ms alongside a full `cargo nextest run`: 302 of 4583 tests failed before
this change (147 as direct `NotFound` spawn panics, five of them
byte-identical to the original shell-wrapper report), 4585 of 4585 after
— with an unrelated external cargo also rebuilding `wt` mid-validation,
absorbed the same way.

**`--reap` probe races.** `test_remove_reap_kills_process` predicted the
reap guard's verdict with its own `lsof`/`ps` snapshot, and under load
either probe's spawn can stall past the 5 s bound, whose fail-safe empty
result flips the outcome — a prediction `wt` then contradicts, or `wt`
reporting "No processes to reap" for a live child. The prediction now
reads the session's controlling terminal directly (`/dev/tty` opens iff
the session has one — the property the child inherits at spawn), the
probe timeout is env-pinnable (`WORKTRUNK_TEST_PROBE_TIMEOUT_MS`, set to
60 s in the static test baseline; production keeps its 5 s bound), and
the discovery poll uses the suite's 60 s presence-poll convention.
Looped 15/15 green at load average ~60, where the previous shape failed
2/10.

Not covered here, noted as follow-ups: benches still spawn
`env!("CARGO_BIN_EXE_wt")` directly (same hazard, separate runner,
outside the guard's scan), and the reap "spared" branch has no
deterministic end-to-end test (needs a PTY-held child).

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-09 07:06:08 -07:00
Worktrunk Bot eba35d039c fix(shell): stop PowerShell wrapper leaking a stray exit-code line to stdout (#3425) 2026-07-12 01:54:55 -07:00
Maximilian Roos 516f90bac4 fix(shell): PowerShell wrapper swallows -D flag as -Debug (#1057)
* fix(shell): PowerShell wrapper swallows -D flag as -Debug (#885)

The `[Parameter(ValueFromRemainingArguments)]` attribute promoted the
wrapper to an "advanced function", which adds common parameters like
-Debug and -Verbose. PowerShell then consumed `-D` as `-Debug` instead
of passing it to wt.exe — so `wt remove -D` silently lost the flag.

Replace with `$args` (automatic variable for simple functions) which
passes all arguments through unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(test): use .ps1 mock for cross-platform PowerShell test

The shell script mock (#!/bin/sh) doesn't work on Windows. Use a .ps1
script instead — pwsh can invoke it directly with &, and pwsh is already
required for this test.

Co-Authored-By: Claude <noreply@anthropic.com>

* style: apply cargo fmt to PowerShell test

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-15 23:36:32 -08:00
Maximilian Roos 722e70373d fix(shell): add | Out-String to PowerShell config_line (#888)
* fix(shell): add `| Out-String` to PowerShell config_line (#885)

PowerShell command output is an array of strings by default, but
`Invoke-Expression` expects a single string. Without `| Out-String`,
users get "Cannot convert 'System.Object[]' to the type 'System.String'".

Also adds PSModulePath hint to `wt config show` diagnostics on Windows.

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: add wt to PATH in PowerShell test, remove PSModulePath hint

- Add bin_dir to PATH so `Get-Command wt` works in CI
- Remove PSModulePath diagnostic to fix Windows snapshot failures

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: move PowerShell test to integration tests

CARGO_BIN_EXE_wt is only available in integration tests, not lib tests.
Move the test to tests/integration_tests/shell_powershell.rs.

Co-Authored-By: Claude <noreply@anthropic.com>

* feat: require | Out-String in PowerShell detection

PowerShell configs without `| Out-String` are now treated as "not installed"
so that `wt config shell install` will update them with the fix.

Key changes:
- PowerShell detection now uses case-insensitive matching
- Check for Invoke-Expression/iex BEFORE POSIX patterns to avoid false match
  on `if ` which appears in old PowerShell configs
- Add test for exact old canonical PowerShell line

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-27 19:16:52 -08:00