Skip to content

Commit c8598b1

Browse files
committed
test/integration/goDebug: catch any error while cleaning up
On windows, sometimes we get Resource Busy errors. We catch and log the errors gut subsequent file deletion still can fail. Catch all errors. For #832 Change-Id: I81fe195c9862b2a8f96cbc0bebf9b39f40f6d21d Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/418355 Reviewed-by: Suzy Mueller <[email protected]> Run-TryBot: Hyang-Ah Hana Kim <[email protected]> TryBot-Result: kokoro <[email protected]>
1 parent 8f6cb5d commit c8598b1

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

test/integration/goDebug.test.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1926,7 +1926,7 @@ const testAll = (ctx: Mocha.Context, isDlvDap: boolean, withConsole?: string) =>
19261926
tmpDir = fs.mkdtempSync(path.join(tmpdir(), 'logDestTest'));
19271927
});
19281928
suiteTeardown(() => {
1929-
rmdirRecursive(tmpDir);
1929+
tryRmdirRecursive(tmpDir);
19301930
});
19311931

19321932
test('logs are written to logDest file', async function () {
@@ -1998,7 +1998,7 @@ const testAll = (ctx: Mocha.Context, isDlvDap: boolean, withConsole?: string) =>
19981998
});
19991999

20002000
suiteTeardown(() => {
2001-
rmdirRecursive(tmpDir);
2001+
tryRmdirRecursive(tmpDir);
20022002
});
20032003

20042004
function copyDirectory(name: string) {
@@ -2030,13 +2030,13 @@ const testAll = (ctx: Mocha.Context, isDlvDap: boolean, withConsole?: string) =>
20302030
});
20312031

20322032
suiteTeardown(() => {
2033-
rmdirRecursive(goBuildOutput);
2033+
tryRmdirRecursive(goBuildOutput);
20342034
});
20352035

20362036
async function copyBuildDelete(program: string): Promise<{ program: string; output: string }> {
20372037
const wd = copyDirectory(program);
20382038
const output = await buildGoProgram(wd, path.join(goBuildOutput, program));
2039-
rmdirRecursive(wd);
2039+
tryRmdirRecursive(wd);
20402040
return { program: wd, output };
20412041
}
20422042

@@ -2081,7 +2081,7 @@ const testAll = (ctx: Mocha.Context, isDlvDap: boolean, withConsole?: string) =>
20812081
});
20822082

20832083
suiteTeardown(() => {
2084-
rmdirRecursive(helloWorldLocal);
2084+
tryRmdirRecursive(helloWorldLocal);
20852085
});
20862086

20872087
test('stopped for a breakpoint set during initialization using substitutePath (remote attach)', async () => {
@@ -2149,7 +2149,7 @@ const testAll = (ctx: Mocha.Context, isDlvDap: boolean, withConsole?: string) =>
21492149
});
21502150
suiteTeardown(() => {
21512151
fs.unlinkSync(symlinkPath);
2152-
rmdirRecursive(realPath);
2152+
tryRmdirRecursive(realPath);
21532153
});
21542154
test('should stop on a breakpoint', async function () {
21552155
if (!isDlvDap) this.skip(); // BUG: the legacy adapter fails with 'breakpoint verification mismatch' error.
@@ -2428,3 +2428,11 @@ class DelveDAPDebugAdapterOnSocket extends proxy.DelveDAPOutputAdapter {
24282428
function sleep(ms: number) {
24292429
return new Promise((resolve) => setTimeout(resolve, ms));
24302430
}
2431+
2432+
function tryRmdirRecursive(dir: string) {
2433+
try {
2434+
rmdirRecursive(dir);
2435+
} catch (e) {
2436+
console.log(`failed to delete ${dir}: ${e}`);
2437+
}
2438+
}

0 commit comments

Comments
 (0)