Skip to content

Commit 113d6eb

Browse files
Windows \r sad
1 parent 720665d commit 113d6eb

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

.github/workflows/tests.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
name: Test
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
48

59
jobs:
610
unit:

scripts/check-for-changes.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
git update-index --refresh
1+
git update-index --refresh
2+
git diff-index --patch-with-raw HEAD --
23
git diff-index --quiet HEAD --

scripts/generateOverloadSnapshots.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ const configPath = join(ROOT, '../unit-test/script-overload-snapshots/config')
1111
* These are used in unit-test/script-overload.js and ran automatically in automation so that we verify the output is correct.
1212
*/
1313
function generateOut () {
14+
if (process.platform === 'win32') {
15+
console.log('skipping test generation on windows')
16+
return
17+
}
18+
1419
const files = readdirSync(configPath)
1520
for (const fileName of files) {
1621
const config = readFileSync(join(configPath, fileName)).toString()

unit-test/script-overload.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import { cwd } from '../scripts/script-utils.js'
66
const ROOT = join(cwd(import.meta.url))
77
const configPath = join(ROOT, '/script-overload-snapshots/config')
88

9+
function replaceWindowsLineEndings (text) {
10+
return text.replace(/\r/gm, '')
11+
}
12+
913
describe('Output validation', () => {
1014
it('Given the correct config we should generate expected code output', () => {
1115
// Uses the snapshots generated in scripts/generateOverloadSnapshots.js to ensure we don't break the output.
@@ -15,7 +19,7 @@ describe('Output validation', () => {
1519
const out = wrapScriptCodeOverload('console.log(1)', JSON.parse(config))
1620
const outName = fileName.replace(/.json$/, '.js')
1721
const expectedOut = readFileSync(join(ROOT, '/script-overload-snapshots/out/', outName)).toString()
18-
expect(out).withContext(`wrapScriptCodeOverload with ${fileName} matches ${outName}`).toEqual(expectedOut)
22+
expect(replaceWindowsLineEndings(out)).withContext(`wrapScriptCodeOverload with ${fileName} matches ${outName}`).toEqual(replaceWindowsLineEndings(expectedOut))
1923
}
2024
})
2125
})

0 commit comments

Comments
 (0)