Skip to content

fix(tests): make cache-removal and tarball tests pass on Windows (#36) - #38

Merged
diegohb merged 3 commits into
mainfrom
issue-36-failing-tests
Oct 7, 2026
Merged

diegohb merged 3 commits into
mainfrom
issue-36-failing-tests

Conversation

@diegohb

@diegohb diegohb commented Oct 7, 2026

Copy link
Copy Markdown
Member

Summary

  • CacheCleaner and Installer now accept an optional rm function (defaulting to fs/promises rm), so tests inject removal failures at a code seam instead of relying on chmod 0o500.
  • The CLI test keeps chmod 0o500 on POSIX; on Windows it parks a short-lived helper process whose cwd is inside the blocked tree, so removal fails with EBUSY and the warn-but-exit-0 path is exercised cross-platform.
  • Tarball tests derive ROOT via fileURLToPath and join paths with path.join instead of string concatenation, which previously produced /C:/... paths on Windows.
  • npm pack --dry-run --json output is now accepted as either a legacy array or the name-keyed object emitted by newer npm.

Why

Several tests were failing on Windows: the read-only attribute set by chmod 0o500 does not block recursive removal there, so the failure injection silently succeeded and the warn-and-continue path was never exercised. Additionally, new URL().pathname string concatenation yields invalid root paths on win32, and npm pack --json output shape varies across npm versions.

Testing

  • CacheCleaner and Installer unit tests inject a failing rm for one target while delegating the rest; behavior is identical on win32 and POSIX.
  • CLI test covers the warn-but-exit-0 path on both platforms: chmod 0o500 on POSIX, cwd-holding helper process on Windows.
  • Tarball tests resolve paths correctly on Windows and tolerate both npm pack --json output shapes.

…on parsing

- Derive ROOT via fileURLToPath and join paths with path.join instead of
  string concatenation (new URL().pathname yields /C:/... on Windows).
- Accept npm pack --dry-run --json output as either a legacy array or the
  name-keyed object emitted by newer npm.
CacheCleaner and Installer now accept an optional rm function (defaulting
to fs/promises rm). On Windows the read-only attribute does not block
recursive removal, so chmod-based failure injection silently succeeded
and never exercised the warn-and-continue path. Both unit tests now
inject a failing rm for one target while delegating the rest — works
identically on win32 and POSIX.
The CLI test spawns a subprocess, so failure cannot be injected at a code
seam. Keep chmod 0o500 on POSIX; on Windows park a short-lived helper
process whose cwd is inside the blocked tree — Windows refuses to delete
a directory that is a process's working directory, so the removal fails
with EBUSY and the warn-but-exit-0 path is exercised cross-platform.
@diegohb
diegohb merged commit 5b33359 into main Oct 7, 2026
2 checks passed
@diegohb diegohb changed the title fix(tests): make cache-removal and tarball tests pass on Windows fix(tests): make cache-removal and tarball tests pass on Windows (#36) Oct 7, 2026
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