Skip to content

fix(windows): cmd.exe verbatim filter commands and Windows-native fixtures - #348

Open
vosbek wants to merge 2 commits into
atomicdotdev:devfrom
vosbek:fix/windows-native-suite
Open

vosbek wants to merge 2 commits into
atomicdotdev:devfrom
vosbek:fix/windows-native-suite

Conversation

@vosbek

@vosbek vosbek commented Nov 24, 2026

Copy link
Copy Markdown

fix(windows): native test suite — cmd.exe verbatim filter commands + portable fixtures

Three failures on the native Windows CI path, all fixed and verified on
Windows (x86_64-pc-windows-msvc, NTFS) and Linux (Ubuntu, ext4):

1. Filter driver commands never reached cmd.exe intact (production fix)

run_bounded_command spawned Command::new("cmd").args(["/C", &command]).
Rust's standard Windows argument escaping writes \" for every quote in
the command string — and cmd.exe does not understand backslash-escaped
quotes. Consequence: any filter driver whose command quotes an argument
(a path with spaces, or any %f substitution that needs them) failed with
"The filename, directory name, or volume label syntax is incorrect" before
the driver ever ran.

Fix: pass the substituted command with raw_arg so cmd /C receives it
verbatim, the way a shell command line is meant to reach cmd.exe. The Unix
sh -c arm and the %f metacharacter refusal policy are unchanged. The
conflict-surface tests now cover this end to end with a quoted absolute
path.

2. git_import_preflight_repairs_a_database_left_by_a_killed_process

The fixture copied the repository while the database was open — possible on
Unix (a second handle reads a live redb file), impossible on Windows:
redb holds a byte-range lock over the open database, so fs::copy fails
with a sharing violation (OS error 33).

Fix: the fixture now opens the database in a child process and kills the
child (child.kill() = SIGKILL / TerminateProcess), producing the same
unclosed, must-repair state on every platform — and finally matching the
test's own name. Reuses the spawn-marker-kill pattern already proven by
changes::staged_projected_change_survives_process_kill_without_partial_publication.

3. Conflict-surface fixtures ran clean = "cat"

cat does not exist on Windows, so the required filter failed for the
wrong reason and both conflict tests errored out early.

Fix: the byte-exact pass-through is platform-aware — Unix keeps cat on
stdin; Windows points type at the working file's absolute path (there is
no stdin pass-through on Windows that preserves bytes: find /V "" rewrites
LF to CRLF, verified). The path is embedded as a TOML literal string and
depends on (1) for the quoted path to reach cmd.exe.

Verification

  • Windows: all three tests pass; full atomic-repository suite green.
  • Linux: killed-process fixture passes (it replaced a passing fixture —
    re-verified), all 18 conflict-surface tests pass, switch regression
    tests pass.
  • cargo fmt --check clean; clippy shows no new warnings (three
    pre-existing #[cfg(windows)] sites remain, never linted by the
    ubuntu-only clippy job).

Rust's standard Windows argument escaping writes `\"` for every quote
in a command string, which cmd.exe does not understand: a filter driver
whose command quotes an argument -- a path with spaces, or any `%f`
substitution that needs them -- failed with "The filename, directory
name, or volume label syntax is incorrect" before the driver ever ran.

Pass the substituted command to `cmd /C` with `raw_arg` so it arrives
verbatim, the way a shell command line is meant to reach cmd.exe. The
Unix `sh -c` arm and the `%f` metacharacter refusal policy are
unchanged. The Windows conflict-surface tests now exercise this end to
end with a quoted absolute path.
Three fixtures assumed Unix and failed on the Windows CI path:

- `git_import_preflight_repairs_a_database_left_by_a_killed_process`
  copied the repository while the database was open. Windows cannot
  reproduce that copy -- redb holds a byte-range lock over the open
  database, so every second-handle read fails with a sharing violation
  (OS error 33) -- so the fixture now opens the database in a child
  process and kills the child, which produces the same unclosed state
  on every platform and finally matches the test's own name.

- The conflict-surface fixtures ran `clean = "cat"`, and `cat` does not
  exist on Windows. The byte-exact pass-through is now platform-aware:
  Unix keeps `cat` on stdin; Windows points `type` at the working
  file's absolute path (there is no stdin pass-through on Windows that
  preserves bytes -- `find` rewrites line endings), embedded as a TOML
  literal string. This needs the verbatim `cmd /C` command pass-through
  from the previous commit, and covers it end to end.
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