Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne committed Apr 18, 2018
1 parent c7e952a commit 10ca82b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
32 changes: 19 additions & 13 deletions src/client/debugger/configProviders/pythonV2Provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,53 +19,53 @@ export class PythonV2DebugConfigurationProvider extends BaseConfigurationProvide
super.provideLaunchDefaults(workspaceFolder, debugConfiguration);
const debugOptions = debugConfiguration.debugOptions!;
if (debugConfiguration.debugStdLib) {
debugOptions.push(DebugOptions.DebugStdLib);
this.debugOption(debugOptions, DebugOptions.DebugStdLib);
}
if (debugConfiguration.django) {
debugOptions.push(DebugOptions.Django);
this.debugOption(debugOptions, DebugOptions.Django);
}
if (debugConfiguration.jinja) {
debugOptions.push(DebugOptions.Jinja);
this.debugOption(debugOptions, DebugOptions.Jinja);
}
if (debugConfiguration.redirectOutput || debugConfiguration.redirectOutput === undefined) {
debugOptions.push(DebugOptions.RedirectOutput);
this.debugOption(debugOptions, DebugOptions.RedirectOutput);
}
if (debugConfiguration.sudo) {
debugOptions.push(DebugOptions.Sudo);
this.debugOption(debugOptions, DebugOptions.Sudo);
}
if (this.serviceContainer.get<IPlatformService>(IPlatformService).isWindows) {
debugOptions.push(DebugOptions.FixFilePathCase);
this.debugOption(debugOptions, DebugOptions.FixFilePathCase);
}
if (debugConfiguration.module && debugConfiguration.module.toUpperCase() === 'FLASK'
&& debugOptions.indexOf(DebugOptions.Jinja) === -1
&& debugConfiguration.jinja !== false) {
debugOptions.push(DebugOptions.Jinja);
this.debugOption(debugOptions, DebugOptions.Jinja);
}
}
protected provideAttachDefaults(workspaceFolder: Uri, debugConfiguration: PythonAttachDebugConfiguration<AttachRequestArguments>): void {
super.provideAttachDefaults(workspaceFolder, debugConfiguration);
const debugOptions = debugConfiguration.debugOptions!;
if (debugConfiguration.debugStdLib) {
debugOptions.push(DebugOptions.DebugStdLib);
this.debugOption(debugOptions, DebugOptions.DebugStdLib);
}
if (debugConfiguration.django) {
debugOptions.push(DebugOptions.Django);
this.debugOption(debugOptions, DebugOptions.Django);
}
if (debugConfiguration.jinja) {
debugOptions.push(DebugOptions.Jinja);
this.debugOption(debugOptions, DebugOptions.Jinja);
}
if (debugConfiguration.redirectOutput || debugConfiguration.redirectOutput === undefined) {
debugOptions.push(DebugOptions.RedirectOutput);
this.debugOption(debugOptions, DebugOptions.RedirectOutput);
}

// We'll need paths to be fixed only in the case where local and remote hosts are the same
// I.e. only if hostName === 'localhost' or '127.0.0.1' or ''
const isLocalHost = !debugConfiguration.host || debugConfiguration.host === 'localhost' || debugConfiguration.host === '127.0.0.1';
if (this.serviceContainer.get<IPlatformService>(IPlatformService).isWindows && isLocalHost) {
debugOptions.push(DebugOptions.FixFilePathCase);
this.debugOption(debugOptions, DebugOptions.FixFilePathCase);
}
if (this.serviceContainer.get<IPlatformService>(IPlatformService).isWindows) {
debugOptions.push(DebugOptions.WindowsClient);
this.debugOption(debugOptions, DebugOptions.WindowsClient);
}

if (!debugConfiguration.pathMappings) {
Expand All @@ -78,4 +78,10 @@ export class PythonV2DebugConfigurationProvider extends BaseConfigurationProvide
});
}
}
private debugOption(debugOptions: DebugOptions[], debugOption: DebugOptions) {
if (debugOptions.indexOf(debugOption) >= 0) {
return;
}
debugOptions.push(debugOption);
}
}
3 changes: 2 additions & 1 deletion src/test/debugger/configProvider/provider.attach.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,10 @@ enum OS {
setupWorkspaces([defaultWorkspace]);

const debugOptions = debugOptionsAvailable.slice().concat(DebugOptions.Jinja, DebugOptions.Sudo);
const expectedDebugOptions = debugOptions.slice();
const debugConfig = await debugProvider.resolveDebugConfiguration!(workspaceFolder, { debugOptions, request: 'attach' } as any as DebugConfiguration);

expect(debugConfig).to.have.property('debugOptions').to.be.deep.equal(debugOptions);
expect(debugConfig).to.have.property('debugOptions').to.be.deep.equal(expectedDebugOptions);
});
});
});
Expand Down

0 comments on commit 10ca82b

Please sign in to comment.