提交 0e16b7a0 编写于 作者: D Daniel Imms

Simplify echo works in the default shell

上级 8853436d
......@@ -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<Terminal>(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<void>(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<void>(r => {
terminal.dispose();
disposables.push(window.onDidCloseTerminal(t => {
strictEqual(terminal, t);
r();
}));
});
});
test('onDidCloseTerminal event fires when terminal is disposed', async () => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册