From d5c2f96eed29221328622345d7ec16a66e588593 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Mon, 12 Mar 2018 14:45:19 -0700 Subject: [PATCH 1/3] :memo: change log --- news/3 Code Health/1048.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/3 Code Health/1048.md diff --git a/news/3 Code Health/1048.md b/news/3 Code Health/1048.md new file mode 100644 index 000000000000..c49a6f27e1a1 --- /dev/null +++ b/news/3 Code Health/1048.md @@ -0,0 +1 @@ +Enable unit testing of stdout and stderr redirection for the experimental debugger. From e6aae5016161b2a5166819e863ff1a8d529f41be Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Mon, 12 Mar 2018 14:45:32 -0700 Subject: [PATCH 2/3] :white_check_mark: enable testing --- src/test/debugger/misc.test.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/test/debugger/misc.test.ts b/src/test/debugger/misc.test.ts index 348219134d34..a82185afc3c3 100644 --- a/src/test/debugger/misc.test.ts +++ b/src/test/debugger/misc.test.ts @@ -84,23 +84,18 @@ const THREAD_TIMEOUT = 10000; debugClient.waitForEvent('stopped') ]); }); - test('test stderr output', async function () { - if (debuggerType !== 'python') { - return this.skip(); - } + test('test stderr output for Python', async () => { + const output = debuggerType === 'python' ? 'stdout' : 'stderr'; await Promise.all([ debugClient.configurationSequence(), debugClient.launch(buildLauncArgs('stdErrOutput.py', false)), debugClient.waitForEvent('initialized'), //TODO: ptvsd does not differentiate. - debugClient.assertOutput('stdout', 'error output'), + debugClient.assertOutput(output, 'error output'), debugClient.waitForEvent('terminated') ]); }); - test('Test stdout output', async function () { - if (debuggerType !== 'python') { - return this.skip(); - } + test('Test stdout output', async () => { await Promise.all([ debugClient.configurationSequence(), debugClient.launch(buildLauncArgs('stdOutOutput.py', false)), From ca05d59cdaedacc46af98dc62b4070ac9458140f Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Mon, 12 Mar 2018 15:43:29 -0700 Subject: [PATCH 3/3] :bug: pass necessary flags to experimental debugger --- src/test/debugger/misc.test.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/test/debugger/misc.test.ts b/src/test/debugger/misc.test.ts index a82185afc3c3..c6dfab6068cd 100644 --- a/src/test/debugger/misc.test.ts +++ b/src/test/debugger/misc.test.ts @@ -51,7 +51,7 @@ const THREAD_TIMEOUT = 10000; await sleep(1000); }); function buildLauncArgs(pythonFile: string, stopOnEntry: boolean = false): LaunchRequestArguments { - return { + const options: LaunchRequestArguments = { program: path.join(debugFilesPath, pythonFile), cwd: debugFilesPath, stopOnEntry, @@ -63,6 +63,13 @@ const THREAD_TIMEOUT = 10000; logToFile: false, type: debuggerType }; + + // Custom experimental debugger options (filled in by DebugConfigurationProvider). + if (debuggerType === 'pythonExperimental') { + (options as any).redirectOutput = true; + } + + return options; } test('Should run program to the end', async () => {