Skip to content

Make CI tests actually fail if there is an error in build_tests; fix broken tests #6804

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

Merged
merged 3 commits into from
Jun 1, 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
12 changes: 6 additions & 6 deletions jscomp/build_tests/cli_help/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ async function test() {

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

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

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

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

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

{
// Shows dump help with -h arg
const out = await exec(`../../../rescript dump`, ["-h"], {
const out = await exec(`../../../rescript`, ["dump", "-h"], {
cwd: __dirname,
});
assert.equal(out.stdout, dumpHelp);
Expand Down
2 changes: 1 addition & 1 deletion jscomp/build_tests/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async function exec(command, args, options) {
code = signals[signal] + 128;
}

resolve({ code, stdout, stderr });
resolve({ status: code, stdout, stderr });
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cli_help tests use status, not code (matching the spawnSync API).

});
});
}
Expand Down
36 changes: 20 additions & 16 deletions scripts/ciTest.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
//@ts-check
var cp = require("child_process");
var path = require("path");
var fs = require("fs");
const cp = require("child_process");
const path = require("path");
const fs = require("fs");

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

const { exec } = require("../jscomp/build_tests/utils.js");

var ounitTest = false;
var mochaTest = false;
var bsbTest = false;
var formatTest = false;
var all = false;
let ounitTest = false;
let mochaTest = false;
let bsbTest = false;
let formatTest = false;

if (process.argv.includes("-ounit")) {
ounitTest = true;
Expand All @@ -30,9 +29,6 @@ if (process.argv.includes("-format")) {
}

if (process.argv.includes("-all")) {
all = true;
}
if (all) {
ounitTest = true;
mochaTest = true;
bsbTest = true;
Expand All @@ -56,10 +52,13 @@ async function runTests() {

if (bsbTest) {
console.log("Doing build_tests");
var buildTestDir = path.join(__dirname, "..", "jscomp", "build_tests");
var files = fs.readdirSync(buildTestDir);
const buildTestDir = path.join(__dirname, "..", "jscomp", "build_tests");
const files = fs.readdirSync(buildTestDir);

let hasError = false;

for (const file of files) {
var testDir = path.join(buildTestDir, file);
const testDir = path.join(buildTestDir, file);
if (file === "node_modules" || !fs.lstatSync(testDir).isDirectory()) {
break;
}
Expand All @@ -72,13 +71,18 @@ async function runTests() {
const out = await exec(`node`, ["input.js"], { cwd: testDir });
console.log(out.stdout);

if (out.code === 0) {
if (out.status === 0) {
console.log("✅ success in", file);
} else {
console.log(`❌ error in ${file} with stderr:\n`, out.stderr);
hasError = true;
}
}
}

if (hasError) {
process.exit(1);
}
}

if (formatTest) {
Expand Down
Loading