Skip to content

fix(tests): tolerate CRLF working-tree line endings in freshness and style gates - #516

Draft
tahayusab wants to merge 1 commit into
CoreBunch:mainfrom
tahayusab:fix/tests-crlf-robustness
Draft

fix(tests): tolerate CRLF working-tree line endings in freshness and style gates#516
tahayusab wants to merge 1 commit into
CoreBunch:mainfrom
tahayusab:fix/tests-crlf-robustness

Conversation

@tahayusab

Copy link
Copy Markdown

On Windows checkouts (autocrlf), three gates compare raw bytes against
line-ending-sensitive patterns and fail spuriously:

$ bun test src/__tests__/architecture/plugin-bootstrap-fresh.test.ts
(fail) generated plugin bootstrap artifacts > match a fresh bundle of
      bootstrap/src/ (run `bun run bootstrap:sync` if this fails)

Root causes:

  • scripts/sync-plugin-bootstrap.ts bundles from on-disk sources; on a CRLF
    working tree the CRLFs are carried into the bundle and JSON-escaped, so the
    in-memory artifact diverges from the committed (LF) artifact even with no
    source drift.
  • plugin-bootstrap-fresh.test.ts compares the committed artifact
    byte-for-byte; a CRLF-checked-out file never equals the LF string.
  • siteExplorerPanel.test.tsx matches a multi-line CSS selector block with a
    regex that hardcodes \n line breaks.

Changes:

  • Normalize the bundled text to LF in bundleEntry so emitted artifacts stay
    platform-independent (no-op on LF checkouts; committed artifacts unchanged).
  • EOL-normalize the file read in the freshness gate.
  • Make the CSS block regex use \r?\n.

Verified on a Windows / autocrlf checkout: plugin-bootstrap-fresh 1 pass,
siteExplorerPanel 40/40 pass (was 39 + 1 fail), no prior bootstrap:sync,
git status clean on generated/. bun run build + bun run lint green.

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