Skip to content

test: make path assertions platform-agnostic so the suite passes on Windows - #1450

Open
KallinikosMil wants to merge 1 commit into
callstack:mainfrom
KallinikosMil:fix/tests-platform-agnostic-paths
Open

test: make path assertions platform-agnostic so the suite passes on Windows#1450
KallinikosMil wants to merge 1 commit into
callstack:mainfrom
KallinikosMil:fix/tests-platform-agnostic-paths

Conversation

@KallinikosMil

@KallinikosMil KallinikosMil commented Aug 28, 2026

Copy link
Copy Markdown

Summary

Five tests across two suites fail on Windows because they compare platform-native paths against hard-coded POSIX literals, so pnpm test is red even though the code under test is correct:

● HermesBytecodePlugin › getHermesCLIPath › returns new hermes-compiler path when it exists

  Expected: "path/to/hermes-compiler/hermesc/osx-bin/hermesc"
  Received: "path\to\hermes-compiler\hermesc\osx-bin\hermesc"

getHermesCLIPath and resolveProjectPath build those paths with path.join / path.resolve, which is exactly what they should do — the separators are right for the platform. It's the expectations that are POSIX-only.

The fix runs the expectations through path.join / path.resolve rather than comparing raw strings. Both are no-ops on POSIX, so Linux and macOS runs are byte-for-byte unchanged; the literals stay readable as POSIX in the source.

One case needed a bit more

In resolveProjectPath.test.ts the root is resolved as well, not just the expectation. With a POSIX root and no drive letter, up-level navigation that reaches the root collapses to a bare \, and Windows then reads \ + /shared/... as the start of a UNC share:

● should resolve [projectRoot^N] prefix with up-level navigation

  Expected: "C:\shared\utils.js"
  Received: "\\shared\utils.js\\"     ← \shared\utils.js\ , a network path

Resolving the root first gives it a drive letter, so path.join keeps the drive when it walks up and the result stays local. To be clear about scope: I don't think this is reachable in production, because rootDir there comes from a real project directory and always carries a drive on Windows. It's a property of feeding the function a POSIX absolute path on Windows, so I've fixed it in the test and left resolveProjectPath alone. Flagging it because the failure mode is a surprising one and worth knowing about.

Test plan

Windows 11, Node 22.23.2, pnpm 10.34.5.

Before@callstack/repack:

Test Suites: 2 failed, 31 passed, 33 total
Tests:       5 failed, 294 passed, 299 total

After:

Test Suites: 33 passed, 33 total
Tests:       299 passed, 299 total

pnpm lint (biome) is clean. metro-compat-test (47 passed), resolver-cases-test (3 files) and repack-dev-server (5 tests) all pass on Windows both before and after.

Not addressed here: tests/integration fails on Windows with Module build failed — 4 files, 50 tests, 24 snapshots. I verified this is pre-existing and unrelated by stashing my changes and re-running on a clean tree, which produced the identical 50 failed | 8 passed. It looks like a separate Windows issue and I didn't want to bundle a fix for it into this PR. Happy to look into it separately if that'd be useful.

I noticed test-main-matrix.yml already has an os matrix axis, currently [ubuntu-latest]. If you'd like these kept honest, adding windows-latest there would do it — glad to open that as its own PR rather than assume you want the extra CI minutes.

…indows

Five assertions in two suites compared platform-native paths against
hard-coded POSIX literals, so they failed on Windows even though the code
under test is correct -- it builds those paths with `path.join` /
`path.resolve`, which use backslashes there.

  Expected: "path/to/react-native/scripts/compose-source-maps.js"
  Received: "path\to\react-native\scripts\compose-source-maps.js"

Run the expectations through `path.join` / `path.resolve` instead of
comparing raw strings. Both are no-ops on POSIX, so Linux and macOS runs are
unchanged.

In resolveProjectPath.test.ts the root is resolved as well. Without a drive
letter, up-level navigation that reaches the root collapses to a bare
backslash, which Windows then reads as the beginning of a UNC share -- the
test produced \\shared\utils.js rather than a local path.
@vercel

vercel Bot commented Aug 28, 2026

Copy link
Copy Markdown

@KallinikosMil is attempting to deploy a commit to the Callstack Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented Aug 28, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: c89dc78

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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