Skip to content

Commit 1c7839a

Browse files
committed
Start next command in tests to finish previous command
1 parent 3fa7cc6 commit 1c7839a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/vs/workbench/contrib/terminal/test/browser/capabilities/commandDetectionCapability.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ suite('CommandDetectionCapability', () => {
6060
capability.handleCommandFinished(exitCode);
6161
}
6262

63+
async function printCommandStart(prompt: string) {
64+
capability.handlePromptStart();
65+
await writeP(xterm, `\r${prompt}`);
66+
}
67+
68+
6369
setup(async () => {
6470
disposables = new DisposableStore();
6571
const TerminalCtor = (await importAMDNodeModule<typeof import('@xterm/xterm')>('@xterm/xterm', 'lib/xterm.js')).Terminal;
@@ -86,6 +92,7 @@ suite('CommandDetectionCapability', () => {
8692

8793
test('should add commands for expected capability method calls', async () => {
8894
await printStandardCommand('$ ', 'echo foo', 'foo', undefined, 0);
95+
await printCommandStart('$ ');
8996
assertCommands([{
9097
command: 'echo foo',
9198
exitCode: 0,
@@ -96,6 +103,7 @@ suite('CommandDetectionCapability', () => {
96103

97104
test('should trim the command when command executed appears on the following line', async () => {
98105
await printStandardCommand('$ ', 'echo foo\r\n', 'foo', undefined, 0);
106+
await printCommandStart('$ ');
99107
assertCommands([{
100108
command: 'echo foo',
101109
exitCode: 0,
@@ -108,6 +116,7 @@ suite('CommandDetectionCapability', () => {
108116
test('should add cwd to commands when it\'s set', async () => {
109117
await printStandardCommand('$ ', 'echo foo', 'foo', '/home', 0);
110118
await printStandardCommand('$ ', 'echo bar', 'bar', '/home/second', 0);
119+
await printCommandStart('$ ');
111120
assertCommands([
112121
{ command: 'echo foo', exitCode: 0, cwd: '/home', marker: { line: 0 } },
113122
{ command: 'echo bar', exitCode: 0, cwd: '/home/second', marker: { line: 2 } }
@@ -116,6 +125,7 @@ suite('CommandDetectionCapability', () => {
116125
test('should add old cwd to commands if no cwd sequence is output', async () => {
117126
await printStandardCommand('$ ', 'echo foo', 'foo', '/home', 0);
118127
await printStandardCommand('$ ', 'echo bar', 'bar', undefined, 0);
128+
await printCommandStart('$ ');
119129
assertCommands([
120130
{ command: 'echo foo', exitCode: 0, cwd: '/home', marker: { line: 0 } },
121131
{ command: 'echo bar', exitCode: 0, cwd: '/home', marker: { line: 2 } }
@@ -124,6 +134,7 @@ suite('CommandDetectionCapability', () => {
124134
test('should use an undefined cwd if it\'s not set initially', async () => {
125135
await printStandardCommand('$ ', 'echo foo', 'foo', undefined, 0);
126136
await printStandardCommand('$ ', 'echo bar', 'bar', '/home', 0);
137+
await printCommandStart('$ ');
127138
assertCommands([
128139
{ command: 'echo foo', exitCode: 0, cwd: undefined, marker: { line: 0 } },
129140
{ command: 'echo bar', exitCode: 0, cwd: '/home', marker: { line: 2 } }

0 commit comments

Comments
 (0)