Skip to content

Commit

Permalink
tmp: no buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
cometkim committed Mar 6, 2024
1 parent e4069e1 commit 6098902
Showing 1 changed file with 38 additions and 17 deletions.
55 changes: 38 additions & 17 deletions scripts/ciTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if (all) {
formatTest = true;
}

function runTests() {
async function runTests() {
if (ounitTest) {
cp.execSync(path.join(duneBinDir, "ounit_tests"), {
stdio: [0, 1, 2],
Expand All @@ -56,7 +56,13 @@ function runTests() {
console.log("Doing build_tests");
var buildTestDir = path.join(__dirname, "..", "jscomp", "build_tests");
var files = fs.readdirSync(buildTestDir);
files.forEach(function (file) {
var tasks = files.map(async function (file) {
// @ts-ignore
let resolve, reject;
let promise = new Promise((res, rej) => {
resolve = res;
reject = rej;
});
var testDir = path.join(buildTestDir, file);
if (file === "node_modules" || !fs.lstatSync(testDir).isDirectory()) {
return;
Expand All @@ -65,23 +71,38 @@ function runTests() {
console.warn(`input.js does not exist in ${testDir}`);
} else {
console.log(`testing ${file}`);

// note existsSync test already ensure that it is a directory
cp.exec(
`node input.js`,
{ cwd: testDir, encoding: "utf8" },
function (error, stdout, stderr) {
console.log(stdout);

if (error !== null) {
console.log(`❌ error in ${file} with stderr:\n`, stderr);
throw error;
} else {
console.log("✅ success in", file);
}
let p = cp.spawn(`node`, ["input.js"], { cwd: testDir });

p.stdout.setEncoding("utf8").on("data", line => {
console.log(line);
});

let stderr = "";
p.stderr.setEncoding("utf8").on("data", line => {
stderr += line + "\n";
});

p.once("error", err => {
console.log(`❌ error in ${file} with stderr:\n`, stderr);
// @ts-ignore
reject(err);
});

p.once("close", () => {
if (!stderr) {
console.log("✅ success in", file);
}
);
// @ts-ignore
resolve();
});
}

return promise;
});

await Promise.all(tasks);
}

if (formatTest) {
Expand All @@ -92,9 +113,9 @@ function runTests() {
}
}

function main() {
async function main() {
try {
runTests();
await runTests();
} catch (err) {
console.error(err);
process.exit(2);
Expand Down

0 comments on commit 6098902

Please sign in to comment.