Skip to content

Commit ef239bf

Browse files
authored
Update default debug configurations to enable live reloading (#2995)
For #2925
1 parent 52872ee commit ef239bf

File tree

8 files changed

+85
-37
lines changed

8 files changed

+85
-37
lines changed

news/1 Enhancements/2925.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update default flask and django debug configurations to enable live reloading.

package.json

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,10 @@
344344
"program": "^\"\\${workspaceFolder}/manage.py\"",
345345
"args": [
346346
"runserver",
347-
"--noreload",
348347
"--nothreading"
349348
],
350-
"django": true
349+
"django": true,
350+
"subProcess": true
351351
}
352352
},
353353
{
@@ -366,7 +366,8 @@
366366
"args": [
367367
"run"
368368
],
369-
"jinja": true
369+
"jinja": true,
370+
"subProcess": true
370371
}
371372
},
372373
{
@@ -570,6 +571,11 @@
570571
"type": "boolean",
571572
"description": "Whether debugging Pyramid applications",
572573
"default": false
574+
},
575+
"subProcess": {
576+
"type": "boolean",
577+
"description": "Whether to enable Sub Process debugging",
578+
"default": false
573579
}
574580
}
575581
},
@@ -641,6 +647,11 @@
641647
],
642648
"description": "Jinja template debugging (e.g. Flask).",
643649
"default": null
650+
},
651+
"subProcess": {
652+
"type": "boolean",
653+
"description": "Whether to enable Sub Process debugging",
654+
"default": false
644655
}
645656
}
646657
}
@@ -675,10 +686,10 @@
675686
"console": "integratedTerminal",
676687
"args": [
677688
"runserver",
678-
"--noreload",
679689
"--nothreading"
680690
],
681-
"django": true
691+
"django": true,
692+
"subProcess": true
682693
},
683694
{
684695
"name": "Python: Flask",
@@ -693,7 +704,8 @@
693704
"args": [
694705
"run"
695706
],
696-
"jinja": true
707+
"jinja": true,
708+
"subProcess": true
697709
},
698710
{
699711
"name": "Python: Current File (External Terminal)",

src/client/debugger/extension/configProviders/pythonV2Provider.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ export class PythonV2DebugConfigurationProvider extends BaseConfigurationProvide
4343
if (debugConfiguration.sudo) {
4444
this.debugOption(debugOptions, DebugOptions.Sudo);
4545
}
46+
if (debugConfiguration.subProcess === true) {
47+
this.debugOption(debugOptions, DebugOptions.SubProcess);
48+
}
4649
if (this.serviceContainer.get<IPlatformService>(IPlatformService).isWindows) {
4750
this.debugOption(debugOptions, DebugOptions.FixFilePathCase);
4851
}
@@ -71,6 +74,9 @@ export class PythonV2DebugConfigurationProvider extends BaseConfigurationProvide
7174
if (debugConfiguration.jinja) {
7275
this.debugOption(debugOptions, DebugOptions.Jinja);
7376
}
77+
if (debugConfiguration.subProcess === true) {
78+
this.debugOption(debugOptions, DebugOptions.SubProcess);
79+
}
7480
if (debugConfiguration.pyramid
7581
&& debugOptions.indexOf(DebugOptions.Jinja) === -1
7682
&& debugConfiguration.jinja !== false) {
@@ -140,7 +146,8 @@ export class PythonV2DebugConfigurationProvider extends BaseConfigurationProvide
140146
jinja: !!debugConfiguration.jinja,
141147
pyramid: !!debugConfiguration.pyramid,
142148
stopOnEntry: !!debugConfiguration.stopOnEntry,
143-
showReturnValue: !!debugConfiguration.showReturnValue
149+
showReturnValue: !!debugConfiguration.showReturnValue,
150+
subProcess: debugConfiguration.subProcess
144151
};
145152
sendTelemetryEvent(DEBUGGER, undefined, telemetryProps);
146153
}

src/client/debugger/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ export enum DebugOptions {
1818
WindowsClient = 'WindowsClient',
1919
UnixClient = 'UnixClient',
2020
StopOnEntry = 'StopOnEntry',
21-
ShowReturnValue = 'ShowReturnValue'
21+
ShowReturnValue = 'ShowReturnValue',
22+
SubProcess = 'Multiprocess'
2223
}
2324

