Skip to content

Commit

Permalink
Start next command in tests to finish previous command
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyriar committed Nov 16, 2023
1 parent 3fa7cc6 commit 1c7839a
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ suite('CommandDetectionCapability', () => {
capability.handleCommandFinished(exitCode);
}

async function printCommandStart(prompt: string) {
capability.handlePromptStart();
await writeP(xterm, `\r${prompt}`);
}


setup(async () => {
disposables = new DisposableStore();
const TerminalCtor = (await importAMDNodeModule<typeof import('@xterm/xterm')>('@xterm/xterm', 'lib/xterm.js')).Terminal;
Expand All @@ -86,6 +92,7 @@ suite('CommandDetectionCapability', () => {

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

test('should trim the command when command executed appears on the following line', async () => {
await printStandardCommand('$ ', 'echo foo\r\n', 'foo', undefined, 0);
await printCommandStart('$ ');
assertCommands([{
command: 'echo foo',
exitCode: 0,
Expand All @@ -108,6 +116,7 @@ suite('CommandDetectionCapability', () => {
test('should add cwd to commands when it\'s set', async () => {
await printStandardCommand('$ ', 'echo foo', 'foo', '/home', 0);
await printStandardCommand('$ ', 'echo bar', 'bar', '/home/second', 0);
await printCommandStart('$ ');
assertCommands([
{ command: 'echo foo', exitCode: 0, cwd: '/home', marker: { line: 0 } },
{ command: 'echo bar', exitCode: 0, cwd: '/home/second', marker: { line: 2 } }
Expand All @@ -116,6 +125,7 @@ suite('CommandDetectionCapability', () => {
test('should add old cwd to commands if no cwd sequence is output', async () => {
await printStandardCommand('$ ', 'echo foo', 'foo', '/home', 0);
await printStandardCommand('$ ', 'echo bar', 'bar', undefined, 0);
await printCommandStart('$ ');
assertCommands([
{ command: 'echo foo', exitCode: 0, cwd: '/home', marker: { line: 0 } },
{ command: 'echo bar', exitCode: 0, cwd: '/home', marker: { line: 2 } }
Expand All @@ -124,6 +134,7 @@ suite('CommandDetectionCapability', () => {
test('should use an undefined cwd if it\'s not set initially', async () => {
await printStandardCommand('$ ', 'echo foo', 'foo', undefined, 0);
await printStandardCommand('$ ', 'echo bar', 'bar', '/home', 0);
await printCommandStart('$ ');
assertCommands([
{ command: 'echo foo', exitCode: 0, cwd: undefined, marker: { line: 0 } },
{ command: 'echo bar', exitCode: 0, cwd: '/home', marker: { line: 2 } }
Expand Down

0 comments on commit 1c7839a

Please sign in to comment.