Fix Windows test portability (fileURLToPath in 6 tests, .gitattributes LF) and add test.yml CI on Ubuntu + Windows
Specification
Motivation
On Windows, several tests build filesystem paths with new URL(...).pathname. That yields /C:/..., or C:\C:\... once resolved, instead of a native path. Separately, git's default core.autocrlf=true on Windows checks files out with CRLF line endings, which makes scripts/verify-ai-contract.mjs report 34 false failures. The proposer verified that with the fixes below, npm test passes on Windows 10 (117/117, plus 42/42 for SynthMCP).
There is currently no standalone test workflow. Tests run only inside pages.yml and release.yml after a push to main, on ubuntu-latest with Node 20.
Scope
- Path fixes. Replace
new URL(..., import.meta.url).pathname(and similar.pathname-as-filesystem-path uses) withfileURLToPath(...)imported fromnode:urlin:packages/synthmcp/test/drift.test.js: the expected path in the "by default the server reads the repository's synthcss.ai.json through the synthcss package" test, i.e.fileURLToPath(REPO_CONTRACT).scripts/check-base.test.mjsscripts/check-components.test.mjsscripts/check-layout.test.mjsscripts/check-showcase.test.mjsscripts/verify-ai-contract.test.mjs- Any other test file found by grep (see acceptance criteria) using a URL pathname as a filesystem path.
- Line endings. Add a root
.gitattributescontaining* text=auto eol=lf.- Assumption: if any binary assets exist (e.g. images or fonts), also add
binaryentries for their extensions so they are not normalised.
- Assumption: if any binary assets exist (e.g. images or fonts), also add
- CI. Add a new
.github/workflows/test.ymlthat:- runs on
pull_requestand onpushtomain; - uses a matrix with
os: [ubuntu-latest, windows-latest]; - sets up Node 20 via
actions/setup-node; - runs
npm ciand thennpm test. - Assumption:
npm testalready includes the SynthMCP tests. If it does not, also runnpm run test:mcp.
- runs on
Acceptance criteria
- All six named test files import
fileURLToPathfromnode:urland no longer derive filesystem paths from.pathname. grep -rn "\.pathname" scripts packages/*/test test --include=*.js --include=*.mjsshows no remaining use of a URL pathname as a filesystem path or compared with one..gitattributesexists at the repo root and contains* text=auto eol=lf..github/workflows/test.ymlexists, is valid YAML, has the triggers, OS matrix and Node 20 setup described above, and runsnpm ciandnpm test.pages.ymlandrelease.ymlare unchanged.npm testandnpm run test:mcppass in the sandbox (Linux).- No changes to SynthMCP runtime source (anything under
packages/synthmcp/outsidetest/) or to non-test scripts such asscripts/verify-ai-contract.mjs.
Out of scope
- Any change to SynthMCP's runtime path resolution.
- macOS runners and Node version matrices.
- Modifying the deploy workflows.
- Refactoring tests beyond the path fixes.
- Renormalising existing files' line endings beyond what
.gitattributesimplies.
Discussion · 0
No comments yet.