From 2e5760d4c991f806a3efce0bb01e08e39e1a7f0a Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Wed, 2 Oct 2024 19:53:51 +0200 Subject: [PATCH] Run more tests on Windows --- .github/workflows/ci.yml | 9 ++--- scripts/test.js | 2 +- tests/build_tests/cli_compile_status/input.js | 9 +++-- tests/build_tests/cli_help/input.js | 39 ++++++++++--------- 4 files changed, 32 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 913b1bf371..cd12f65000 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/scripts/test.js b/scripts/test.js index b16ff13c71..c875272de7 100644 --- a/scripts/test.js +++ b/scripts/test.js @@ -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; diff --git a/tests/build_tests/cli_compile_status/input.js b/tests/build_tests/cli_compile_status/input.js index 90f72542c3..2f69ccdda2 100755 --- a/tests/build_tests/cli_compile_status/input.js +++ b/tests/build_tests/cli_compile_status/input.js @@ -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, }); @@ -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, }); @@ -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, }); diff --git a/tests/build_tests/cli_help/input.js b/tests/build_tests/cli_help/input.js index 8fe5b9b9b4..d5dc87de94 100755 --- a/tests/build_tests/cli_help/input.js +++ b/tests/build_tests/cli_help/input.js @@ -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 \n" + "\n" + @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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, ""); @@ -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); @@ -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); @@ -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); @@ -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, ""); @@ -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, ""); @@ -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); @@ -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); @@ -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, ""); @@ -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); @@ -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); @@ -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); @@ -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);