Skip to content

Commit 2d645c7

Browse files
authored
Make CI tests actually fail if there is an error in build_tests; fix broken tests (#6804)
1 parent 73e3d2c commit 2d645c7

File tree

3 files changed

+27
-23
lines changed

3 files changed

+27
-23
lines changed

jscomp/build_tests/cli_help/input.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ async function test() {
214214

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

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

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

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

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

265265
{
266266
// Shows dump help with -h arg
267-
const out = await exec(`../../../rescript dump`, ["-h"], {
267+
const out = await exec(`../../../rescript`, ["dump", "-h"], {
268268
cwd: __dirname,
269269
});
270270
assert.equal(out.stdout, dumpHelp);

jscomp/build_tests/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ async function exec(command, args, options) {
4444
code = signals[signal] + 128;
4545
}
4646

47-
resolve({ code, stdout, stderr });
47+
resolve({ status: code, stdout, stderr });
4848
});
4949
});
5050
}

scripts/ciTest.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
//@ts-check
2-
var cp = require("child_process");
3-
var path = require("path");
4-
var fs = require("fs");
2+
const cp = require("child_process");
3+
const path = require("path");
4+
const fs = require("fs");
55

6-
var duneBinDir = require("./dune").duneBinDir;
6+
const duneBinDir = require("./dune").duneBinDir;
77

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

10-
var ounitTest = false;
11-
var mochaTest = false;
12-
var bsbTest = false;
13-
var formatTest = false;
14-
var all = false;
10+
let ounitTest = false;
11+
let mochaTest = false;
12+
let bsbTest = false;
13+
let formatTest = false;
1514

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

3231
if (process.argv.includes("-all")) {
33-
all = true;
34-
}
35-
if (all) {
3632
ounitTest = true;
3733
mochaTest = true;
3834
bsbTest = true;
@@ -56,10 +52,13 @@ async function runTests() {
5652

5753
if (bsbTest) {
5854
console.log("Doing build_tests");
59-
var buildTestDir = path.join(__dirname, "..", "jscomp", "build_tests");
60-
var files = fs.readdirSync(buildTestDir);
55+
const buildTestDir = path.join(__dirname, "..", "jscomp", "build_tests");
56+
const files = fs.readdirSync(buildTestDir);
57+
58+
let hasError = false;
59+
6160
for (const file of files) {
62-
var testDir = path.join(buildTestDir, file);
61+
const testDir = path.join(buildTestDir, file);
6362
if (file === "node_modules" || !fs.lstatSync(testDir).isDirectory()) {
6463
break;
6564
}
@@ -72,13 +71,18 @@ async function runTests() {
7271
const out = await exec(`node`, ["input.js"], { cwd: testDir });
7372
console.log(out.stdout);
7473

75-
if (out.code === 0) {
74+
if (out.status === 0) {
7675
console.log("✅ success in", file);
7776
} else {
7877
console.log(`❌ error in ${file} with stderr:\n`, out.stderr);
78+
hasError = true;
7979
}
8080
}
8181
}
82+
83+
if (hasError) {
84+
process.exit(1);
85+
}
8286
}
8387

8488
if (formatTest) {

0 commit comments

Comments
 (0)