From 32d9c88a384ad90c3345244dd6ccdf2897bcf1af Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Mon, 12 Feb 2024 12:46:21 -0800 Subject: [PATCH 1/5] Update type python to debugpy in testing --- src/client/debugger/constants.ts | 2 ++ src/client/debugger/types.ts | 6 +++--- src/client/testing/common/debugLauncher.ts | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/client/debugger/constants.ts b/src/client/debugger/constants.ts index 08b8619ce03a..12773c04c399 100644 --- a/src/client/debugger/constants.ts +++ b/src/client/debugger/constants.ts @@ -4,3 +4,5 @@ 'use strict'; export const DebuggerTypeName = 'python'; +export const PythonDebuggerTypeName = 'debugpy'; + diff --git a/src/client/debugger/types.ts b/src/client/debugger/types.ts index 3e884cf8f64f..80585ba7d87b 100644 --- a/src/client/debugger/types.ts +++ b/src/client/debugger/types.ts @@ -5,7 +5,7 @@ import { DebugConfiguration } from 'vscode'; import { DebugProtocol } from 'vscode-debugprotocol/lib/debugProtocol'; -import { DebuggerTypeName } from './constants'; +import { DebuggerTypeName, PythonDebuggerTypeName } from './constants'; export enum DebugOptions { RedirectOutput = 'RedirectOutput', @@ -123,14 +123,14 @@ export interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArguments, IKnownLaunchRequestArguments, DebugConfiguration { - type: typeof DebuggerTypeName; + type: typeof DebuggerTypeName | typeof PythonDebuggerTypeName; } export interface AttachRequestArguments extends DebugProtocol.AttachRequestArguments, IKnownAttachDebugArguments, DebugConfiguration { - type: typeof DebuggerTypeName; + type: typeof DebuggerTypeName | typeof PythonDebuggerTypeName; } export interface DebugConfigurationArguments extends LaunchRequestArguments, AttachRequestArguments {} diff --git a/src/client/testing/common/debugLauncher.ts b/src/client/testing/common/debugLauncher.ts index c76557699ff2..85076461f22e 100644 --- a/src/client/testing/common/debugLauncher.ts +++ b/src/client/testing/common/debugLauncher.ts @@ -5,7 +5,7 @@ import { IApplicationShell, IDebugService } from '../../common/application/types import { EXTENSION_ROOT_DIR } from '../../common/constants'; import * as internalScripts from '../../common/process/internal/scripts'; import { IConfigurationService, IPythonSettings } from '../../common/types'; -import { DebuggerTypeName } from '../../debugger/constants'; +import { DebuggerTypeName, PythonDebuggerTypeName } from '../../debugger/constants'; import { IDebugConfigurationResolver } from '../../debugger/extension/configuration/types'; import { DebugPurpose, LaunchRequestArguments } from '../../debugger/types'; import { IServiceContainer } from '../../ioc/types'; @@ -78,7 +78,7 @@ export class DebugLauncher implements ITestDebugLauncher { if (!debugConfig) { debugConfig = { name: 'Debug Unit Test', - type: 'python', + type: 'debugpy', request: 'test', subProcess: true, }; @@ -118,7 +118,7 @@ export class DebugLauncher implements ITestDebugLauncher { for (const cfg of configs) { if ( cfg.name && - cfg.type === DebuggerTypeName && + (cfg.type === DebuggerTypeName || cfg.type === PythonDebuggerTypeName) && (cfg.request === 'test' || (cfg as LaunchRequestArguments).purpose?.includes(DebugPurpose.DebugTest)) ) { From 019e79415e876afff972ad6cf7e3f6a4e0d08ebe Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Mon, 12 Feb 2024 12:46:27 -0800 Subject: [PATCH 2/5] fix tests --- .../testing/common/debugLauncher.unit.test.ts | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/test/testing/common/debugLauncher.unit.test.ts b/src/test/testing/common/debugLauncher.unit.test.ts index bbb65f0b2e2a..1c69bac20593 100644 --- a/src/test/testing/common/debugLauncher.unit.test.ts +++ b/src/test/testing/common/debugLauncher.unit.test.ts @@ -16,7 +16,7 @@ import { IApplicationShell, IDebugService } from '../../../client/common/applica import { EXTENSION_ROOT_DIR } from '../../../client/common/constants'; import '../../../client/common/extensions'; import { IConfigurationService, IPythonSettings } from '../../../client/common/types'; -import { DebuggerTypeName } from '../../../client/debugger/constants'; +import { PythonDebuggerTypeName } from '../../../client/debugger/constants'; import { IDebugEnvironmentVariablesService } from '../../../client/debugger/extension/configuration/resolvers/helper'; import { LaunchConfigurationResolver } from '../../../client/debugger/extension/configuration/resolvers/launch'; import { DebugOptions } from '../../../client/debugger/types'; @@ -166,7 +166,7 @@ suite('Unit Tests - Debug Launcher', () => { function getDefaultDebugConfig(): DebugConfiguration { return { name: 'Debug Unit Test', - type: DebuggerTypeName, + type: PythonDebuggerTypeName, request: 'launch', console: 'internalConsole', env: {}, @@ -329,7 +329,7 @@ suite('Unit Tests - Debug Launcher', () => { }; const expected = getDefaultDebugConfig(); expected.name = 'spam'; - setupSuccess(options, 'unittest', expected, [{ name: 'spam', type: DebuggerTypeName, request: 'test' }]); + setupSuccess(options, 'unittest', expected, [{ name: 'spam', type: PythonDebuggerTypeName, request: 'test' }]); await debugLauncher.launchDebugger(options); @@ -363,7 +363,7 @@ suite('Unit Tests - Debug Launcher', () => { }; const expected = { name: 'my tests', - type: DebuggerTypeName, + type: PythonDebuggerTypeName, request: 'launch', python: 'some/dir/bin/py3', debugAdapterPython: 'some/dir/bin/py3', @@ -388,7 +388,7 @@ suite('Unit Tests - Debug Launcher', () => { setupSuccess(options, 'unittest', expected, [ { name: 'my tests', - type: DebuggerTypeName, + type: PythonDebuggerTypeName, request: 'test', pythonPath: expected.python, stopOnEntry: expected.stopOnEntry, @@ -417,9 +417,9 @@ suite('Unit Tests - Debug Launcher', () => { const expected = getDefaultDebugConfig(); expected.name = 'spam1'; setupSuccess(options, 'unittest', expected, [ - { name: 'spam1', type: DebuggerTypeName, request: 'test' }, - { name: 'spam2', type: DebuggerTypeName, request: 'test' }, - { name: 'spam3', type: DebuggerTypeName, request: 'test' }, + { name: 'spam1', type: PythonDebuggerTypeName, request: 'test' }, + { name: 'spam2', type: PythonDebuggerTypeName, request: 'test' }, + { name: 'spam3', type: PythonDebuggerTypeName, request: 'test' }, ]); await debugLauncher.launchDebugger(options); @@ -446,7 +446,7 @@ suite('Unit Tests - Debug Launcher', () => { '// test 2 \n\ { \n\ "name": "spam", \n\ - "type": "python", \n\ + "type": "debugpy", \n\ "request": "test" \n\ } \n\ ', @@ -454,7 +454,7 @@ suite('Unit Tests - Debug Launcher', () => { [ \n\ { \n\ "name": "spam", \n\ - "type": "python", \n\ + "type": "debugpy", \n\ "request": "test" \n\ } \n\ ] \n\ @@ -464,7 +464,7 @@ suite('Unit Tests - Debug Launcher', () => { "configurations": [ \n\ { \n\ "name": "spam", \n\ - "type": "python", \n\ + "type": "debugpy", \n\ "request": "test" \n\ } \n\ ] \n\ @@ -499,10 +499,10 @@ suite('Unit Tests - Debug Launcher', () => { setupSuccess(options, 'unittest', expected, [ {} as DebugConfiguration, { name: 'spam1' } as DebugConfiguration, - { name: 'spam2', type: DebuggerTypeName } as DebugConfiguration, + { name: 'spam2', type: PythonDebuggerTypeName } as DebugConfiguration, { name: 'spam3', request: 'test' } as DebugConfiguration, - { type: DebuggerTypeName } as DebugConfiguration, - { type: DebuggerTypeName, request: 'test' } as DebugConfiguration, + { type: PythonDebuggerTypeName } as DebugConfiguration, + { type: PythonDebuggerTypeName, request: 'test' } as DebugConfiguration, { request: 'test' } as DebugConfiguration, ]); @@ -532,7 +532,7 @@ suite('Unit Tests - Debug Launcher', () => { testProvider: 'unittest', }; const expected = getDefaultDebugConfig(); - setupSuccess(options, 'unittest', expected, [{ name: 'spam', type: DebuggerTypeName, request: 'bogus' }]); + setupSuccess(options, 'unittest', expected, [{ name: 'spam', type: PythonDebuggerTypeName, request: 'bogus' }]); await debugLauncher.launchDebugger(options); @@ -547,8 +547,8 @@ suite('Unit Tests - Debug Launcher', () => { }; const expected = getDefaultDebugConfig(); setupSuccess(options, 'unittest', expected, [ - { name: 'spam', type: DebuggerTypeName, request: 'launch' }, - { name: 'spam', type: DebuggerTypeName, request: 'attach' }, + { name: 'spam', type: PythonDebuggerTypeName, request: 'launch' }, + { name: 'spam', type: PythonDebuggerTypeName, request: 'attach' }, ]); await debugLauncher.launchDebugger(options); @@ -567,9 +567,9 @@ suite('Unit Tests - Debug Launcher', () => { setupSuccess(options, 'unittest', expected, [ { name: 'foo1', type: 'other', request: 'bar' }, { name: 'foo2', type: 'other', request: 'bar' }, - { name: 'spam1', type: DebuggerTypeName, request: 'launch' }, - { name: 'spam2', type: DebuggerTypeName, request: 'test' }, - { name: 'spam3', type: DebuggerTypeName, request: 'attach' }, + { name: 'spam1', type: PythonDebuggerTypeName, request: 'launch' }, + { name: 'spam2', type: PythonDebuggerTypeName, request: 'test' }, + { name: 'spam3', type: PythonDebuggerTypeName, request: 'attach' }, { name: 'xyz', type: 'another', request: 'abc' }, ]); @@ -599,7 +599,7 @@ suite('Unit Tests - Debug Launcher', () => { { \n\ // "test" debug config \n\ "name": "spam", /* non-empty */ \n\ - "type": "python", /* must be "python" */ \n\ + "type": "debugpy", /* must be "python" */ \n\ "request": "test", /* must be "test" */ \n\ // extra stuff here: \n\ "stopOnEntry": true \n\ From 5fe3bf875db77fc77759bbc0e03ed67378c6bef9 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Mon, 12 Feb 2024 12:46:21 -0800 Subject: [PATCH 3/5] Update type python to debugpy in testing --- src/client/debugger/constants.ts | 2 ++ src/client/debugger/types.ts | 6 +++--- src/client/testing/common/debugLauncher.ts | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/client/debugger/constants.ts b/src/client/debugger/constants.ts index 08b8619ce03a..12773c04c399 100644 --- a/src/client/debugger/constants.ts +++ b/src/client/debugger/constants.ts @@ -4,3 +4,5 @@ 'use strict'; export const DebuggerTypeName = 'python'; +export const PythonDebuggerTypeName = 'debugpy'; + diff --git a/src/client/debugger/types.ts b/src/client/debugger/types.ts index 3e884cf8f64f..80585ba7d87b 100644 --- a/src/client/debugger/types.ts +++ b/src/client/debugger/types.ts @@ -5,7 +5,7 @@ import { DebugConfiguration } from 'vscode'; import { DebugProtocol } from 'vscode-debugprotocol/lib/debugProtocol'; -import { DebuggerTypeName } from './constants'; +import { DebuggerTypeName, PythonDebuggerTypeName } from './constants'; export enum DebugOptions { RedirectOutput = 'RedirectOutput', @@ -123,14 +123,14 @@ export interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArguments, IKnownLaunchRequestArguments, DebugConfiguration { - type: typeof DebuggerTypeName; + type: typeof DebuggerTypeName | typeof PythonDebuggerTypeName; } export interface AttachRequestArguments extends DebugProtocol.AttachRequestArguments, IKnownAttachDebugArguments, DebugConfiguration { - type: typeof DebuggerTypeName; + type: typeof DebuggerTypeName | typeof PythonDebuggerTypeName; } export interface DebugConfigurationArguments extends LaunchRequestArguments, AttachRequestArguments {} diff --git a/src/client/testing/common/debugLauncher.ts b/src/client/testing/common/debugLauncher.ts index c76557699ff2..85076461f22e 100644 --- a/src/client/testing/common/debugLauncher.ts +++ b/src/client/testing/common/debugLauncher.ts @@ -5,7 +5,7 @@ import { IApplicationShell, IDebugService } from '../../common/application/types import { EXTENSION_ROOT_DIR } from '../../common/constants'; import * as internalScripts from '../../common/process/internal/scripts'; import { IConfigurationService, IPythonSettings } from '../../common/types'; -import { DebuggerTypeName } from '../../debugger/constants'; +import { DebuggerTypeName, PythonDebuggerTypeName } from '../../debugger/constants'; import { IDebugConfigurationResolver } from '../../debugger/extension/configuration/types'; import { DebugPurpose, LaunchRequestArguments } from '../../debugger/types'; import { IServiceContainer } from '../../ioc/types'; @@ -78,7 +78,7 @@ export class DebugLauncher implements ITestDebugLauncher { if (!debugConfig) { debugConfig = { name: 'Debug Unit Test', - type: 'python', + type: 'debugpy', request: 'test', subProcess: true, }; @@ -118,7 +118,7 @@ export class DebugLauncher implements ITestDebugLauncher { for (const cfg of configs) { if ( cfg.name && - cfg.type === DebuggerTypeName && + (cfg.type === DebuggerTypeName || cfg.type === PythonDebuggerTypeName) && (cfg.request === 'test' || (cfg as LaunchRequestArguments).purpose?.includes(DebugPurpose.DebugTest)) ) { From e58ce0209b92c3ac08ab0a66afffb77b0ea0ad31 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Mon, 12 Feb 2024 12:46:27 -0800 Subject: [PATCH 4/5] fix tests --- .../testing/common/debugLauncher.unit.test.ts | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/test/testing/common/debugLauncher.unit.test.ts b/src/test/testing/common/debugLauncher.unit.test.ts index bbb65f0b2e2a..1c69bac20593 100644 --- a/src/test/testing/common/debugLauncher.unit.test.ts +++ b/src/test/testing/common/debugLauncher.unit.test.ts @@ -16,7 +16,7 @@ import { IApplicationShell, IDebugService } from '../../../client/common/applica import { EXTENSION_ROOT_DIR } from '../../../client/common/constants'; import '../../../client/common/extensions'; import { IConfigurationService, IPythonSettings } from '../../../client/common/types'; -import { DebuggerTypeName } from '../../../client/debugger/constants'; +import { PythonDebuggerTypeName } from '../../../client/debugger/constants'; import { IDebugEnvironmentVariablesService } from '../../../client/debugger/extension/configuration/resolvers/helper'; import { LaunchConfigurationResolver } from '../../../client/debugger/extension/configuration/resolvers/launch'; import { DebugOptions } from '../../../client/debugger/types'; @@ -166,7 +166,7 @@ suite('Unit Tests - Debug Launcher', () => { function getDefaultDebugConfig(): DebugConfiguration { return { name: 'Debug Unit Test', - type: DebuggerTypeName, + type: PythonDebuggerTypeName, request: 'launch', console: 'internalConsole', env: {}, @@ -329,7 +329,7 @@ suite('Unit Tests - Debug Launcher', () => { }; const expected = getDefaultDebugConfig(); expected.name = 'spam'; - setupSuccess(options, 'unittest', expected, [{ name: 'spam', type: DebuggerTypeName, request: 'test' }]); + setupSuccess(options, 'unittest', expected, [{ name: 'spam', type: PythonDebuggerTypeName, request: 'test' }]); await debugLauncher.launchDebugger(options); @@ -363,7 +363,7 @@ suite('Unit Tests - Debug Launcher', () => { }; const expected = { name: 'my tests', - type: DebuggerTypeName, + type: PythonDebuggerTypeName, request: 'launch', python: 'some/dir/bin/py3', debugAdapterPython: 'some/dir/bin/py3', @@ -388,7 +388,7 @@ suite('Unit Tests - Debug Launcher', () => { setupSuccess(options, 'unittest', expected, [ { name: 'my tests', - type: DebuggerTypeName, + type: PythonDebuggerTypeName, request: 'test', pythonPath: expected.python, stopOnEntry: expected.stopOnEntry, @@ -417,9 +417,9 @@ suite('Unit Tests - Debug Launcher', () => { const expected = getDefaultDebugConfig(); expected.name = 'spam1'; setupSuccess(options, 'unittest', expected, [ - { name: 'spam1', type: DebuggerTypeName, request: 'test' }, - { name: 'spam2', type: DebuggerTypeName, request: 'test' }, - { name: 'spam3', type: DebuggerTypeName, request: 'test' }, + { name: 'spam1', type: PythonDebuggerTypeName, request: 'test' }, + { name: 'spam2', type: PythonDebuggerTypeName, request: 'test' }, + { name: 'spam3', type: PythonDebuggerTypeName, request: 'test' }, ]); await debugLauncher.launchDebugger(options); @@ -446,7 +446,7 @@ suite('Unit Tests - Debug Launcher', () => { '// test 2 \n\ { \n\ "name": "spam", \n\ - "type": "python", \n\ + "type": "debugpy", \n\ "request": "test" \n\ } \n\ ', @@ -454,7 +454,7 @@ suite('Unit Tests - Debug Launcher', () => { [ \n\ { \n\ "name": "spam", \n\ - "type": "python", \n\ + "type": "debugpy", \n\ "request": "test" \n\ } \n\ ] \n\ @@ -464,7 +464,7 @@ suite('Unit Tests - Debug Launcher', () => { "configurations": [ \n\ { \n\ "name": "spam", \n\ - "type": "python", \n\ + "type": "debugpy", \n\ "request": "test" \n\ } \n\ ] \n\ @@ -499,10 +499,10 @@ suite('Unit Tests - Debug Launcher', () => { setupSuccess(options, 'unittest', expected, [ {} as DebugConfiguration, { name: 'spam1' } as DebugConfiguration, - { name: 'spam2', type: DebuggerTypeName } as DebugConfiguration, + { name: 'spam2', type: PythonDebuggerTypeName } as DebugConfiguration, { name: 'spam3', request: 'test' } as DebugConfiguration, - { type: DebuggerTypeName } as DebugConfiguration, - { type: DebuggerTypeName, request: 'test' } as DebugConfiguration, + { type: PythonDebuggerTypeName } as DebugConfiguration, + { type: PythonDebuggerTypeName, request: 'test' } as DebugConfiguration, { request: 'test' } as DebugConfiguration, ]); @@ -532,7 +532,7 @@ suite('Unit Tests - Debug Launcher', () => { testProvider: 'unittest', }; const expected = getDefaultDebugConfig(); - setupSuccess(options, 'unittest', expected, [{ name: 'spam', type: DebuggerTypeName, request: 'bogus' }]); + setupSuccess(options, 'unittest', expected, [{ name: 'spam', type: PythonDebuggerTypeName, request: 'bogus' }]); await debugLauncher.launchDebugger(options); @@ -547,8 +547,8 @@ suite('Unit Tests - Debug Launcher', () => { }; const expected = getDefaultDebugConfig(); setupSuccess(options, 'unittest', expected, [ - { name: 'spam', type: DebuggerTypeName, request: 'launch' }, - { name: 'spam', type: DebuggerTypeName, request: 'attach' }, + { name: 'spam', type: PythonDebuggerTypeName, request: 'launch' }, + { name: 'spam', type: PythonDebuggerTypeName, request: 'attach' }, ]); await debugLauncher.launchDebugger(options); @@ -567,9 +567,9 @@ suite('Unit Tests - Debug Launcher', () => { setupSuccess(options, 'unittest', expected, [ { name: 'foo1', type: 'other', request: 'bar' }, { name: 'foo2', type: 'other', request: 'bar' }, - { name: 'spam1', type: DebuggerTypeName, request: 'launch' }, - { name: 'spam2', type: DebuggerTypeName, request: 'test' }, - { name: 'spam3', type: DebuggerTypeName, request: 'attach' }, + { name: 'spam1', type: PythonDebuggerTypeName, request: 'launch' }, + { name: 'spam2', type: PythonDebuggerTypeName, request: 'test' }, + { name: 'spam3', type: PythonDebuggerTypeName, request: 'attach' }, { name: 'xyz', type: 'another', request: 'abc' }, ]); @@ -599,7 +599,7 @@ suite('Unit Tests - Debug Launcher', () => { { \n\ // "test" debug config \n\ "name": "spam", /* non-empty */ \n\ - "type": "python", /* must be "python" */ \n\ + "type": "debugpy", /* must be "python" */ \n\ "request": "test", /* must be "test" */ \n\ // extra stuff here: \n\ "stopOnEntry": true \n\ From 3f53a01d365c9e0890686b7c31e115f0e2e72106 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Mon, 12 Feb 2024 13:19:04 -0800 Subject: [PATCH 5/5] fix lint --- src/client/debugger/constants.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/client/debugger/constants.ts b/src/client/debugger/constants.ts index 12773c04c399..a2ac198a597d 100644 --- a/src/client/debugger/constants.ts +++ b/src/client/debugger/constants.ts @@ -5,4 +5,3 @@ export const DebuggerTypeName = 'python'; export const PythonDebuggerTypeName = 'debugpy'; -