Skip to content

Commit aabe056

Browse files
committed
Try fixing test failure in CI
1 parent b2a0214 commit aabe056

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/test/suite/extensionIntegration.test.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import * as os from "os";
77
import { execSync } from "child_process";
88

99
suite("Extension Integration", () => {
10-
test("Git branch detected in in-workspace file", async () => {
10+
test("Git branch detected in in-workspace file", async function () {
11+
this.timeout(5000); // Should be longer than the deadline below
12+
1113
const expectedBranch = execSync("git branch --show-current", {
1214
cwd: __dirname,
1315
})
@@ -30,21 +32,21 @@ suite("Extension Integration", () => {
3032
)!;
3133
await ext.activate();
3234

33-
// Wait (up to ~2s) for async branch detection to populate gitBranch
34-
const deadline = Date.now() + 2000;
35-
let actualBranch: string | undefined = ext.exports.gitBranch;
36-
while (actualBranch != expectedBranch && Date.now() < deadline) {
35+
// Wait (up to ~4s) for async branch detection to populate gitBranch
36+
const deadline = Date.now() + 4000; // Should be shorter than the test timeout above
37+
while (ext.exports.gitBranch != expectedBranch && Date.now() < deadline) {
3738
await new Promise((r) => globalThis.setTimeout(r, 50));
38-
actualBranch = ext.exports.gitBranch;
3939
}
4040

41-
assert.strictEqual(actualBranch, expectedBranch);
41+
assert.strictEqual(ext.exports.gitBranch, expectedBranch);
4242
} finally {
4343
fs.rmSync(commitMessage);
4444
}
4545
});
4646

47-
test("Git branch detected in not-in-workspace file", async () => {
47+
test("Git branch detected in not-in-workspace file", async function () {
48+
this.timeout(5000); // Should be longer than the deadline below
49+
4850
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "git-commit-test-"));
4951

5052
try {
@@ -67,15 +69,13 @@ suite("Extension Integration", () => {
6769
)!;
6870
await ext.activate();
6971

70-
// Wait (up to ~2s) for async branch detection to populate gitBranch
71-
const deadline = Date.now() + 2000;
72-
let actualBranch: string | undefined = ext.exports.gitBranch;
73-
while (actualBranch != "test-branch" && Date.now() < deadline) {
72+
// Wait (up to ~4s) for async branch detection to populate gitBranch
73+
const deadline = Date.now() + 4000; // Should be shorter than the test timeout above
74+
while (ext.exports.gitBranch != "test-branch" && Date.now() < deadline) {
7475
await new Promise((r) => globalThis.setTimeout(r, 50));
75-
actualBranch = ext.exports.gitBranch;
7676
}
7777

78-
assert.strictEqual(actualBranch, "test-branch");
78+
assert.strictEqual(ext.exports.gitBranch, "test-branch");
7979
} finally {
8080
fs.rmSync(tmpDir, { recursive: true, force: true });
8181
}

0 commit comments

Comments
 (0)