Skip to content

Commit 42f27be

Browse files
committed
Do not throw error in launch.json does not exist (#4536)
For #332
1 parent ad0fb7c commit 42f27be

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/client/unittests/common/debugLauncher.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ export class DebugLauncher implements ITestDebugLauncher {
9393
const workspaceFolder = this.workspaceService.workspaceFolders![0];
9494
const filename = path.join(workspaceFolder.uri.fsPath, '.vscode', 'launch.json');
9595
let configs: DebugConfiguration[] = [];
96+
if (!(await this.fs.fileExists(filename))) {
97+
return [];
98+
}
9699
try {
97100
let text = await this.fs.readFile(filename);
98101
text = stripJsonComments(text);
@@ -105,7 +108,7 @@ export class DebugLauncher implements ITestDebugLauncher {
105108
} catch (exc) {
106109
traceError('could not get debug config', exc);
107110
const appShell = this.serviceContainer.get<IApplicationShell>(IApplicationShell);
108-
await appShell.showErrorMessage('could not load unit test config from launch.json');
111+
await appShell.showErrorMessage('Could not load unit test config from launch.json');
109112
}
110113
return configs;
111114
}

src/test/unittests/common/debugLauncher.unit.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,11 @@ suite('Unit Tests - Debug Launcher', () => {
175175
.returns(() => workspaceFolders[0]);
176176

177177
if (!debugConfigs) {
178-
filesystem.setup(fs => fs.readFile(TypeMoq.It.isAny()))
179-
.throws(new Error('file not found'));
178+
filesystem.setup(fs => fs.fileExists(TypeMoq.It.isAny()))
179+
.returns(() => Promise.resolve(false));
180180
} else {
181+
filesystem.setup(fs => fs.fileExists(TypeMoq.It.isAny()))
182+
.returns(() => Promise.resolve(true));
181183
if (typeof debugConfigs !== 'string') {
182184
debugConfigs = JSON.stringify({
183185
version: '0.1.0',

0 commit comments

Comments
 (0)