|
| 1 | +// Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | +// Licensed under the MIT License. |
| 3 | + |
| 4 | +'use strict'; |
| 5 | + |
| 6 | +// tslint:disable:no-suspicious-comment max-func-body-length no-invalid-this no-var-requires no-require-imports no-any |
| 7 | + |
| 8 | +import * as path from 'path'; |
| 9 | +import { DebugClient } from 'vscode-debugadapter-testsupport'; |
| 10 | +import { EXTENSION_ROOT_DIR } from '../../client/common/constants'; |
| 11 | +import { noop } from '../../client/common/core.utils'; |
| 12 | +import { PTVSD_PATH } from '../../client/debugger/Common/constants'; |
| 13 | +import { DebugOptions, LaunchRequestArguments } from '../../client/debugger/Common/Contracts'; |
| 14 | +import { sleep } from '../common'; |
| 15 | +import { IS_MULTI_ROOT_TEST, TEST_DEBUGGER } from '../initialize'; |
| 16 | +import { createDebugAdapter } from './utils'; |
| 17 | + |
| 18 | +const workspaceDirectory = path.join(EXTENSION_ROOT_DIR, 'src', 'testMultiRootWkspc', 'workspace5'); |
| 19 | +const debuggerType = 'pythonExperimental'; |
| 20 | +suite(`Module Debugging - Misc tests: ${debuggerType}`, () => { |
| 21 | + let debugClient: DebugClient; |
| 22 | + setup(async function () { |
| 23 | + if (!IS_MULTI_ROOT_TEST || !TEST_DEBUGGER) { |
| 24 | + this.skip(); |
| 25 | + } |
| 26 | + const coverageDirectory = path.join(EXTENSION_ROOT_DIR, 'debug_coverage_module'); |
| 27 | + debugClient = await createDebugAdapter(coverageDirectory); |
| 28 | + }); |
| 29 | + teardown(async () => { |
| 30 | + // Wait for a second before starting another test (sometimes, sockets take a while to get closed). |
| 31 | + await sleep(1000); |
| 32 | + try { |
| 33 | + await debugClient.stop().catch(noop); |
| 34 | + // tslint:disable-next-line:no-empty |
| 35 | + } catch (ex) { } |
| 36 | + await sleep(1000); |
| 37 | + }); |
| 38 | + function buildLauncArgs(): LaunchRequestArguments { |
| 39 | + const env = {}; |
| 40 | + // tslint:disable-next-line:no-string-literal |
| 41 | + env['PYTHONPATH'] = `.${path.delimiter}${PTVSD_PATH}`; |
| 42 | + |
| 43 | + // tslint:disable-next-line:no-unnecessary-local-variable |
| 44 | + const options: LaunchRequestArguments = { |
| 45 | + module: 'mymod', |
| 46 | + program: '', |
| 47 | + cwd: workspaceDirectory, |
| 48 | + debugOptions: [DebugOptions.RedirectOutput], |
| 49 | + pythonPath: 'python', |
| 50 | + args: [], |
| 51 | + env, |
| 52 | + envFile: '', |
| 53 | + logToFile: false, |
| 54 | + type: debuggerType |
| 55 | + }; |
| 56 | + |
| 57 | + return options; |
| 58 | + } |
| 59 | + |
| 60 | + test('Test stdout output', async () => { |
| 61 | + await Promise.all([ |
| 62 | + debugClient.configurationSequence(), |
| 63 | + debugClient.launch(buildLauncArgs()), |
| 64 | + debugClient.waitForEvent('initialized'), |
| 65 | + debugClient.assertOutput('stdout', 'Hello world!'), |
| 66 | + debugClient.waitForEvent('exited'), |
| 67 | + debugClient.waitForEvent('terminated') |
| 68 | + ]); |
| 69 | + }); |
| 70 | +}); |
0 commit comments