aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alex Lam S.L <alexlamsl@gmail.com> 2023-03-31 17:14:55 +0300
committerGravatar GitHub <noreply@github.com> 2023-03-31 07:14:55 -0700
commit685e298146af11215e372d974de625e8a551061e (patch)
treeff3348ab15ba5123ea8d349bb9fa413175b44ae1
parent74cacffb0c3894fbf8c43d960842f6360fef41bf (diff)
downloadbun-685e298146af11215e372d974de625e8a551061e.tar.gz
bun-685e298146af11215e372d974de625e8a551061e.tar.zst
bun-685e298146af11215e372d974de625e8a551061e.zip
report timed-out test as failure (#2523)
-rw-r--r--packages/bun-internal-test/src/runner.node.mjs17
1 files changed, 9 insertions, 8 deletions
diff --git a/packages/bun-internal-test/src/runner.node.mjs b/packages/bun-internal-test/src/runner.node.mjs
index 60b11905f..508e2e339 100644
--- a/packages/bun-internal-test/src/runner.node.mjs
+++ b/packages/bun-internal-test/src/runner.node.mjs
@@ -1,10 +1,10 @@
import * as action from "@actions/core";
import { spawnSync } from "child_process";
-import { fsyncSync, rmSync, statSync, writeFileSync, writeSync } from "fs";
+import { fsyncSync, rmSync, writeFileSync, writeSync } from "fs";
import { readdirSync } from "node:fs";
import { resolve } from "node:path";
import { StringDecoder } from "node:string_decoder";
-import { basename, relative } from "path";
+import { relative } from "path";
import { fileURLToPath } from "url";
const cwd = resolve(fileURLToPath(import.meta.url), "../../../../");
@@ -55,6 +55,7 @@ async function runTest(path) {
stdout,
stderr,
status: exitCode,
+ error: timedOut,
} = spawnSync("bun", ["test", path], {
stdio: ["ignore", "pipe", "pipe"],
timeout: 10_000,
@@ -63,18 +64,20 @@ async function runTest(path) {
FORCE_COLOR: "1",
},
});
+ const passed = exitCode === 0 && !timedOut;
- if (+exitCode !== 0) {
+ if (!passed) {
failingTests.push(name);
+ if (timedOut) console.error(timedOut);
}
- if (isAction && exitCode !== 0) {
+ if (isAction && !passed) {
findErrors(stdout);
findErrors(stderr);
}
if (isAction) {
- const prefix = +exitCode === 0 ? "PASS" : `FAIL`;
+ const prefix = passed ? "PASS" : `FAIL`;
action.startGroup(`${prefix} - ${name}`);
}
@@ -86,8 +89,6 @@ async function runTest(path) {
}
}
-let failed = false;
-
function findErrors(data) {
const text = new StringDecoder().write(new Buffer(data.buffer)).replaceAll(/\u001b\[.*?m/g, "");
let index = 0;
@@ -149,4 +150,4 @@ if (isAction) {
writeFileSync("failing-tests.txt", failingTests.join("\n"));
}
-process.exit(failed ? 1 : 0);
+process.exit(failingTests.length);