Skip to content

Commit 61b9cc9

Browse files
committed
Run more tests on Windows
1 parent f41b822 commit 61b9cc9

File tree

16 files changed

+169
-214
lines changed

16 files changed

+169
-214
lines changed

.github/workflows/ci.yml

-5
Original file line numberDiff line numberDiff line change
@@ -326,17 +326,12 @@ jobs:
326326
run: ./scripts/prebuilt.js
327327

328328
- name: Run tests
329-
if: runner.os != 'Windows'
330329
run: node scripts/test.js -all
331330

332331
- name: Run gentype tests
333332
if: runner.os != 'Windows'
334333
run: make -C tests/gentype_tests/typescript-react-example clean test
335334

336-
- name: Run tests (Windows)
337-
if: runner.os == 'Windows'
338-
run: node scripts/test.js -mocha -theme -format
339-
340335
- name: Build playground compiler
341336
if: matrix.build_playground
342337
run: |

scripts/test.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
const cp = require("child_process");
33
const path = require("path");
44
const fs = require("fs");
5-
var { rescript_exe } = require("#cli/bin_path");
5+
const { rescript_exe } = require("#cli/bin_path");
66

77
const duneBinDir = require("./dune").duneBinDir;
88

@@ -50,9 +50,13 @@ async function runTests() {
5050
}
5151

5252
if (ounitTest) {
53-
cp.execSync(path.join(duneBinDir, "ounit_tests"), {
54-
stdio: [0, 1, 2],
55-
});
53+
if (process.platform === "win32") {
54+
console.log("Skipping OUnit tests on Windows");
55+
} else {
56+
cp.execSync(path.join(duneBinDir, "ounit_tests"), {
57+
stdio: [0, 1, 2],
58+
});
59+
}
5660
}
5761

5862
if (mochaTest) {

tests/build_tests/case/input.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
var p = require("child_process");
22
var assert = require("assert");
33
var { rescript_exe } = require("#cli/bin_path");
4+
var { normalizeNewlines } = require("../utils.js");
5+
46
var o = p.spawnSync(rescript_exe, { encoding: "utf8", cwd: __dirname });
57

68
if (
79
![
810
`Error: Invalid bsconfig.json implementation and interface have different path names or different cases src/demo vs src/Demo\n`,
9-
// On linux files are parsed in different order
11+
// Windows: path separator
12+
`Error: Invalid bsconfig.json implementation and interface have different path names or different cases src\\demo vs src\\Demo\n`,
13+
// Linux: files are parsed in different order
1014
`Error: Invalid bsconfig.json implementation and interface have different path names or different cases src/Demo vs src/demo\n`,
11-
].includes(o.stderr)
15+
].includes(normalizeNewlines(o.stderr))
1216
) {
1317
assert.fail(o.stderr);
1418
}

tests/build_tests/case2/input.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
var p = require("child_process");
22
var assert = require("assert");
33
var { rescript_exe } = require("#cli/bin_path");
4+
var { normalizeNewlines } = require("../utils.js");
5+
46
var o = p.spawnSync(rescript_exe, { encoding: "utf8", cwd: __dirname });
57

68
if (
79
![
810
`Error: Invalid bsconfig.json implementation and interface have different path names or different cases src/X vs src/x\n`,
9-
// On linux files are parsed in different order
11+
// Windows: path separator
12+
`Error: Invalid bsconfig.json implementation and interface have different path names or different cases src\\X vs src\\x\n`,
13+
// Linux: files are parsed in different order
1014
`Error: Invalid bsconfig.json implementation and interface have different path names or different cases src/x vs src/X\n`,
11-
].includes(o.stderr)
15+
].includes(normalizeNewlines(o.stderr))
1216
) {
1317
assert.fail(o.stderr);
1418
}
+12-11
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
11
// @ts-check
22

33
const assert = require("assert");
4+
const path = require("path");
45
const child_process = require("child_process");
6+
const { normalizeNewlines } = require("../utils.js");
7+
8+
const rescriptPath = path.join(__dirname, "..", "..", "..", "rescript")
59

610
// Shows compile time for `rescript build` command
7-
let out = child_process.spawnSync(`../../../rescript`, ["build"], {
11+
let out = child_process.spawnSync("node", [rescriptPath, "build"], {
812
encoding: "utf8",
913
cwd: __dirname,
1014
});
1115
assert.match(
12-
out.stdout,
16+
normalizeNewlines(out.stdout),
1317
new RegExp(`>>>> Start compiling
1418
Dependency Finished
1519
>>>> Finish compiling \\d+ mseconds`),
1620
);
1721

1822
// Shows compile time for `rescript` command
19-
out = child_process.spawnSync(`../../../rescript`, {
23+
out = child_process.spawnSync("node", [rescriptPath], {
2024
encoding: "utf8",
2125
cwd: __dirname,
2226
});
2327
assert.match(
24-
out.stdout,
28+
normalizeNewlines(out.stdout),
2529
new RegExp(`>>>> Start compiling
2630
Dependency Finished
2731
>>>> Finish compiling \\d+ mseconds`),
@@ -31,13 +35,10 @@ Dependency Finished
3135
// Because we can't be sure that -verbose is a valid argument
3236
// And bsb won't fail with a usage message.
3337
// It works this way not only for -verbose, but any other arg, including -h/--help/-help
34-
out = child_process.spawnSync(`../../../rescript`, ["build", "-verbose"], {
38+
out = child_process.spawnSync("node", [rescriptPath, "build", "-verbose"], {
3539
encoding: "utf8",
3640
cwd: __dirname,
3741
});
38-
assert.match(
39-
out.stdout,
40-
new RegExp(
41-
`Package stack: test \nDependency Finished\nninja.exe -C lib/bs \n`,
42-
),
43-
);
42+
43+
assert.match(normalizeNewlines(out.stdout), /Package stack: test \nDependency Finished\n/);
44+
assert.match(normalizeNewlines(out.stdout), /ninja.exe"? -C lib[\\/]bs ?\n/);

0 commit comments

Comments
 (0)