Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run build_tests on Windows #7065

Merged
merged 2 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -326,17 +326,12 @@ jobs:
run: ./scripts/prebuilt.js

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

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

- name: Run tests (Windows)
if: runner.os == 'Windows'
run: node scripts/test.js -mocha -theme -format

- name: Build playground compiler
if: matrix.build_playground
run: |
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
- Remove uncurried flag from bsb. https://github.com/rescript-lang/rescript-compiler/pull/7049
- Build runtime/stdlib files with rescript/bsb instead of ninja.js. https://github.com/rescript-lang/rescript-compiler/pull/7063
- Build tests with bsb and move them out of jscomp. https://github.com/rescript-lang/rescript-compiler/pull/7068
- Run `build_tests` on Windows. https://github.com/rescript-lang/rescript-compiler/pull/7065

# 12.0.0-alpha.3

Expand Down
12 changes: 8 additions & 4 deletions scripts/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const cp = require("child_process");
const path = require("path");
const fs = require("fs");
var { rescript_exe } = require("#cli/bin_path");
const { rescript_exe } = require("#cli/bin_path");

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

Expand Down Expand Up @@ -50,9 +50,13 @@ async function runTests() {
}

if (ounitTest) {
cp.execSync(path.join(duneBinDir, "ounit_tests"), {
stdio: [0, 1, 2],
});
if (process.platform === "win32") {
console.log("Skipping OUnit tests on Windows");
} else {
cp.execSync(path.join(duneBinDir, "ounit_tests"), {
stdio: [0, 1, 2],
});
}
}

if (mochaTest) {
Expand Down
8 changes: 6 additions & 2 deletions tests/build_tests/case/input.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
var p = require("child_process");
var assert = require("assert");
var { rescript_exe } = require("#cli/bin_path");
var { normalizeNewlines } = require("../utils.js");

var o = p.spawnSync(rescript_exe, { encoding: "utf8", cwd: __dirname });

if (
![
`Error: Invalid bsconfig.json implementation and interface have different path names or different cases src/demo vs src/Demo\n`,
// On linux files are parsed in different order
// Windows: path separator
`Error: Invalid bsconfig.json implementation and interface have different path names or different cases src\\demo vs src\\Demo\n`,
// Linux: files are parsed in different order
`Error: Invalid bsconfig.json implementation and interface have different path names or different cases src/Demo vs src/demo\n`,
].includes(o.stderr)
].includes(normalizeNewlines(o.stderr))
) {
assert.fail(o.stderr);
}
8 changes: 6 additions & 2 deletions tests/build_tests/case2/input.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
var p = require("child_process");
var assert = require("assert");
var { rescript_exe } = require("#cli/bin_path");
var { normalizeNewlines } = require("../utils.js");

var o = p.spawnSync(rescript_exe, { encoding: "utf8", cwd: __dirname });

if (
![
`Error: Invalid bsconfig.json implementation and interface have different path names or different cases src/X vs src/x\n`,
// On linux files are parsed in different order
// Windows: path separator
`Error: Invalid bsconfig.json implementation and interface have different path names or different cases src\\X vs src\\x\n`,
// Linux: files are parsed in different order
`Error: Invalid bsconfig.json implementation and interface have different path names or different cases src/x vs src/X\n`,
].includes(o.stderr)
].includes(normalizeNewlines(o.stderr))
) {
assert.fail(o.stderr);
}
23 changes: 12 additions & 11 deletions tests/build_tests/cli_compile_status/input.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
// @ts-check

const assert = require("assert");
const path = require("path");
const child_process = require("child_process");
const { normalizeNewlines } = require("../utils.js");

const rescriptPath = path.join(__dirname, "..", "..", "..", "rescript")

// Shows compile time for `rescript build` command
let out = child_process.spawnSync(`../../../rescript`, ["build"], {
let out = child_process.spawnSync("node", [rescriptPath, "build"], {
encoding: "utf8",
cwd: __dirname,
});
assert.match(
out.stdout,
normalizeNewlines(out.stdout),
new RegExp(`>>>> Start compiling
Dependency Finished
>>>> Finish compiling \\d+ mseconds`),
);

// Shows compile time for `rescript` command
out = child_process.spawnSync(`../../../rescript`, {
out = child_process.spawnSync("node", [rescriptPath], {
encoding: "utf8",
cwd: __dirname,
});
assert.match(
out.stdout,
normalizeNewlines(out.stdout),
new RegExp(`>>>> Start compiling
Dependency Finished
>>>> Finish compiling \\d+ mseconds`),
Expand All @@ -31,13 +35,10 @@ Dependency Finished
// Because we can't be sure that -verbose is a valid argument
// And bsb won't fail with a usage message.
// It works this way not only for -verbose, but any other arg, including -h/--help/-help
out = child_process.spawnSync(`../../../rescript`, ["build", "-verbose"], {
out = child_process.spawnSync("node", [rescriptPath, "build", "-verbose"], {
encoding: "utf8",
cwd: __dirname,
});
assert.match(
out.stdout,
new RegExp(
`Package stack: test \nDependency Finished\nninja.exe -C lib/bs \n`,
),
);

assert.match(normalizeNewlines(out.stdout), /Package stack: test \nDependency Finished\n/);
assert.match(normalizeNewlines(out.stdout), /ninja.exe"? -C lib[\\/]bs ?\n/);
Loading