Skip to content

Commit

Permalink
Update runner.node.mjs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarred-Sumner committed Sep 27, 2024
1 parent 0bbce0f commit fc1ae69
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions scripts/runner.node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@
// - It cannot use Bun APIs, since it is run using Node.js.
// - It does not import dependencies, so it's faster to start.

import { spawn, spawnSync } from "node:child_process";
import {
constants as fs,
readFileSync,
mkdtempSync,
existsSync,
statSync,
mkdirSync,
accessSync,
appendFileSync,
existsSync,
constants as fs,
mkdirSync,
mkdtempSync,
readdirSync,
readFileSync,
rmSync,
statSync,
} from "node:fs";
import { spawn, spawnSync } from "node:child_process";
import { tmpdir, hostname, userInfo, homedir } from "node:os";
import { join, basename, dirname, relative, sep, resolve } from "node:path";
import { normalize as normalizeWindows } from "node:path/win32";
import { isIP } from "node:net";
import { homedir, hostname, tmpdir, userInfo } from "node:os";
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
import { normalize as normalizeWindows } from "node:path/win32";
import { parseArgs } from "node:util";

const spawnTimeout = 5_000;
Expand Down Expand Up @@ -226,7 +226,7 @@ async function runTests() {
// Make it an absolute path so that the test directory is not scanned, which reduces the load on the filesystem
const abs = resolve("test", testPath);

await runTest(title, async () => spawnBunTest(execPath, abs));
await runTest(title, async () => spawnBunTest(execPath, abs, join("test", testPath)));
}
}

Expand Down Expand Up @@ -535,12 +535,12 @@ async function spawnBun(execPath, { args, cwd, timeout, env, stdout, stderr }) {
* @param {string} testPath
* @returns {Promise<TestResult>}
*/
async function spawnBunTest(execPath, testPath) {
async function spawnBunTest(execPath, absoluteTestPath, testPath) {
const timeout = getTestTimeout(testPath);
const perTestTimeout = Math.ceil(timeout / 2);
const isReallyTest = isTestStrict(testPath);
const { ok, error, stdout } = await spawnBun(execPath, {
args: isReallyTest ? ["test", `--timeout=${perTestTimeout}`, testPath] : [testPath],
args: isReallyTest ? ["test", `--timeout=${perTestTimeout}`, absoluteTestPath] : [absoluteTestPath],
cwd: cwd,
timeout: isReallyTest ? timeout : 30_000,
env: {
Expand Down Expand Up @@ -1269,6 +1269,10 @@ function getBuildLabel() {
* @returns {string | undefined}
*/
function getFileUrl(file, line) {
if (isAbsolute(filePath)) {
file = relative(cwd, filePath);
}

const filePath = file.replace(/\\/g, "/");

let url;
Expand Down

0 comments on commit fc1ae69

Please sign in to comment.