Compare commits

...

2 Commits

Author SHA1 Message Date
Meghan Denny
6142c7fc1c Merge branch 'main' into nektro-patch-16679 2024-08-14 17:18:58 -07:00
Meghan Denny
9db65c9159 ci: investigate watch/watch.test.ts 2024-08-09 18:07:50 -07:00

View File

@@ -2,13 +2,13 @@ import { it, expect, afterEach } from "bun:test";
import type { Subprocess } from "bun";
import { spawn } from "bun";
import { join } from "node:path";
import { writeFileSync, rmSync } from "node:fs";
import { rmSync } from "node:fs";
import { bunExe, bunEnv, tmpdirSync } from "harness";
let watchee: Subprocess;
for (const dir of ["dir", "©️"]) {
it(`should watch files ${dir === "dir" ? "" : "(non-ascii path)"}`, async () => {
it(`should watch files${dir === "dir" ? "" : " (non-ascii path)"}`, async () => {
const cwd = join(tmpdirSync(), dir);
const path = join(cwd, "watchee.js");
@@ -17,7 +17,9 @@ for (const dir of ["dir", "©️"]) {
};
let i = 0;
console.log(0);
await updateFile(i);
console.log(1);
watchee = spawn({
cwd,
cmd: [bunExe(), "--watch", "watchee.js"],
@@ -26,18 +28,24 @@ for (const dir of ["dir", "©️"]) {
stderr: "inherit",
stdin: "ignore",
});
console.log(2);
for await (const line of watchee.stdout) {
console.log(3, i, Buffer.from(line).toString().trim());
if (i == 10) break;
var str = new TextDecoder().decode(line);
expect(str).toContain(`${i} ${cwd}`);
i++;
await updateFile(i);
}
console.log(4);
rmSync(path);
console.log(5);
});
}
afterEach(() => {
console.log(6);
watchee?.kill();
console.log(7);
});