test(fuzz): CRLF and CR files mean the same as LF (line-endings invariant) #308
No reviewers
Labels
No labels
bug
discussion
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
research
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gram-lang/gram!308
Loading…
Reference in a new issue
No description provided.
Delete branch "test/line-endings"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Lot 2 of
.notes/v1.6/plan-finitions-techniques-1.6.md.Fuzz invariant
line-endings(fuzz/src/invariants.ts): every corpus/mutated input is compared with its CRLF and CR versions: same parse outcome, same compilation (theformat-preserves-meaningcomparison, no new rule innormalize.ts), sameformatGramoutput, same lint codes at spans that correspond throughmapSpan(), and preferred fixes that give the same text with the file's own line endings. One comparison rule, commented: an offset between the\rand\nof a line break counts as after it (a parse error on a line break covers its first character).Bugs it found, fixed in
@gram-lang/modules/lint(only ondev/1.6, so no changeset):\r(CR) was never treated as a line break by the rules (indexOf("\n")everywhere):MERGED_STEP_LINE,DEPRECATED_FRONTMATTER_KEY… were missed or misplaced.lintDocumentnow hands the rules the text with lone\rturned into\n(same length, so offsets don't move).\n: a fix that inserts a line (MISSING_TITLE,MERGED_STEP_LINE) mixed line endings in a CRLF/CR file. They now write the line ending of the line break just before them (so a file that mixes them doesn't get\r+\njoined into one break).gram-tokens.tsonly matched---\n…\n---: in CRLF,@inside an unreadable frontmatter became a lost ingredient.buildLineIndex()now counts lines after\r\n,\nand a lone\r, like the LSP.Tests:
packages/modules/tests/lint/line-endings.test.ts: CRLF and CR forDEPRECATED_FRONTMATTER_KEY(rename and whole-line removal, no orphan\r),SPACED_COMPOSITE,INVALID_DURATION,MERGED_STEP_LINE, the insertedMISSING_TITLEline, the two fuzz regressions,buildLineIndex. Sources built in code, no CRLF file committed.Checks: modules/cli/language-server/parser/format/fuzz tests green, typecheck, lint, conformance. Two 50k fuzz sessions: everything found was fixed here, except two pre-existing
fix-idempotentviolations ondev/1.6, unrelated to line endings (not hit by the seeded test):@flour ^&flour: theREFERENCE_TO_INGREDIENTfix writes^@&flourand the diagnostic comes back.".\n##\n[e]": theMERGED_STEP_LINEfix breaks the parse.