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
19 changes: 14 additions & 5 deletions test/unit/core/cliManager.concurrent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@ function setupManager(testDir: string): CliManager {
);
}

/**
* Asserts the lock and progress files are removed. The lock directory can
* briefly reappear while a peer re-acquires and releases it, so poll until gone.
*/
async function expectLockFilesRemoved(binaryPath: string): Promise<void> {
await vi.waitFor(async () => {
await expect(fs.access(binaryPath + ".lock")).rejects.toThrow();
await expect(fs.access(binaryPath + ".progress.log")).rejects.toThrow();
});
}

describe("CliManager Concurrent Downloads", () => {
let testDir: string;

Expand Down Expand Up @@ -124,10 +135,9 @@ describe("CliManager Concurrent Downloads", () => {
expect(result).toBe(binaryPath);
}

// Verify binary exists, and lock/progress files are cleaned up
// Verify binary exists, and lock/progress files are cleaned up.
await expect(fs.access(binaryPath)).resolves.toBeUndefined();
await expect(fs.access(binaryPath + ".lock")).rejects.toThrow();
await expect(fs.access(binaryPath + ".progress.log")).rejects.toThrow();
await expectLockFilesRemoved(binaryPath);
});

it("redownloads when version mismatch is detected concurrently", async () => {
Expand Down Expand Up @@ -167,8 +177,7 @@ describe("CliManager Concurrent Downloads", () => {
await expect(fs.access(binaryPath)).resolves.toBeUndefined();
const finalContent = await fs.readFile(binaryPath, "utf8");
expect(finalContent).toContain("v2.0.0");
await expect(fs.access(binaryPath + ".lock")).rejects.toThrow();
await expect(fs.access(binaryPath + ".progress.log")).rejects.toThrow();
await expectLockFilesRemoved(binaryPath);
});

it.each([
Expand Down
13 changes: 10 additions & 3 deletions test/unit/remote/sshSupport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,16 @@ Object.entries(supports).forEach(([version, expected]) => {
});
});

it("current shell supports ssh", () => {
expect(sshSupportsSetEnv()).toBeTruthy();
});
/**
* Spawning real `ssh` is slow on Windows CI runners, so allow a larger budget there.
*/
it(
"current shell supports ssh",
{ timeout: process.platform === "win32" ? 30_000 : undefined },
() => {
expect(sshSupportsSetEnv()).toBeTruthy();
},
);

describe("computeSshProperties", () => {
it("computes the config for a host", () => {
Expand Down