mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
fix hot/hot.test.ts, hot/watch.test.ts, and watch/watch.test.ts (#13876)
Co-authored-by: dylan-conway <dylan-conway@users.noreply.github.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { spawn } from "bun";
|
import { spawn } from "bun";
|
||||||
import { beforeEach, expect, it } from "bun:test";
|
import { beforeEach, expect, it } from "bun:test";
|
||||||
import { copyFileSync, cpSync, readFileSync, renameSync, rmSync, unlinkSync, writeFileSync } from "fs";
|
import { copyFileSync, cpSync, readFileSync, renameSync, rmSync, unlinkSync, writeFileSync } from "fs";
|
||||||
import { bunEnv, bunExe, isDebug, tmpdirSync } from "harness";
|
import { bunEnv, bunExe, isDebug, tmpdirSync, waitForFileToExist } from "harness";
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
|
|
||||||
const timeout = isDebug ? Infinity : 10_000;
|
const timeout = isDebug ? Infinity : 10_000;
|
||||||
@@ -487,6 +487,7 @@ throw new Error('0');`,
|
|||||||
stderr: "inherit",
|
stderr: "inherit",
|
||||||
stdin: "ignore",
|
stdin: "ignore",
|
||||||
});
|
});
|
||||||
|
waitForFileToExist(hotRunnerRoot, 20);
|
||||||
await using runner = spawn({
|
await using runner = spawn({
|
||||||
cmd: [bunExe(), "--hot", "run", hotRunnerRoot],
|
cmd: [bunExe(), "--hot", "run", hotRunnerRoot],
|
||||||
env: bunEnv,
|
env: bunEnv,
|
||||||
@@ -576,6 +577,7 @@ throw new Error('0');`,
|
|||||||
stderr: "ignore",
|
stderr: "ignore",
|
||||||
stdin: "ignore",
|
stdin: "ignore",
|
||||||
});
|
});
|
||||||
|
waitForFileToExist(hotRunnerRoot, 20);
|
||||||
await using runner = spawn({
|
await using runner = spawn({
|
||||||
cmd: [
|
cmd: [
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ for (const dir of ["dir", "©️"]) {
|
|||||||
await updateFile(i);
|
await updateFile(i);
|
||||||
}
|
}
|
||||||
rmSync(path);
|
rmSync(path);
|
||||||
});
|
}, 10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { gc as bunGC, spawnSync, unsafe, which } from "bun";
|
import { gc as bunGC, sleepSync, spawnSync, unsafe, which } from "bun";
|
||||||
import { heapStats } from "bun:jsc";
|
import { heapStats } from "bun:jsc";
|
||||||
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
|
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
|
||||||
import { readFile, readlink, writeFile } from "fs/promises";
|
import { readFile, readlink, writeFile } from "fs/promises";
|
||||||
@@ -1284,3 +1284,9 @@ Object.defineProperty(globalThis, "gc", {
|
|||||||
enumerable: false,
|
enumerable: false,
|
||||||
configurable: true,
|
configurable: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export function waitForFileToExist(path: string, interval: number) {
|
||||||
|
while (!fs.existsSync(path)) {
|
||||||
|
sleepSync(interval);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user