feat: release 2.7.0-rc2
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
||||
compareVersions,
|
||||
createVersionObserver,
|
||||
installVersion,
|
||||
waitForVersionUpdate,
|
||||
} from "../../lib/version-update";
|
||||
|
||||
const tick = () => new Promise<void>((resolve) => setTimeout(resolve, 0));
|
||||
@@ -36,16 +37,15 @@ describe("server version updates", () => {
|
||||
expect(await installVersion("2.7.0;echo hacked")).toBe(false);
|
||||
});
|
||||
|
||||
test("uses a quiet detached timeout argument vector", async () => {
|
||||
test("uses a quiet Bun install with explicit inherited environment", async () => {
|
||||
const calls: string[][] = [];
|
||||
let unrefs = 0;
|
||||
const spawn = (
|
||||
argv: string[],
|
||||
options: {
|
||||
stdin: "ignore";
|
||||
stdout: "ignore";
|
||||
stderr: "ignore";
|
||||
detached: true;
|
||||
env: NodeJS.ProcessEnv;
|
||||
},
|
||||
) => {
|
||||
calls.push(argv);
|
||||
@@ -53,30 +53,69 @@ describe("server version updates", () => {
|
||||
stdin: "ignore",
|
||||
stdout: "ignore",
|
||||
stderr: "ignore",
|
||||
detached: true,
|
||||
env: process.env,
|
||||
});
|
||||
expect(options.env.PATH).toBe(process.env.PATH);
|
||||
return {
|
||||
exited: Promise.resolve(0),
|
||||
unref: () => {
|
||||
unrefs++;
|
||||
kill: () => {
|
||||
throw new Error("unexpected kill");
|
||||
},
|
||||
};
|
||||
};
|
||||
expect(await installVersion("2.7.0-rc.1+build.2", spawn, 1)).toBe(true);
|
||||
expect(await installVersion("2.7.0-rc.1+build.2", spawn, 2)).toBe(true);
|
||||
expect(calls).toEqual([
|
||||
[
|
||||
"timeout",
|
||||
"--signal=TERM",
|
||||
"--kill-after=2s",
|
||||
"1s",
|
||||
"bun",
|
||||
process.execPath,
|
||||
"i",
|
||||
"-g",
|
||||
"--no-cache",
|
||||
"@dmgnr/[email protected]+build.2",
|
||||
],
|
||||
]);
|
||||
expect(unrefs).toBe(1);
|
||||
});
|
||||
|
||||
test("kills a stalled installer and treats late success as failure", async () => {
|
||||
let finish!: (code: number) => void;
|
||||
const exited = new Promise<number>((resolve) => {
|
||||
finish = resolve;
|
||||
});
|
||||
const signals: (NodeJS.Signals | undefined)[] = [];
|
||||
const installing = installVersion(
|
||||
"2.7.0",
|
||||
() => ({
|
||||
exited,
|
||||
kill: (signal) => {
|
||||
signals.push(signal);
|
||||
finish(0);
|
||||
},
|
||||
}),
|
||||
1,
|
||||
);
|
||||
expect(await installing).toBe(false);
|
||||
expect(signals).toEqual([undefined]);
|
||||
});
|
||||
|
||||
test("handles spawn errors and bounds an unresponsive child", async () => {
|
||||
expect(
|
||||
await installVersion("2.7.0", () => {
|
||||
throw new Error("spawn failed");
|
||||
}),
|
||||
).toBe(false);
|
||||
const signals: (NodeJS.Signals | undefined)[] = [];
|
||||
expect(
|
||||
await installVersion(
|
||||
"2.7.0",
|
||||
() => ({
|
||||
exited: new Promise<number>(() => {}),
|
||||
kill: (signal) => {
|
||||
signals.push(signal);
|
||||
},
|
||||
}),
|
||||
1,
|
||||
),
|
||||
).toBe(false);
|
||||
expect(signals).toEqual([undefined, "SIGKILL"]);
|
||||
});
|
||||
|
||||
test("ignores malformed, equal, and older headers without attempting an install", async () => {
|
||||
@@ -126,7 +165,7 @@ describe("server version updates", () => {
|
||||
expect(runs).toEqual(["2.6.1"]);
|
||||
expect(lines).toEqual([]);
|
||||
finish(true);
|
||||
await tick();
|
||||
await waitForVersionUpdate();
|
||||
expect(lines).toEqual(["\x1b[90m+ Updated to 2.6.1\x1b[0m\n"]);
|
||||
observe("10.0.0");
|
||||
await tick();
|
||||
@@ -155,28 +194,6 @@ describe("server version updates", () => {
|
||||
}
|
||||
});
|
||||
|
||||
test("a detached pending install does not delay a short CLI or pollute its streams", async () => {
|
||||
const url = new URL("../../lib/version-update.ts", import.meta.url).href;
|
||||
const script = `
|
||||
const { createVersionObserver } = await import(${JSON.stringify(url)});
|
||||
createVersionObserver({ currentVersion: '2.6.1',
|
||||
runner: () => new Promise(() => {}) })('2.7.0');
|
||||
`;
|
||||
const child = Bun.spawn([process.execPath, "-e", script], {
|
||||
stdin: "ignore",
|
||||
stdout: "pipe",
|
||||
stderr: "pipe",
|
||||
});
|
||||
const timeout = setTimeout(() => child.kill(), 1_000);
|
||||
try {
|
||||
expect(await child.exited).toBe(0);
|
||||
expect(await new Response(child.stdout).text()).toBe("");
|
||||
expect(await new Response(child.stderr).text()).toBe("");
|
||||
} finally {
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
});
|
||||
|
||||
test("a short subprocess emits one outcome to stderr when its runner settles", async () => {
|
||||
const url = new URL("../../lib/version-update.ts", import.meta.url).href;
|
||||
for (const result of ["true", "false", "reject"]) {
|
||||
|
||||
Reference in New Issue
Block a user