Skip to content

Commit

Permalink
ensure things get disposed and give time for resources to free (#3370)
Browse files Browse the repository at this point in the history
  • Loading branch information
gcampbell-msft authored Oct 9, 2023
1 parent 5e6d948 commit eee8703
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions test/extension-tests/successful-build/test/debugger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,17 @@ suite('Debug/Launch interface', () => {
const exists = fs.existsSync(createdFileOnExecution);
// Check that it is compiled as a new file
expect(exists).to.be.true;

terminal?.dispose();

// Needed to ensure things get disposed
await new Promise((resolve) => setTimeout(resolve, 3000));
}).timeout(60000);

test('Test launch same target multiple times when newTerminal run is enabled', async () => {
testEnv.config.updatePartial({
buildBeforeRun: false,
launchBehavior: 'newTerminal'
launchBehavior: "newTerminal"
});

const executablesTargets = await cmakeProject.executableTargets;
Expand All @@ -201,7 +206,10 @@ suite('Debug/Launch interface', () => {
expect(launchProgramPath).to.be.not.null;

// Remove file if exists
const createdFileOnExecution = path.join(path.dirname(launchProgramPath!), 'test.txt');
const createdFileOnExecution = path.join(
path.dirname(launchProgramPath!),
"test.txt"
);
if (fs.existsSync(createdFileOnExecution)) {
fs.unlinkSync(createdFileOnExecution);
}
Expand All @@ -212,16 +220,23 @@ suite('Debug/Launch interface', () => {

const term2 = await cmakeProject.launchTarget();
expect(term2).to.be.not.null;
expect(term2!.name).to.eq(`CMake/Launch - ${executablesTargets[0].name}`);
expect(term2!.name).to.eq(
`CMake/Launch - ${executablesTargets[0].name}`
);

const term2Pid = await term2?.processId;
expect(term1Pid).to.not.eq(term2Pid);
term1?.dispose();
term2?.dispose();

// Needed to ensure things get disposed
await new Promise((resolve) => setTimeout(resolve, 3000));
}).timeout(60000);

test('Test launch same target multiple times when newTerminal run is disabled', async () => {
testEnv.config.updatePartial({
buildBeforeRun: false,
launchBehavior: 'reuseTerminal'
launchBehavior: "reuseTerminal"
});

const executablesTargets = await cmakeProject.executableTargets;
Expand All @@ -232,7 +247,10 @@ suite('Debug/Launch interface', () => {
expect(launchProgramPath).to.be.not.null;

// Remove file if exists
const createdFileOnExecution = path.join(path.dirname(launchProgramPath!), 'test.txt');
const createdFileOnExecution = path.join(
path.dirname(launchProgramPath!),
"test.txt"
);
if (fs.existsSync(createdFileOnExecution)) {
fs.unlinkSync(createdFileOnExecution);
}
Expand All @@ -246,6 +264,11 @@ suite('Debug/Launch interface', () => {

const term2Pid = await term2?.processId;
expect(term1Pid).to.eq(term2Pid);
term1?.dispose();
term2?.dispose();

// Needed to ensure things get disposed
await new Promise((resolve) => setTimeout(resolve, 3000));
}).timeout(60000);
});

0 comments on commit eee8703

Please sign in to comment.