Skip to content

Commit e489241

Browse files
committed
citest: add callback
1 parent 9af349c commit e489241

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

scripts/ciTest.js

Lines changed: 14 additions & 13 deletions
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(`node input.js`, { cwd: testDir, encoding: "utf8" }, function (
132+
error,
133+
stdout,
134+
stderr
135+
) {
136+
console.log(stdout);
137+
138+
if (error !== null) {
139+
console.log(stderr);
140+
throw new Error(`❌ error in ${file}: \n${error} `);
141+
} else {
142+
console.log("✅ success in ", file);
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)