Skip to content

test: enforce LF line endings so fixture digests stay byte-exact - #101

Open
BlueX888 wants to merge 1 commit into
rsi-gear:devfrom
BlueX888:test/enforce-lf-line-endings
Open

BlueX888 wants to merge 1 commit into
rsi-gear:devfrom
BlueX888:test/enforce-lf-line-endings

Conversation

@BlueX888

Copy link
Copy Markdown

Problem

The test suite hard-depends on LF bytes, but the repo has no .gitattributes, so a default Windows checkout (core.autocrlf=true) rewrites the working tree to CRLF and breaks four assertions out of the box:

  • tests/composition/target-skill-loader.spec.ts — tests/helpers/documented-skill-candidate.ts parses skills/refine/references/dsh-target-harness.md with \n-anchored regexes, so it fails with missing documented hook: ### `pre_action`: and returns no candidates;
  • tests/unit/dsh-codex-luna-example.spec.ts — the two fixture digest assertions compare byte-exact artifacts and see 3155 bytes / a different sha256 instead of the expected 3109.

The index is already all-LF (git ls-files --eol), so Linux and macOS contributors never see this — the suite's byte-exactness currently depends on each contributor's local git config rather than on the repo.

Change

Add a four-line .gitattributes enforcing * text=auto eol=lf, with a comment explaining why. text=auto leaves the fourteen tracked binary assets in docs/ (png/gif/zip/mp4) untouched — they are auto-detected as binary and stay byte-identical. Targeted rules (skills/examples/docs/tests only) would leave src/ and scripts/ CRLF on Windows and let the same class of failure recur, so the blanket rule is used.

Validation

Run on Windows 11 with a default autocrlf=true checkout:

  • Plain dev (red): the composition target-skill-loader spec and the two digest assertions fail as described above.
  • With .gitattributes and the working tree re-materialized (green): the same four assertions pass.
  • git add --renormalize . on the full repo adds nothing but .gitattributes itself; git ls-files --eol shows 851 i/lf, 14 binary, 2 n/a — the index is unchanged, so Linux/macOS CI sees zero difference.
  • npm run typecheck: pass.

Existing Windows checkouts need a one-time working-tree refresh to benefit (re-clone, or git rm --cached -r . && git reset --hard); until then git status may show phantom modifications from stale stat data.

A default Git-for-Windows checkout (core.autocrlf=true) materializes
every text file with CRLF, which breaks the tests that treat fixtures
as bytes: tests/helpers/documented-skill-candidate.ts can no longer
match the LF-anchored code fences of the documented harness, and the
Luna example digest tests compare CRLF bytes against the committed LF
digests. text=auto leaves the binary documentation assets untouched,
and the index is already all-LF, so renormalizing reports no changes
on POSIX.
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