From f6549befd7c7c4e2a43b61096b52e547a02f45bc Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Tue, 22 Oct 2024 15:49:57 +0700 Subject: [PATCH] chore(developer): ignore new line form when testing kmc-copy --- developer/src/kmc-copy/test/test-copier.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/developer/src/kmc-copy/test/test-copier.ts b/developer/src/kmc-copy/test/test-copier.ts index 60c6db7c96b..1c5648c18f7 100644 --- a/developer/src/kmc-copy/test/test-copier.ts +++ b/developer/src/kmc-copy/test/test-copier.ts @@ -16,6 +16,10 @@ import { makePathToFixture } from './helpers/index.js'; const { TEST_SAVE_ARTIFACTS } = env; let outputRoot: string = '/an/imaginary/root/'; +function normalizeNewLine(s: string): string { + return s.replaceAll(/\r\n/g, '\n'); +} + describe('KeymanProjectCopier', function() { const callbacks = new TestCompilerCallbacks(); @@ -135,14 +139,14 @@ describe('KeymanProjectCopier', function() { // vary depending on the file location const expected = fs.readFileSync(makePathToFixture('expected/khmer_angkor/khmer_angkor_2024.kmn'), 'utf-8'); actual = actual.replace(/store\(&DISPLAYMAP\) '.+KbdKhmr.json'/, "store(&DISPLAYMAP) '.../KbdKhmr.json'"); - assert.equal(actual, expected); + assert.equal(normalizeNewLine(actual), normalizeNewLine(expected)); }, 'source/khmer_angkor.kps': (actual: string) => { // We need to strip out ../../.../kmc-copy/... generated path because it will // vary depending on the file location const expected = fs.readFileSync(makePathToFixture('expected/khmer_angkor/khmer_angkor_2024.kps'), 'utf-8'); actual = actual.replace(/>.+kmc-copy\/test\/(.+)<\//g, '>.../$1test.fixtures)[fixture](actual); } else { const expected = fs.readFileSync(makePathToFixture((test.fixtures)[fixture]), 'utf-8'); - assert.equal(expected, actual); + assert.equal(normalizeNewLine(expected), normalizeNewLine(actual)); } } });