2425
interface ICommonDebugArguments {
@@ -34,6 +35,7 @@ interface ICommonDebugArguments {
3435
host?: string;
3536
// Show return values of functions while stepping.
3637
showReturnValue?: boolean;
38+
subProcess?: boolean;
3739
}
3840
export interface IKnownAttachDebugArguments extends ICommonDebugArguments {
3941
workspaceFolder?: string;

src/client/telemetry/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export type DebuggerTelemetry = {
5959
stopOnEntry: boolean;
6060
showReturnValue: boolean;
6161
pyramid: boolean;
62+
subProcess: boolean;
6263
};
6364
export type DebuggerPerformanceTelemetry = {
6465
duration: number;

src/test/debugger/banner.unit.test.ts renamed to src/test/debugger/extension/banner.unit.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
import { expect } from 'chai';
99
import * as typemoq from 'typemoq';
1010
import { DebugSession } from 'vscode';
11-
import { IApplicationShell, IDebugService } from '../../client/common/application/types';
11+
import { IApplicationShell, IDebugService } from '../../../client/common/application/types';
1212
import { IBrowserService, IDisposableRegistry,
13-
ILogger, IPersistentState, IPersistentStateFactory, IRandom } from '../../client/common/types';
14-
import { DebuggerTypeName } from '../../client/debugger/constants';
15-
import { DebuggerBanner, PersistentStateKeys } from '../../client/debugger/extension/banner';
16-
import { IServiceContainer } from '../../client/ioc/types';
13+
ILogger, IPersistentState, IPersistentStateFactory, IRandom } from '../../../client/common/types';
14+
import { DebuggerTypeName } from '../../../client/debugger/constants';
15+
import { DebuggerBanner, PersistentStateKeys } from '../../../client/debugger/extension/banner';
16+
import { IServiceContainer } from '../../../client/ioc/types';
1717

1818
suite('Debugging - Banner', () => {
1919
let serviceContainer: typemoq.IMock<IServiceContainer>;

src/test/debugger/configProvider/provider.attach.unit.test.ts renamed to src/test/debugger/extension/configProvider/provider.attach.unit.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import { expect } from 'chai';
99
import * as path from 'path';
1010
import * as TypeMoq from 'typemoq';
1111
import { DebugConfiguration, DebugConfigurationProvider, TextDocument, TextEditor, Uri, WorkspaceFolder } from 'vscode';
12-
import { IDocumentManager, IWorkspaceService } from '../../../client/common/application/types';
13-
import { PYTHON_LANGUAGE } from '../../../client/common/constants';
14-
import { IFileSystem, IPlatformService } from '../../../client/common/platform/types';
15-
import { getNamesAndValues } from '../../../client/common/utils/enum';
16-
import { DebuggerTypeName } from '../../../client/debugger/constants';
17-
import { PythonV2DebugConfigurationProvider } from '../../../client/debugger/extension/configProviders/pythonV2Provider';
18-
import { AttachRequestArguments, DebugOptions } from '../../../client/debugger/types';
19-
import { IServiceContainer } from '../../../client/ioc/types';
12+
import { IDocumentManager, IWorkspaceService } from '../../../../client/common/application/types';
13+
import { PYTHON_LANGUAGE } from '../../../../client/common/constants';
14+
import { IFileSystem, IPlatformService } from '../../../../client/common/platform/types';
15+
import { getNamesAndValues } from '../../../../client/common/utils/enum';
16+
import { DebuggerTypeName } from '../../../../client/debugger/constants';
17+
import { PythonV2DebugConfigurationProvider } from '../../../../client/debugger/extension/configProviders/pythonV2Provider';
18+
import { AttachRequestArguments, DebugOptions } from '../../../../client/debugger/types';
19+
import { IServiceContainer } from '../../../../client/ioc/types';
2020

2121
enum OS {
2222
Windows,

src/test/debugger/configProvider/provider.unit.test.ts renamed to src/test/debugger/extension/configProvider/provider.unit.test.ts

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ import { expect } from 'chai';
99
import * as path from 'path';
1010
import * as TypeMoq from 'typemoq';
1111
import { DebugConfiguration, DebugConfigurationProvider, TextDocument, TextEditor, Uri, WorkspaceFolder } from 'vscode';
12-
import { InvalidPythonPathInDebuggerServiceId } from '../../../client/application/diagnostics/checks/invalidPythonPathInDebugger';
13-
import { IDiagnosticsService, IInvalidPythonPathInDebuggerService } from '../../../client/application/diagnostics/types';
14-
import { IApplicationShell, IDocumentManager, IWorkspaceService } from '../../../client/common/application/types';
15-
import { PYTHON_LANGUAGE } from '../../../client/common/constants';
16-
import { IFileSystem, IPlatformService } from '../../../client/common/platform/types';
17-
import { IPythonExecutionFactory, IPythonExecutionService } from '../../../client/common/process/types';
18-
import { IConfigurationService, ILogger, IPythonSettings } from '../../../client/common/types';
19-
import { DebuggerTypeName } from '../../../client/debugger/constants';
20-
import { ConfigurationProviderUtils } from '../../../client/debugger/extension/configProviders/configurationProviderUtils';
21-
import { PythonV2DebugConfigurationProvider } from '../../../client/debugger/extension/configProviders/pythonV2Provider';
22-
import { IConfigurationProviderUtils } from '../../../client/debugger/extension/configProviders/types';
23-
import { DebugOptions, LaunchRequestArguments } from '../../../client/debugger/types';
24-
import { IInterpreterHelper } from '../../../client/interpreter/contracts';
25-
import { IServiceContainer } from '../../../client/ioc/types';
26-
27-
suite('Debugging - Config Provider', () => {
12+
import { InvalidPythonPathInDebuggerServiceId } from '../../../../client/application/diagnostics/checks/invalidPythonPathInDebugger';
13+
import { IDiagnosticsService, IInvalidPythonPathInDebuggerService } from '../../../../client/application/diagnostics/types';
14+
import { IApplicationShell, IDocumentManager, IWorkspaceService } from '../../../../client/common/application/types';
15+
import { PYTHON_LANGUAGE } from '../../../../client/common/constants';
16+
import { IFileSystem, IPlatformService } from '../../../../client/common/platform/types';
17+
import { IPythonExecutionFactory, IPythonExecutionService } from '../../../../client/common/process/types';
18+
import { IConfigurationService, ILogger, IPythonSettings } from '../../../../client/common/types';
19+
import { DebuggerTypeName } from '../../../../client/debugger/constants';
20+
import { ConfigurationProviderUtils } from '../../../../client/debugger/extension/configProviders/configurationProviderUtils';
21+
import { PythonV2DebugConfigurationProvider } from '../../../../client/debugger/extension/configProviders/pythonV2Provider';
22+
import { IConfigurationProviderUtils } from '../../../../client/debugger/extension/configProviders/types';
23+
import { DebugOptions, LaunchRequestArguments } from '../../../../client/debugger/types';
24+
import { IInterpreterHelper } from '../../../../client/interpreter/contracts';
25+
import { IServiceContainer } from '../../../../client/ioc/types';
26+
27+
suite('Debuggingx - Config Provider', () => {
2828
let serviceContainer: TypeMoq.IMock<IServiceContainer>;
2929
let debugProvider: DebugConfigurationProvider;
3030
let platformService: TypeMoq.IMock<IPlatformService>;
@@ -60,6 +60,7 @@ suite('Debugging - Config Provider', () => {
6060
diagnosticsService
6161
.setup(h => h.validatePythonPath(TypeMoq.It.isAny(), TypeMoq.It.isAny()))
6262
.returns(() => Promise.resolve(true));
63+
const pythonSettings = TypeMoq.Mock.ofType<IPythonSettings>();
6364

6465
serviceContainer.setup(c => c.get(TypeMoq.It.isValue(IPythonExecutionFactory))).returns(() => factory.object);
6566
serviceContainer.setup(c => c.get(TypeMoq.It.isValue(IConfigurationService))).returns(() => confgService.object);
@@ -449,4 +450,28 @@ suite('Debugging - Config Provider', () => {
449450
diagnosticsService.verifyAll();
450451
expect(debugConfig).to.not.be.equal(undefined, 'is undefined');
451452
});
453+
async function testSetting(requestType: 'launch' | 'attach', settings: { [key: string]: boolean }, debugOptionName: DebugOptions, mustHaveDebugOption: boolean) {
454+
setupIoc('pythonPath');
455+
const debugConfiguration: DebugConfiguration = { request: requestType, type: 'python', name: '', ...settings };
456+
const workspaceFolder = createMoqWorkspaceFolder(__dirname);
457+
458+
459+
const debugConfig = await debugProvider.resolveDebugConfiguration!(workspaceFolder, debugConfiguration);
460+
if (mustHaveDebugOption) {
461+
expect((debugConfig as any).debugOptions).contains(debugOptionName);
462+
} else {
463+
expect((debugConfig as any).debugOptions).not.contains(debugOptionName);
464+
}
465+
}
466+
['launch', 'attach'].forEach((requestType: 'launch' | 'attach') => {
467+
test(`Must not contain Sub Process when not specified (${requestType})`, async () => {
468+
await testSetting(requestType, {}, DebugOptions.SubProcess, false);
469+
});
470+
test(`Must not contain Sub Process setting=false (${requestType})`, async () => {
471+
await testSetting(requestType, { subProcess: false }, DebugOptions.SubProcess, false);
472+
});
473+
test(`Must not contain Sub Process setting=true (${requestType})`, async () => {
474+
await testSetting(requestType, { subProcess: true }, DebugOptions.SubProcess, true);
475+
});
476+
});
452477
});

0 commit comments

Comments
 (0)