From 8b7d7aecdad6bfd315608a4a3318d4b02499492b Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Fri, 3 Jun 2022 10:54:34 +1000 Subject: [PATCH] Fixed tests --- .../codeExecution/codeExecutionHelper.node.ts | 2 +- .../interactiveDebugging.vscode.common.ts | 58 +- .../interactiveDebugging.vscode.test.ts | 613 ++---------------- .../interactiveDebugging.vscode.web.test.ts | 12 - 4 files changed, 53 insertions(+), 632 deletions(-) delete mode 100644 src/test/datascience/interactiveDebugging.vscode.web.test.ts diff --git a/src/platform/terminals/codeExecution/codeExecutionHelper.node.ts b/src/platform/terminals/codeExecution/codeExecutionHelper.node.ts index 2885d58fe156..5ac5ee7f9966 100644 --- a/src/platform/terminals/codeExecution/codeExecutionHelper.node.ts +++ b/src/platform/terminals/codeExecution/codeExecutionHelper.node.ts @@ -77,7 +77,7 @@ export class CodeExecutionHelper extends CodeExecutionHelperBase { if (indexOfFirstNonEmptyLineInOriginalCode > indexOfFirstNonEmptyLineInNormalizedCode) { // Some white space has been trimmed, add them back. const trimmedLineCount = - indexOfFirstNonEmptyLineInOriginalCode - indexOfFirstNonEmptyLineInNormalizedCode; + indexOfFirstNonEmptyLineInOriginalCode - indexOfFirstNonEmptyLineInNormalizedCode; return `${'\n'.repeat(trimmedLineCount)}${normalizedLines}`; } return normalizedLines; diff --git a/src/test/datascience/interactiveDebugging.vscode.common.ts b/src/test/datascience/interactiveDebugging.vscode.common.ts index d86aab6b08ec..2f23009fd7d0 100644 --- a/src/test/datascience/interactiveDebugging.vscode.common.ts +++ b/src/test/datascience/interactiveDebugging.vscode.common.ts @@ -3,15 +3,13 @@ 'use strict'; -import * as path from '../../platform/vscode-path/path'; -import * as fs from 'fs-extra'; import { assert } from 'chai'; import * as sinon from 'sinon'; import * as vscode from 'vscode'; import { traceInfo } from '../../platform/logging'; import { IDisposable } from '../../platform/common/types'; import { InteractiveWindowProvider } from '../../interactive-window/interactiveWindowProvider'; -import { captureScreenShot, IExtensionTestApi, waitForCondition } from '../common.node'; +import { IExtensionTestApi, waitForCondition } from '../common'; import { initialize, IS_REMOTE_NATIVE_TEST } from '../initialize.node'; import { submitFromPythonFile, @@ -27,15 +25,17 @@ import { IInteractiveWindowProvider } from '../../interactive-window/types'; import { Commands } from '../../platform/common/constants'; import { IVariableViewProvider } from '../../webviews/extension-side/variablesView/types'; import { pythonIWKernelDebugAdapter } from '../../kernels/debugger/constants'; -import { EXTENSION_ROOT_DIR } from '../../platform/constants.node'; + +export type DebuggerType = 'VSCodePythonDebugger' | 'JupyterProtocolDebugger'; export function sharedIWDebuggerTests( this: Mocha.Suite, options: { startJupyterServer: (notebook?: vscode.NotebookDocument) => Promise; + suiteSetup?: (debuggerType: DebuggerType) => Promise; + captureScreenShot?: (title: string) => Promise; } ) { - type DebuggerType = 'VSCodePythonDebugger' | 'JupyterProtocolDebugger'; const debuggerTypes: DebuggerType[] = ['VSCodePythonDebugger', 'JupyterProtocolDebugger']; debuggerTypes.forEach((debuggerType) => { suite(`Debugging with ${debuggerType}`, async function () { @@ -52,49 +52,13 @@ export function sharedIWDebuggerTests( return debugAdapterTracker; } }; - const settingsFile = path.join( - EXTENSION_ROOT_DIR, - 'src', - 'test', - 'datascience', - '.vscode', - 'settings.json' - ); - function enableJupyterDebugger(enable: boolean) { - const settingFileContents = fs.readFileSync(settingsFile).toString(); - if (enable && settingFileContents.includes(`"jupyter.forceIPyKernelDebugger": true`)) { - return; - } else if (enable && settingFileContents.includes(`"jupyter.forceIPyKernelDebugger": false`)) { - fs.writeFileSync( - settingsFile, - settingFileContents.replace( - `"jupyter.forceIPyKernelDebugger": false`, - `"jupyter.forceIPyKernelDebugger": true` - ) - ); - return; - } else if (enable && !settingFileContents.includes(`"jupyter.forceIPyKernelDebugger": true`)) { - throw new Error('Unable to update settings file'); - } else if (!enable && settingFileContents.includes(`"jupyter.forceIPyKernelDebugger": true`)) { - fs.writeFileSync( - settingsFile, - settingFileContents.replace( - `"jupyter.forceIPyKernelDebugger": true`, - `"jupyter.forceIPyKernelDebugger": false` - ) - ); - return; - } else if (!enable && settingFileContents.includes(`"jupyter.forceIPyKernelDebugger": false`)) { - return; - } else if (!enable && !settingFileContents.includes(`"jupyter.forceIPyKernelDebugger": true`)) { - throw new Error('Unable to update settings file'); - } - } - suiteSetup(function () { + suiteSetup(async function () { if (IS_REMOTE_NATIVE_TEST() && debuggerType === 'VSCodePythonDebugger') { return this.skip(); } - enableJupyterDebugger(debuggerType === 'JupyterProtocolDebugger'); + if (options.suiteSetup) { + await options.suiteSetup(debuggerType); + } }); suiteTeardown(() => vscode.commands.executeCommand('workbench.debug.viewlet.action.removeAllBreakpoints')); setup(async function () { @@ -128,8 +92,8 @@ export function sharedIWDebuggerTests( ); traceInfo(`Ended Test ${this.currentTest?.title}`); - if (this.currentTest?.isFailed()) { - await captureScreenShot(this.currentTest?.title); + if (this.currentTest?.isFailed() && options.captureScreenShot) { + await options.captureScreenShot(this.currentTest?.title); } sinon.restore(); debugAdapterTracker = undefined; diff --git a/src/test/datascience/interactiveDebugging.vscode.test.ts b/src/test/datascience/interactiveDebugging.vscode.test.ts index f1df2ab05ff9..737af206497b 100644 --- a/src/test/datascience/interactiveDebugging.vscode.test.ts +++ b/src/test/datascience/interactiveDebugging.vscode.test.ts @@ -3,577 +3,46 @@ 'use strict'; -import { assert } from 'chai'; -import * as sinon from 'sinon'; -import * as vscode from 'vscode'; -import { traceInfo } from '../../platform/logging'; -import { IDisposable } from '../../platform/common/types'; -import { InteractiveWindowProvider } from '../../interactive-window/interactiveWindowProvider'; -import { captureScreenShot, IExtensionTestApi, waitForCondition } from '../common.node'; -import { initialize, IS_REMOTE_NATIVE_TEST } from '../initialize.node'; -import { - submitFromPythonFile, - submitFromPythonFileUsingCodeWatcher, - waitForCodeLenses, - waitForLastCellToComplete -} from './helpers.node'; -import { closeNotebooksAndCleanUpAfterTests, defaultNotebookTestTimeout, getCellOutputs } from './notebook/helper.node'; -import { ITestWebviewHost } from './testInterfaces'; -import { waitForVariablesToMatch } from './variableView/variableViewHelpers'; -import { ITestVariableViewProvider } from './variableView/variableViewTestInterfaces'; -import { IInteractiveWindowProvider } from '../../interactive-window/types'; -import { Commands } from '../../platform/common/constants'; -import { IVariableViewProvider } from '../../webviews/extension-side/variablesView/types'; -import { pythonIWKernelDebugAdapter } from '../../kernels/debugger/constants'; - -suite('Interactive window debugging', async function () { - this.timeout(120_000); - let api: IExtensionTestApi; - const disposables: IDisposable[] = []; - let interactiveWindowProvider: InteractiveWindowProvider; - let variableViewProvider: ITestVariableViewProvider; - let debugAdapterTracker: vscode.DebugAdapterTracker | undefined; - const tracker: vscode.DebugAdapterTrackerFactory = { - createDebugAdapterTracker: function ( - _session: vscode.DebugSession - ): vscode.ProviderResult { - return debugAdapterTracker; - } - }; - - setup(async function () { - if (IS_REMOTE_NATIVE_TEST()) { - return this.skip(); - } - traceInfo(`Start Test ${this.currentTest?.title}`); - api = await initialize(); - disposables.push(vscode.debug.registerDebugAdapterTrackerFactory('python', tracker)); - disposables.push(vscode.debug.registerDebugAdapterTrackerFactory(pythonIWKernelDebugAdapter, tracker)); - interactiveWindowProvider = api.serviceManager.get(IInteractiveWindowProvider); - traceInfo(`Start Test (completed) ${this.currentTest?.title}`); - const coreVariableViewProvider = api.serviceContainer.get(IVariableViewProvider); - // eslint-disable-next-line @typescript-eslint/no-explicit-any - variableViewProvider = coreVariableViewProvider as any as ITestVariableViewProvider; // Cast to expose the test interfaces - }); - teardown(async function () { - // Make sure that debugging is shut down - await vscode.commands.executeCommand('workbench.action.debug.stop'); - await vscode.commands.executeCommand('workbench.action.debug.disconnect'); - await waitForCondition( - async () => { - return vscode.debug.activeDebugSession === undefined; - }, - defaultNotebookTestTimeout, - `Unable to stop debug session on test teardown` - ); - - traceInfo(`Ended Test ${this.currentTest?.title}`); - if (this.currentTest?.isFailed()) { - await captureScreenShot(this.currentTest?.title); - } - sinon.restore(); - debugAdapterTracker = undefined; - await closeNotebooksAndCleanUpAfterTests(disposables); - }); - - test('Debug a cell from a python file', async () => { - // Run a cell to get IW open - const source = 'print(42)'; - const { activeInteractiveWindow, untitledPythonFile } = await submitFromPythonFile( - interactiveWindowProvider, - source, - disposables - ); - await waitForLastCellToComplete(activeInteractiveWindow); - - // Add some more text - const editor = vscode.window.visibleTextEditors.find((e) => e.document.uri === untitledPythonFile.uri); - assert.ok(editor, `Couldn't find python file`); - await editor?.edit((b) => { - b.insert(new vscode.Position(1, 0), '\n# %%\n\n\nprint(43)'); - }); - - let codeLenses = await waitForCodeLenses(untitledPythonFile.uri, Commands.DebugCell); - let stopped = false; - let stoppedOnLine5 = false; - debugAdapterTracker = { - onDidSendMessage: (message) => { - if (message.event == 'stopped') { - stopped = true; - } - if (message.command == 'stackTrace' && !stoppedOnLine5) { - stoppedOnLine5 = message.body.stackFrames[0].line == 5; - } - } - }; - - // Try debugging the cell - assert.ok(codeLenses, `No code lenses found`); - assert.equal(codeLenses.length, 3, `Wrong number of code lenses found`); - const args = codeLenses[2].command!.arguments || []; - void vscode.commands.executeCommand(codeLenses[2].command!.command, ...args); - - // Wait for breakpoint to be hit - await waitForCondition( - async () => { - return vscode.debug.activeDebugSession != undefined && stopped; - }, - defaultNotebookTestTimeout, - `Never hit stop event when waiting for debug cell` - ); - - // Verify we are on the 'print(43)' line (might take a second for UI to update after stop event) - await waitForCondition( - async () => { - return stoppedOnLine5; - }, - defaultNotebookTestTimeout, - `Cursor did not move to expected line when hitting breakpoint` - ); - }); - - test('Run a cell and step into breakpoint', async function () { - // Define the function - const source = 'def foo():\n print("foo")'; - const { activeInteractiveWindow, untitledPythonFile } = await submitFromPythonFile( - interactiveWindowProvider, - source, - disposables - ); - await waitForLastCellToComplete(activeInteractiveWindow); - - // Add some more text - const editor = vscode.window.visibleTextEditors.find((e) => e.document.uri === untitledPythonFile.uri); - assert.ok(editor, `Couldn't find python file`); - await editor?.edit((b) => { - b.insert(new vscode.Position(2, 0), '\n# %%\nfoo()'); - }); - - let codeLenses = await waitForCodeLenses(untitledPythonFile.uri, Commands.DebugCell); - - // Insert a breakpoint on line 2 - vscode.debug.addBreakpoints([ - new vscode.SourceBreakpoint(new vscode.Location(untitledPythonFile.uri, new vscode.Position(1, 0)), true) - ]); - - let stopped = false; - let stoppedOnBreakpoint = false; - debugAdapterTracker = { - onDidSendMessage: (message) => { - if (message.event == 'stopped') { - stopped = true; - } - if (message.command == 'stackTrace' && !stoppedOnBreakpoint && message.body.stackFrames.length) { - stoppedOnBreakpoint = message.body.stackFrames[0].line == 2; - } - } - }; - - // Try debugging the cell - assert.ok(codeLenses, `No code lenses found`); - assert.equal(codeLenses.length, 3, `Wrong number of code lenses found`); - let args = codeLenses[2].command!.arguments || []; - void vscode.commands.executeCommand(codeLenses[2].command!.command, ...args); - - // Wait for breakpoint to be hit - await waitForCondition( - async () => { - return vscode.debug.activeDebugSession != undefined && stopped; - }, - defaultNotebookTestTimeout, - `Never hit stop event when waiting for debug cell` - ); - - codeLenses = await waitForCodeLenses(untitledPythonFile.uri, Commands.DebugContinue); - stopped = false; - // Continue and wait for stopped. - args = codeLenses[0].command!.arguments || []; - void vscode.commands.executeCommand(codeLenses[0].command!.command, ...args); - await waitForCondition( - async () => { - return stoppedOnBreakpoint && stopped; - }, - defaultNotebookTestTimeout, - `Did not hit breakpoint during continue` - ); - }); - - test('Update variables during stepping', async () => { - // Define the function - const source = 'print(42)'; - const { activeInteractiveWindow, untitledPythonFile } = await submitFromPythonFile( - interactiveWindowProvider, - source, - disposables - ); - await waitForLastCellToComplete(activeInteractiveWindow); - - // Add some more text - const editor = vscode.window.visibleTextEditors.find((e) => e.document.uri === untitledPythonFile.uri); - assert.ok(editor, `Couldn't find python file`); - await editor?.edit((b) => { - b.insert(new vscode.Position(1, 0), '\n# %%\nx = 1\nx = 2\nx = 3\nx'); - }); - - let codeLenses = await waitForCodeLenses(untitledPythonFile.uri, Commands.DebugCell); - let stopped = false; - debugAdapterTracker = { - onDidSendMessage: (message) => { - if (message.event == 'stopped') { - stopped = true; - } - } - }; - - // Try debugging the cell - assert.ok(codeLenses, `No code lenses found`); - assert.equal(codeLenses.length, 3, `Wrong number of code lenses found`); - let args = codeLenses[2].command!.arguments || []; - void vscode.commands.executeCommand(codeLenses[2].command!.command, ...args); - - // Wait for breakpoint to be hit - await waitForCondition( - async () => { - return vscode.debug.activeDebugSession != undefined && stopped; - }, - defaultNotebookTestTimeout, - `Never hit stop event when waiting for debug cell` - ); - - // Wait to get the step over code lens - codeLenses = await waitForCodeLenses(untitledPythonFile.uri, Commands.DebugStepOver); - // Step once - stopped = false; - // Continue and wait for stopped. - args = codeLenses[2].command!.arguments || []; - void vscode.commands.executeCommand(codeLenses[2].command!.command, ...args); - await waitForCondition( - async () => { - return stopped; - }, - defaultNotebookTestTimeout, - `Did not do first step` - ); - - // Send the command to open the view - await vscode.commands.executeCommand(Commands.OpenVariableView); - - // Aquire the variable view from the provider - const coreVariableView = await variableViewProvider.activeVariableView; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const variableView = coreVariableView as any as ITestWebviewHost; - - // Parse the HTML for our expected variables - let expectedVariables = [{ name: 'x', type: 'int', length: '', value: '1' }]; - await waitForVariablesToMatch(expectedVariables, variableView); - - stopped = false; - // Continue and wait for stopped. - args = codeLenses[2].command!.arguments || []; - void vscode.commands.executeCommand(codeLenses[2].command!.command, ...args); - await waitForCondition( - async () => { - return stopped; - }, - defaultNotebookTestTimeout, - `Did not do second step` - ); - - expectedVariables = [{ name: 'x', type: 'int', length: '', value: '2' }]; - await waitForVariablesToMatch(expectedVariables, variableView); - - stopped = false; - // Continue and wait for stopped. - args = codeLenses[2].command!.arguments || []; - void vscode.commands.executeCommand(codeLenses[2].command!.command, ...args); - await waitForCondition( - async () => { - return stopped; - }, - defaultNotebookTestTimeout, - `Did not do third step` - ); - - expectedVariables = [{ name: 'x', type: 'int', length: '', value: '3' }]; - await waitForVariablesToMatch(expectedVariables, variableView); - }); - - test('Run a cell and stop in the middle', async () => { - // Define the function - const source = 'print(42)'; - const { activeInteractiveWindow, untitledPythonFile } = await submitFromPythonFile( - interactiveWindowProvider, - source, - disposables - ); - await waitForLastCellToComplete(activeInteractiveWindow); - - // Add some more text - const editor = vscode.window.visibleTextEditors.find((e) => e.document.uri === untitledPythonFile.uri); - assert.ok(editor, `Couldn't find python file`); - await editor?.edit((b) => { - b.insert( - new vscode.Position(1, 0), - `\n# %%\nimport time\nwhile(True):\n print(1)\n time.sleep(.1)\nprint('finished')` +import * as path from '../../platform/vscode-path/path'; +import * as fs from 'fs-extra'; +import { EXTENSION_ROOT_DIR } from '../../platform/constants.node'; +import { DebuggerType, sharedIWDebuggerTests } from './interactiveDebugging.vscode.common'; +import { startJupyterServer } from './notebook/helper.node'; +import { captureScreenShot } from '../common.node'; + +/* eslint-disable @typescript-eslint/no-explicit-any, no-invalid-this */ +suite('Interactive Window Debugging', function () { + const settingsFile = path.join(EXTENSION_ROOT_DIR, 'src', 'test', 'datascience', '.vscode', 'settings.json'); + async function enableJupyterDebugger(debuggerType: DebuggerType) { + const enable = debuggerType === 'JupyterProtocolDebugger'; + const settingFileContents = fs.readFileSync(settingsFile).toString(); + if (enable && settingFileContents.includes(`"jupyter.forceIPyKernelDebugger": true`)) { + return; + } else if (enable && settingFileContents.includes(`"jupyter.forceIPyKernelDebugger": false`)) { + fs.writeFileSync( + settingsFile, + settingFileContents.replace( + `"jupyter.forceIPyKernelDebugger": false`, + `"jupyter.forceIPyKernelDebugger": true` + ) ); - }); - - let codeLenses = await waitForCodeLenses(untitledPythonFile.uri, Commands.DebugCell); - let stopped = false; - debugAdapterTracker = { - onDidSendMessage: (message) => { - if (message.event == 'stopped') { - stopped = true; - } - } - }; - - // Try debugging the cell - assert.ok(codeLenses, `No code lenses found`); - assert.equal(codeLenses.length, 3, `Wrong number of code lenses found`); - let args = codeLenses[2].command!.arguments || []; - void vscode.commands.executeCommand(codeLenses[2].command!.command, ...args); - - // Wait for breakpoint to be hit - await waitForCondition( - async () => { - return vscode.debug.activeDebugSession != undefined && stopped; - }, - defaultNotebookTestTimeout, - `Never hit stop event when waiting for debug cell` - ); - - // Now we should have a stop command (second one) - codeLenses = await waitForCodeLenses(untitledPythonFile.uri, Commands.DebugStop); - const lastCell = await waitForLastCellToComplete(activeInteractiveWindow, -1, true); - const outputs = getCellOutputs(lastCell); - assert.isFalse(outputs.includes('finished'), 'Cell finished during a stop'); - }); - - test('Correctly handle leading spaces in a code cell we are debugging', async () => { - // First just get our window up and started - const source = 'c = 50\n'; - const { activeInteractiveWindow, untitledPythonFile } = await submitFromPythonFile( - interactiveWindowProvider, - source, - disposables - ); - await waitForLastCellToComplete(activeInteractiveWindow); - - // Next add some code lines with leading spaces, we are going to debug this cell and we want to end up on the - // correct starting line - const leadingSpacesSource = `# %% - - - - -a = 100 -b = 200 -`; - const editor = vscode.window.visibleTextEditors.find((e) => e.document.uri === untitledPythonFile.uri); - assert.ok(editor, `Couldn't find python file`); - await editor?.edit((edit) => { - edit.insert(new vscode.Position(2, 0), leadingSpacesSource); - }); - - let codeLenses = await waitForCodeLenses(untitledPythonFile.uri, Commands.DebugCell); - let stopped = false; - let stoppedOnLine = false; - debugAdapterTracker = { - onDidSendMessage: (message) => { - if (message.event == 'stopped') { - stopped = true; - } - if (message.command == 'stackTrace' && !stoppedOnLine) { - stoppedOnLine = message.body.stackFrames[0].line == 7; - } - } - }; - - // Try debugging the cell - assert.ok(codeLenses, `No code lenses found`); - assert.equal(codeLenses.length, 3, `Wrong number of code lenses found`); - let args = codeLenses[2].command!.arguments || []; - void vscode.commands.executeCommand(codeLenses[2].command!.command, ...args); - - // Wait for breakpoint to be hit - await waitForCondition( - async () => { - return vscode.debug.activeDebugSession != undefined && stopped; - }, - defaultNotebookTestTimeout, - `Never hit stop event when waiting for debug cell` - ); - - // Verify we are on the 'a = 100' line (might take a second for UI to update after stop event) - await waitForCondition( - async () => { - return stoppedOnLine; - }, - defaultNotebookTestTimeout, - `Cursor did not move to expected line when hitting breakpoint` - ); - }); - test('Correctly handle leading spaces in a previously run code cell', async () => { - // Define the function with some leading spaces and run it (don't debug it) - const source = ` - - - - -def foo(): - x = 10`; - const { activeInteractiveWindow, untitledPythonFile } = await submitFromPythonFile( - interactiveWindowProvider, - source, - disposables - ); - await waitForLastCellToComplete(activeInteractiveWindow); - - // Add some more text - const editor = vscode.window.visibleTextEditors.find((e) => e.document.uri === untitledPythonFile.uri); - assert.ok(editor, `Couldn't find python file`); - await editor?.edit((b) => { - b.insert(new vscode.Position(8, 0), '\n# %%\nfoo()'); - }); - - let codeLenses = await waitForCodeLenses(untitledPythonFile.uri, Commands.DebugCell); - let stopped = false; - let stoppedOnLine = false; - let targetLine = 9; - debugAdapterTracker = { - onDidSendMessage: (message) => { - if (message.event == 'stopped') { - stopped = true; - } - if (message.command == 'stackTrace' && !stoppedOnLine) { - stoppedOnLine = message.body.stackFrames[0].line == targetLine; - } - } - }; - - assert.ok(codeLenses, `No code lenses found`); - assert.equal(codeLenses.length, 3, `Wrong number of code lenses found`); - let args = codeLenses[2].command!.arguments || []; - void vscode.commands.executeCommand(codeLenses[2].command!.command, ...args); - - // Wait for breakpoint to be hit - await waitForCondition( - async () => { - return vscode.debug.activeDebugSession != undefined && stopped; - }, - defaultNotebookTestTimeout, - `Never hit stop event when waiting for debug cell` - ); - - // Verify that we hit the correct line - await waitForCondition( - async () => { - return stoppedOnLine; - }, - defaultNotebookTestTimeout, - `Cursor did not move to expected line when hitting breakpoint` - ); - - // Perform a step into - stopped = false; - stoppedOnLine = false; - targetLine = 7; - - void vscode.commands.executeCommand('workbench.action.debug.stepInto'); - await waitForCondition( - async () => { - return stopped; - }, - defaultNotebookTestTimeout, - `Did not stop on step into` - ); - - // Verify that we hit the correct line - await waitForCondition( - async () => { - return stoppedOnLine; - }, - defaultNotebookTestTimeout, - `Cursor did not move to expected line when hitting stepping into` - ); - }); - - test('Step into a previous cell', async () => { - // Need a function and a call to the function - const source = ` -# %% -def foo(): - x = 10 - -# %% -foo() -`; - const { activeInteractiveWindow, untitledPythonFile } = await submitFromPythonFileUsingCodeWatcher( - source, - disposables - ); - await waitForLastCellToComplete(activeInteractiveWindow, 2); - - let codeLenses = await waitForCodeLenses(untitledPythonFile.uri, Commands.DebugCell); - let stopped = false; - let stoppedOnLine = false; - let targetLine = 7; - debugAdapterTracker = { - onDidSendMessage: (message) => { - if (message.event == 'stopped') { - stopped = true; - } - if (message.command == 'stackTrace' && !stoppedOnLine) { - stoppedOnLine = message.body.stackFrames[0].line == targetLine; - } - } - }; - - const debugCellCodeLenses = codeLenses.filter((c) => c.command?.command === Commands.DebugCell); - const debugCellCodeLens = debugCellCodeLenses[1]; - let args = debugCellCodeLens.command!.arguments || []; - void vscode.commands.executeCommand(debugCellCodeLens.command!.command, ...args); - - // Wait for breakpoint to be hit - await waitForCondition( - async () => { - return vscode.debug.activeDebugSession != undefined && stopped; - }, - defaultNotebookTestTimeout, - `Never hit stop event when waiting for debug cell` - ); - - // Verify that we hit the correct line - await waitForCondition( - async () => { - return stoppedOnLine; - }, - defaultNotebookTestTimeout, - `Cursor did not move to expected line when hitting breakpoint` - ); - - // Perform a step into - stopped = false; - stoppedOnLine = false; - targetLine = 4; - - void vscode.commands.executeCommand('workbench.action.debug.stepInto'); - await waitForCondition( - async () => { - return stopped; - }, - defaultNotebookTestTimeout, - `Did not stop on step into` - ); - - // Verify that we hit the correct line - await waitForCondition( - async () => { - return stoppedOnLine; - }, - defaultNotebookTestTimeout, - `Cursor did not move to expected line when hitting stepping into` - ); - }); + return; + } else if (enable && !settingFileContents.includes(`"jupyter.forceIPyKernelDebugger": true`)) { + throw new Error('Unable to update settings file'); + } else if (!enable && settingFileContents.includes(`"jupyter.forceIPyKernelDebugger": true`)) { + fs.writeFileSync( + settingsFile, + settingFileContents.replace( + `"jupyter.forceIPyKernelDebugger": true`, + `"jupyter.forceIPyKernelDebugger": false` + ) + ); + return; + } else if (!enable && settingFileContents.includes(`"jupyter.forceIPyKernelDebugger": false`)) { + return; + } else if (!enable && !settingFileContents.includes(`"jupyter.forceIPyKernelDebugger": true`)) { + throw new Error('Unable to update settings file'); + } + } + sharedIWDebuggerTests.bind(this)({ startJupyterServer, suiteSetup: enableJupyterDebugger, captureScreenShot }); }); diff --git a/src/test/datascience/interactiveDebugging.vscode.web.test.ts b/src/test/datascience/interactiveDebugging.vscode.web.test.ts deleted file mode 100644 index 75fc53e71bd1..000000000000 --- a/src/test/datascience/interactiveDebugging.vscode.web.test.ts +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -'use strict'; - -import { sharedIWDebuggerTests } from './interactiveDebugging.vscode.common'; -import { startJupyterServer } from './notebook/helper.web'; - -/* eslint-disable @typescript-eslint/no-explicit-any, no-invalid-this */ -suite('Interactive Window Debugging', function () { - sharedIWDebuggerTests.bind(this)({ startJupyterServer }); -});