fix: handle CRLF line endings in DSN parser and cross-platform test paths - #531
Open
chris200450828 wants to merge 1 commit into
Open
chris200450828 wants to merge 1 commit into
chris200450828 wants to merge 1 commit into
Conversation
…aths Two small cross-platform robustness fixes: 1. parseDsnToDsnJson now normalizes CRLF/CR line endings to LF before tokenizing. Real-world DSN files exported by KiCad on Windows use CRLF, and without normalization a parse -> stringify -> parse round-trip is not idempotent (stringify emits LF), which breaks the round-trip invariant. This fixes tests/dsn-pcb/stringify-dsn-json.test.ts on such inputs. 2. getTestDebugUtils split the test path on "/" only, so on Windows the backslash-separated absolute path was never split and it attempted to mkdir a directory literally named after the full "D:\..." path. Splitting on both separators fixes the test debug-file helper on Windows. Test suite goes from 3 failing to 1 on Windows; no regressions elsewhere.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two small cross-platform robustness fixes.
1. Normalize CRLF/CR line endings in
parseDsnToDsnJsonReal-world DSN files exported by KiCad on Windows use CRLF line endings. Without normalization, a
parse -> stringify -> parseround-trip is not idempotent (becausestringifyDsnJsonemits LF), so the reparsedparserblock differs from the original only by\r. This makes the parser robust to CRLF input and fixestests/dsn-pcb/stringify-dsn-json.test.tson such files.2. Split the test path on both
/and\ingetTestDebugUtilstestPath.split("/")never splits a Windows backslash path, so on Windows.pop()returned the entire absolute path and the helper tried tomkdira directory literally namedD:\...\<test>, throwingENOENT. Splitting on/[/\]/fixes the debug-file helper on Windows.Result
On Windows the suite goes from 3 failing tests to 1 (
merge-dsn-session-with-conversionandstringify dsn jsonnow pass). No changes to behavior on LF input, so no regressions on Linux/macOS CI. Diff is 6 lines.The remaining failure (
basic-via-pcb-layer-change) is an unrelatedlooks-sameimage-buffer issue and is intentionally left out of scope to keep this focused.