Skip to content

Commit

Permalink
Run more tests on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
cknitt committed Oct 4, 2024
1 parent 1b516e9 commit 2e5760d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 27 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,12 @@ jobs:
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
run: node scripts/test.js -mocha -node -bsb -format

- name: Run gentype tests
run: make -C tests/gentype_tests/typescript-react-example clean test

- name: Build playground compiler
if: matrix.build_playground
Expand Down
2 changes: 1 addition & 1 deletion 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
9 changes: 6 additions & 3 deletions tests/build_tests/cli_compile_status/input.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// @ts-check

const assert = require("assert");
const path = require("path");
const child_process = require("child_process");

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(rescriptPath, ["build"], {
encoding: "utf8",
cwd: __dirname,
});
Expand All @@ -16,7 +19,7 @@ Dependency Finished
);

// Shows compile time for `rescript` command
out = child_process.spawnSync(`../../../rescript`, {
out = child_process.spawnSync(rescriptPath, {
encoding: "utf8",
cwd: __dirname,
});
Expand All @@ -31,7 +34,7 @@ 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(rescriptPath, ["build", "-verbose"], {
encoding: "utf8",
cwd: __dirname,
});
Expand Down
39 changes: 21 additions & 18 deletions tests/build_tests/cli_help/input.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// @ts-check

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

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

const cliHelp =
"Usage: rescript <options> <subcommand>\n" +
"\n" +
Expand Down Expand Up @@ -64,7 +67,7 @@ const dumpHelp =
async function test() {
{
// Shows build help with --help arg
const out = await exec(`../../../rescript`, ["build", "--help"], {
const out = await exec(rescriptPath, ["build", "--help"], {
cwd: __dirname,
});
assert.equal(out.stdout, buildHelp);
Expand All @@ -73,7 +76,7 @@ async function test() {
}

{
const out = await exec(`../../../rescript`, ["build", "-w", "--help"], {
const out = await exec(rescriptPath, ["build", "-w", "--help"], {
cwd: __dirname,
});
assert.equal(out.stdout, buildHelp);
Expand All @@ -82,7 +85,7 @@ async function test() {
}

{
const out = await exec(`../../../rescript`, ["-w", "--help"], {
const out = await exec(rescriptPath, ["-w", "--help"], {
cwd: __dirname,
});
assert.equal(out.stdout, cliHelp);
Expand All @@ -92,7 +95,7 @@ async function test() {

{
// Shows cli help with --help arg even if there are invalid arguments after it
const out = await exec(`../../../rescript`, ["--help", "-w"], {
const out = await exec(rescriptPath, ["--help", "-w"], {
cwd: __dirname,
});
assert.equal(out.stdout, cliHelp);
Expand All @@ -102,7 +105,7 @@ async function test() {

{
// Shows build help with -h arg
const out = await exec(`../../../rescript`, ["build", "-h"], {
const out = await exec(rescriptPath, ["build", "-h"], {
cwd: __dirname,
});
assert.equal(out.stdout, buildHelp);
Expand All @@ -112,7 +115,7 @@ async function test() {

{
// Exits with build help with unknown arg
const out = await exec(`../../../rescript`, ["build", "-foo"], {
const out = await exec(rescriptPath, ["build", "-foo"], {
cwd: __dirname,
});
assert.equal(out.stdout, "");
Expand All @@ -122,7 +125,7 @@ async function test() {

{
// Shows cli help with --help arg
const out = await exec(`../../../rescript`, ["--help"], {
const out = await exec(rescriptPath, ["--help"], {
cwd: __dirname,
});
assert.equal(out.stdout, cliHelp);
Expand All @@ -132,7 +135,7 @@ async function test() {

{
// Shows cli help with -h arg
const out = await exec(`../../../rescript`, ["-h"], {
const out = await exec(rescriptPath, ["-h"], {
cwd: __dirname,
});
assert.equal(out.stdout, cliHelp);
Expand All @@ -142,7 +145,7 @@ async function test() {

{
// Shows cli help with -h arg
const out = await exec(`../../../rescript`, ["help"], {
const out = await exec(rescriptPath, ["help"], {
cwd: __dirname,
});
assert.equal(out.stdout, cliHelp);
Expand All @@ -152,7 +155,7 @@ async function test() {

{
// Exits with cli help with unknown command
const out = await exec(`../../../rescript`, ["built"], {
const out = await exec(rescriptPath, ["built"], {
cwd: __dirname,
});
assert.equal(out.stdout, "");
Expand All @@ -162,7 +165,7 @@ async function test() {

{
// Exits with build help with unknown args
const out = await exec(`../../../rescript`, ["-foo"], {
const out = await exec(rescriptPath, ["-foo"], {
cwd: __dirname,
});
assert.equal(out.stdout, "");
Expand All @@ -172,7 +175,7 @@ async function test() {

{
// Shows clean help with --help arg
const out = await exec(`../../../rescript`, ["clean", "--help"], {
const out = await exec(rescriptPath, ["clean", "--help"], {
cwd: __dirname,
});
assert.equal(out.stdout, cleanHelp);
Expand All @@ -182,7 +185,7 @@ async function test() {

{
// Shows clean help with -h arg
const out = await exec(`../../../rescript`, ["clean", "-h"], {
const out = await exec(rescriptPath, ["clean", "-h"], {
cwd: __dirname,
});
assert.equal(out.stdout, cleanHelp);
Expand All @@ -192,7 +195,7 @@ async function test() {

{
// Exits with clean help with unknown arg
const out = await exec(`../../../rescript`, ["clean", "-foo"], {
const out = await exec(rescriptPath, ["clean", "-foo"], {
cwd: __dirname,
});
assert.equal(out.stdout, "");
Expand All @@ -202,7 +205,7 @@ async function test() {

{
// Shows format help with --help arg
const out = await exec(`../../../rescript`, ["format", "--help"], {
const out = await exec(rescriptPath, ["format", "--help"], {
cwd: __dirname,
});
assert.equal(out.stdout, formatHelp);
Expand All @@ -212,7 +215,7 @@ async function test() {

{
// Shows format help with -h arg
const out = await exec(`../../../rescript`, ["format", "-h"], {
const out = await exec(rescriptPath, ["format", "-h"], {
cwd: __dirname,
});
assert.equal(out.stdout, formatHelp);
Expand All @@ -222,7 +225,7 @@ async function test() {

{
// Shows dump help with --help arg
const out = await exec(`../../../rescript`, ["dump", "--help"], {
const out = await exec(rescriptPath, ["dump", "--help"], {
cwd: __dirname,
});
assert.equal(out.stdout, dumpHelp);
Expand All @@ -232,7 +235,7 @@ async function test() {

{
// Shows dump help with -h arg
const out = await exec(`../../../rescript`, ["dump", "-h"], {
const out = await exec(rescriptPath, ["dump", "-h"], {
cwd: __dirname,
});
assert.equal(out.stdout, dumpHelp);
Expand Down

0 comments on commit 2e5760d

Please sign in to comment.