Skip to content

Commit

Permalink
test/integration/goDebug: catch any error while cleaning up
Browse files Browse the repository at this point in the history
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 golang#832

Change-Id: I81fe195c9862b2a8f96cbc0bebf9b39f40f6d21d
  • Loading branch information
hyangah committed Jul 19, 2022
1 parent af61fa7 commit 06ba506
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions test/integration/goDebug.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1926,7 +1926,7 @@ const testAll = (ctx: Mocha.Context, isDlvDap: boolean, withConsole?: string) =>
tmpDir = fs.mkdtempSync(path.join(tmpdir(), 'logDestTest'));
});
suiteTeardown(() => {
rmdirRecursive(tmpDir);
tryRmdirRecursive(tmpDir);
});

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

suiteTeardown(() => {
rmdirRecursive(tmpDir);
tryRmdirRecursive(tmpDir);
});

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

suiteTeardown(() => {
rmdirRecursive(goBuildOutput);
tryRmdirRecursive(goBuildOutput);
});

async function copyBuildDelete(program: string): Promise<{ program: string; output: string }> {
const wd = copyDirectory(program);
const output = await buildGoProgram(wd, path.join(goBuildOutput, program));
rmdirRecursive(wd);
tryRmdirRecursive(wd);
return { program: wd, output };
}

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

suiteTeardown(() => {
rmdirRecursive(helloWorldLocal);
tryRmdirRecursive(helloWorldLocal);
});

test('stopped for a breakpoint set during initialization using substitutePath (remote attach)', async () => {
Expand Down Expand Up @@ -2149,7 +2149,7 @@ const testAll = (ctx: Mocha.Context, isDlvDap: boolean, withConsole?: string) =>
});
suiteTeardown(() => {
fs.unlinkSync(symlinkPath);
rmdirRecursive(realPath);
tryRmdirRecursive(realPath);
});
test('should stop on a breakpoint', async function () {
if (!isDlvDap) this.skip(); // BUG: the legacy adapter fails with 'breakpoint verification mismatch' error.
Expand Down Expand Up @@ -2428,3 +2428,11 @@ class DelveDAPDebugAdapterOnSocket extends proxy.DelveDAPOutputAdapter {
function sleep(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
}

function tryRmdirRecursive(dir: string) {
try {
rmdirRecursive(dir);
} catch (e) {
console.log(`failed to delete ${dir}: ${e}`);
}
}

0 comments on commit 06ba506

Please sign in to comment.