Skip to content

Commit

Permalink
Enable unit testing of redirecting stdout and stderr in experimental …
Browse files Browse the repository at this point in the history
…debugger (#1050)

* 📝 change log
* ✅ enable testing
* 🐛 pass necessary flags to experimental debugger
* Fixes #1048
  • Loading branch information
DonJayamanne authored Mar 15, 2018
1 parent 822cd7a commit 52d0bec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions news/3 Code Health/1048.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Enable unit testing of stdout and stderr redirection for the experimental debugger.
22 changes: 12 additions & 10 deletions src/test/debugger/misc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 () => {
Expand All @@ -84,23 +91,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)),
Expand Down

0 comments on commit 52d0bec

Please sign in to comment.