Skip to content

Commit ca389a1

Browse files
citest: add callback (rescript-lang#5477)
* citest: add callback * clean up * tests: use rescript_exe in custom_namespace test * tests: remove stdio override from all tests that used it Co-authored-by: Cristiano Calcagno <cristianoc@users.noreply.github.com>
1 parent 9af349c commit ca389a1

File tree

15 files changed

+23
-31
lines changed

15 files changed

+23
-31
lines changed

jscomp/build_tests/case3/input.js

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
88
p.spawnSync(rescript_exe, {
99
encoding: "utf8",
1010
cwd: __dirname,
11-
stdio: [0, 1, 2],
1211
});
1312

1413
var o = fs.readFileSync(path.join(__dirname, "src", "hello.bs.js"), "ascii");

jscomp/build_tests/custom_namespace/input.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ var child_process = require("child_process");
22
var fs = require("fs");
33
var path = require("path");
44
var assert = require("assert");
5+
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
56

6-
child_process.execSync(`../node_modules/.bin/rescript clean -with-deps && ../node_modules/.bin/rescript build`, {
7+
child_process.execSync(`${rescript_exe} clean -with-deps && ${rescript_exe} build`, {
78
cwd: __dirname,
8-
stdio: [0, 1, 2],
99
});
1010

1111
var x = require("./src/demo.bs.js");

jscomp/build_tests/exports/input.js

-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
44
child_process.execSync(rescript_exe, {
55
cwd: __dirname,
66
encoding: "utf8",
7-
stdio: [0, 1, 2],
87
});

jscomp/build_tests/hyphen2/input.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
var p = require("child_process");
22
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
33

4-
p.execSync(rescript_exe, { cwd: __dirname, stdio: [0, 1, 2] });
4+
p.execSync(rescript_exe, { cwd: __dirname });

jscomp/build_tests/install/input.js

-4
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
77
p.spawnSync(rescript_exe, [`clean`], {
88
encoding: "utf8",
99
cwd: __dirname,
10-
stdio: [0, 1, 2]
1110
});
1211
p.spawnSync(rescript_exe, [`build`,`-install`], {
1312
encoding: "utf8",
1413
cwd: __dirname,
15-
stdio: [0, 1, 2]
1614
});
1715

1816
var fooExists = fs.existsSync(path.join(__dirname, "lib", "ocaml", "Foo.cmi"));
@@ -21,12 +19,10 @@ assert.ok(fooExists == false);
2119
p.spawnSync(rescript_exe, {
2220
encoding: "utf8",
2321
cwd: __dirname,
24-
stdio: [0, 1, 2]
2522
});
2623
p.spawnSync(rescript_exe ,[`build`,`-install`], {
2724
encoding: "utf8",
2825
cwd: __dirname,
29-
stdio: [0, 1, 2]
3026
});
3127

3228
fooExists = fs.existsSync(path.join(__dirname, "lib", "ocaml", "Foo.cmi"));

jscomp/build_tests/namespace/input.js

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ var path = require("path");
44
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
55
child_process.execSync(`${rescript_exe} clean -with-deps && ${rescript_exe} build`, {
66
cwd: __dirname,
7-
stdio: [0, 1, 2],
87
});
98

109
var x = require("./src/demo.bs.js");

jscomp/build_tests/nested/input.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var assert = require("assert");
33
var fs = require("fs");
44
var path = require("path");
55
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
6-
p.execSync(rescript_exe, { cwd: __dirname, stdio: [0, 1, 2] });
6+
p.execSync(rescript_exe, { cwd: __dirname });
77

88
var content = fs.readFileSync(path.join(__dirname, "src", "demo.js"), "utf8");
99

jscomp/build_tests/nnest/input.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var assert = require("assert");
55
var fs = require("fs");
66
var path = require("path");
77
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
8-
p.execSync(rescript_exe, { cwd: __dirname, stdio: [0, 1, 2] });
8+
p.execSync(rescript_exe, { cwd: __dirname });
99

1010
var content = fs.readFileSync(path.join(__dirname, "src", "demo.js"), "utf8");
1111

jscomp/build_tests/ns/input.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
var child_process = require("child_process");
22
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
33

4-
child_process.execSync(rescript_exe, { cwd: __dirname, stdio: [0, 1, 2] });
4+
child_process.execSync(rescript_exe, { cwd: __dirname });

jscomp/build_tests/priv/input.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var child_process = require("child_process");
22
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
33

44
var output = child_process.spawnSync(
5-
`${rescript_exe} -with-deps && ${rescript_exe} build`,
5+
`${rescript_exe} clean -with-deps && ${rescript_exe} build`,
66
{ cwd: __dirname, shell: true, encoding: "utf8" }
77
);
88

jscomp/build_tests/react_ppx/input.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
var cp = require("child_process");
33
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
44

5-
cp.execSync(rescript_exe, { cwd: __dirname, stdio: [0, 1, 2] });
5+
cp.execSync(rescript_exe, { cwd: __dirname });

jscomp/build_tests/rerror/input.js

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
44
child_process.spawnSync(`${rescript_exe} clean -with-deps`, {
55
cwd: __dirname,
66
encoding: "utf8",
7-
stdio: [0, 1, 2],
87
});
98
var o = child_process.spawnSync(rescript_exe, {
109
cwd: __dirname,

jscomp/build_tests/scoped_ppx/input.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var cp = require("child_process");
22
var assert = require("assert");
33
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
4-
cp.execSync(rescript_exe, { cwd: __dirname, stdio: [0, 1, 2], encoding: "utf8" });
4+
cp.execSync(rescript_exe, { cwd: __dirname, encoding: "utf8" });
55

66
var output = cp.execSync(`${rescript_exe} build -- -t commands src/hello.ast`, {
77
cwd: __dirname,

jscomp/build_tests/white space/input.js

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ try {
77
p.execSync(`${rescript_exe} build`, {
88
cwd: __dirname,
99
encoding: "utf8",
10-
stdio: [0, 1, 2],
1110
});
1211
r.rollup({
1312
input: path.join(__dirname, "yy.js"),

scripts/ciTest.js

+14-13
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ function runTests() {
118118
encoding: "utf8",
119119
});
120120
var files = fs.readdirSync(buildTestDir);
121-
var failed = [];
122121
files.forEach(function (file) {
123122
var testDir = path.join(buildTestDir, file);
124123
if (file === "node_modules" || !fs.lstatSync(testDir).isDirectory()) {
@@ -129,20 +128,22 @@ function runTests() {
129128
} else {
130129
console.log(`testing ${file}`);
131130
// note existsSync test already ensure that it is a directory
132-
try {
133-
cp.exec(`node input.js`, { cwd: testDir, encoding: "utf8" });
134-
console.log("✅ success in ", file);
135-
} catch (e) {
136-
failed.push(file);
137-
console.log("❌ error", e);
138-
}
131+
cp.exec(
132+
`node input.js`,
133+
{ cwd: testDir, encoding: "utf8" },
134+
function (error, stdout, stderr) {
135+
console.log(stdout);
136+
137+
if (error !== null) {
138+
console.log(stderr);
139+
throw new Error(`❌ error in ${file}: \n${error} `);
140+
} else {
141+
console.log("✅ success in ", file);
142+
}
143+
}
144+
);
139145
}
140146
});
141-
if (failed.length > 0) {
142-
console.log("");
143-
console.log("❌ Build tests failed", failed);
144-
throw new Error();
145-
}
146147
}
147148
}
148149

0 commit comments

Comments
 (0)