diff --git a/extensions/vscode-api-tests/src/singlefolder-tests/terminal.test.ts b/extensions/vscode-api-tests/src/singlefolder-tests/terminal.test.ts index 48615e433f6f6348af99288c75c10b5c66de87be..6e9731fbfde23a96ece4dd772c7a06dd80f41854 100644 --- a/extensions/vscode-api-tests/src/singlefolder-tests/terminal.test.ts +++ b/extensions/vscode-api-tests/src/singlefolder-tests/terminal.test.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { window, Pseudoterminal, EventEmitter, TerminalDimensions, workspace, ConfigurationTarget, Disposable, UIKind, env, EnvironmentVariableMutatorType, EnvironmentVariableMutator, extensions, ExtensionContext, TerminalOptions, ExtensionTerminalOptions, Terminal } from 'vscode'; -import { doesNotThrow, equal, deepEqual, throws } from 'assert'; +import { doesNotThrow, equal, deepEqual, throws, strictEqual } from 'assert'; import { assertNoRpc } from '../utils'; // Disable terminal tests: @@ -55,42 +55,28 @@ import { assertNoRpc } from '../utils'; }); }); - (process.platform === 'linux' ? test.skip : test.skip)('echo works in the default shell', (done) => { - disposables.push(window.onDidOpenTerminal(term => { - try { - equal(terminal, term); - } catch (e) { - done(e); - return; - } - let data = ''; - const dataDisposable = window.onDidWriteTerminalData(e => { - try { - equal(terminal, e.terminal); - } catch (e) { - done(e); - return; - } - data += e.data; - if (data.indexOf(expected) !== 0) { - dataDisposable.dispose(); - terminal.dispose(); - disposables.push(window.onDidCloseTerminal(() => { - done(); - })); - } + test('echo works in the default shell', async () => { + const terminal = await new Promise(r => { + disposables.push(window.onDidOpenTerminal(t => { + strictEqual(terminal, t); + r(terminal); + })); + // Use a single character to avoid winpty/conpty issues with injected sequences + const terminal = window.createTerminal({ + env: { TEST: '`' } }); - disposables.push(dataDisposable); - })); - // Use a single character to avoid winpty/conpty issues with injected sequences - const expected = '`'; - const terminal = window.createTerminal({ - env: { - TEST: '`' - } + terminal.show(); }); - terminal.show(); - doesNotThrow(() => { + + let data = ''; + await new Promise(r => { + disposables.push(window.onDidWriteTerminalData(e => { + strictEqual(terminal, e.terminal); + data += e.data; + if (data.indexOf('`') !== 0) { + r(); + } + })); // Print an environment variable value so the echo statement doesn't get matched if (process.platform === 'win32') { terminal.sendText(`$env:TEST`); @@ -98,6 +84,14 @@ import { assertNoRpc } from '../utils'; terminal.sendText(`echo $TEST`); } }); + + await new Promise(r => { + terminal.dispose(); + disposables.push(window.onDidCloseTerminal(t => { + strictEqual(terminal, t); + r(); + })); + }); }); test('onDidCloseTerminal event fires when terminal is disposed', async () => {