Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion test/cli/bake/bake.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,18 @@ test.concurrent.each([
);
const [, url] = await output.waitFor(/url: (http:\/\/\S+)/);

expect(await get(url, "/missing")).toBe("200 1");
// One save can start the process twice on Windows, and each start prints its own port.
if (!isWindows) {
expect(await get(url, "/missing")).toBe("200 1");
return;
}
const deadline = Date.now() + 10_000;
let response = "";
while (response !== "200 1" && Date.now() < deadline) {
const latest = [...output.text.matchAll(/url: (http:\/\/\S+)/g)].at(-1)![1];
response = await get(latest, "/missing").catch(String);
}
Comment thread
alii marked this conversation as resolved.
Resolved
expect(response).toBe("200 1");
});

// Creating a symlink on Windows needs a privilege that CI does not have.
Expand Down
25 changes: 22 additions & 3 deletions test/harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -611,10 +611,29 @@ export function tempDirWithFiles(

class DisposableString extends String {
[Symbol.dispose]() {
fs.rmSync(this + "", { recursive: true, force: true });
// On Windows a process that was just killed can hold the folder for a moment: a child that a job
// object ends after its parent, for one. `rmSync` does not act on `maxRetries`.
const deadline = Date.now() + 5000;
while (true) {
try {
fs.rmSync(this + "", { recursive: true, force: true });
return;
} catch (error: any) {
if (!isWindows || error?.code !== "EBUSY" || Date.now() > deadline) throw error;
sleepSync(50);
}
}
}
[Symbol.asyncDispose]() {
return fs.promises.rm(this + "", { recursive: true, force: true });
async [Symbol.asyncDispose]() {
const deadline = Date.now() + 5000;
while (true) {
try {
return await fs.promises.rm(this + "", { recursive: true, force: true });
} catch (error: any) {
if (!isWindows || error?.code !== "EBUSY" || Date.now() > deadline) throw error;
await Bun.sleep(50);
}
}
}
}

Expand Down
Loading