Skip to content

Commit 709d202

Browse files
committed
tmp: no buffer
1 parent e4069e1 commit 709d202

File tree

1 file changed

+40
-17
lines changed

1 file changed

+40
-17
lines changed

scripts/ciTest.js

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ if (all) {
3737
formatTest = true;
3838
}
3939

40-
function runTests() {
40+
async function runTests() {
4141
if (ounitTest) {
4242
cp.execSync(path.join(duneBinDir, "ounit_tests"), {
4343
stdio: [0, 1, 2],
@@ -56,7 +56,13 @@ function runTests() {
5656
console.log("Doing build_tests");
5757
var buildTestDir = path.join(__dirname, "..", "jscomp", "build_tests");
5858
var files = fs.readdirSync(buildTestDir);
59-
files.forEach(function (file) {
59+
var tasks = files.map(async function (file) {
60+
// @ts-ignore
61+
let resolve, reject;
62+
let promise = new Promise((res, rej) => {
63+
resolve = res;
64+
reject = rej;
65+
});
6066
var testDir = path.join(buildTestDir, file);
6167
if (file === "node_modules" || !fs.lstatSync(testDir).isDirectory()) {
6268
return;
@@ -65,23 +71,40 @@ function runTests() {
6571
console.warn(`input.js does not exist in ${testDir}`);
6672
} else {
6773
console.log(`testing ${file}`);
74+
6875
// note existsSync test already ensure that it is a directory
69-
cp.exec(
70-
`node input.js`,
71-
{ cwd: testDir, encoding: "utf8" },
72-
function (error, stdout, stderr) {
73-
console.log(stdout);
74-
75-
if (error !== null) {
76-
console.log(`❌ error in ${file} with stderr:\n`, stderr);
77-
throw error;
78-
} else {
79-
console.log("✅ success in", file);
80-
}
76+
let p = cp.spawn(`node`, ["input.js"], { cwd: testDir });
77+
78+
p.stdout
79+
.setEncoding("utf8")
80+
.on("data", line => {
81+
console.log(line);
82+
});
83+
84+
let error = '';
85+
p.stderr
86+
.setEncoding("utf8")
87+
.on("data", line => {
88+
error += line + "\n";
89+
});
90+
91+
p.on("close", () => {
92+
if (error) {
93+
console.log(`❌ error in ${file} with stderr:\n`, error);
94+
// @ts-ignore
95+
reject(error);
96+
} else {
97+
console.log("✅ success in", file);
98+
// @ts-ignore
99+
resolve();
81100
}
82-
);
101+
});
83102
}
103+
104+
return promise;
84105
});
106+
107+
await Promise.all(tasks);
85108
}
86109

87110
if (formatTest) {
@@ -92,9 +115,9 @@ function runTests() {
92115
}
93116
}
94117

95-
function main() {
118+
async function main() {
96119
try {
97-
runTests();
120+
await runTests();
98121
} catch (err) {
99122
console.error(err);
100123
process.exit(2);

0 commit comments

Comments
 (0)