Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch over to executeCommand from sendText #24078

Merged
merged 37 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
2413118
vscode engine to 1.93
anthonykim1 Sep 9, 2024
5de9ca5
use executeCommand
anthonykim1 Sep 9, 2024
6d1f522
codeaction mock
anthonykim1 Sep 9, 2024
c9fc4f1
compile
anthonykim1 Sep 9, 2024
0d78806
switching version allows debugging - magically
anthonykim1 Sep 10, 2024
a16a102
pin version to equal to or above 1.93
anthonykim1 Sep 10, 2024
ea24d50
try to fix unit test
anthonykim1 Sep 10, 2024
2cb1eb3
Debt: switch Promise<void> in ensureTerminal to Promise<Terminal>
anthonykim1 Sep 10, 2024
88b4e9f
passing test when shell integration disabled
anthonykim1 Sep 10, 2024
6ecf4fc
please
anthonykim1 Sep 10, 2024
831f893
// @ts-ignore: TS6133
anthonykim1 Sep 10, 2024
f3aa28e
a
anthonykim1 Sep 10, 2024
342587a
stop
anthonykim1 Sep 11, 2024
3efaf9a
try idisposable
anthonykim1 Sep 11, 2024
d3b2238
more trials
anthonykim1 Sep 11, 2024
28ef3c1
lint
anthonykim1 Sep 11, 2024
2375490
slowly migrate test from sendText to executeCommand
anthonykim1 Sep 11, 2024
a75656b
TODO: test for when shellIntegration is active, mock and fire onDidEn…
anthonykim1 Sep 11, 2024
a51b6b4
onDidEndTerminalShellExecution never gets fired
anthonykim1 Sep 11, 2024
7c01537
switch up the order
anthonykim1 Sep 11, 2024
923df5c
add test onDidEndTerminalShellExecutionEmitter.fire(event)
anthonykim1 Sep 11, 2024
16839c9
attach callback to executeCommand so onDidEndTerminalShellExecutionEm…
anthonykim1 Sep 11, 2024
e30bb77
switch up the order abit + comment
anthonykim1 Sep 11, 2024
e69c490
wow
anthonykim1 Sep 11, 2024
e2e71d0
remove junk
anthonykim1 Sep 11, 2024
3d31d1a
remove unused
anthonykim1 Sep 11, 2024
46d28d2
remove comment
anthonykim1 Sep 11, 2024
5d3878f
TODO: smart send smoke test are flaky on windows
anthonykim1 Sep 11, 2024
dfe61de
a
anthonykim1 Sep 11, 2024
8f9ab0d
take recommended feedbacks
anthonykim1 Sep 12, 2024
6d095c8
remove leftover comments - done
anthonykim1 Sep 12, 2024
563fb12
final
anthonykim1 Sep 12, 2024
145e2fd
remove weird import
anthonykim1 Sep 12, 2024
8bc3951
last missed comment
anthonykim1 Sep 12, 2024
610d0fb
upgrade actions/download-artifact@v4
anthonykim1 Sep 12, 2024
c6a4713
why
anthonykim1 Sep 12, 2024
2b4c2bf
try with actions/download-artifact@v3
anthonykim1 Sep 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
attach callback to executeCommand so onDidEndTerminalShellExecutionEm…
…itter fires
  • Loading branch information
anthonykim1 committed Sep 11, 2024
commit 16839c9092ce70d0ede1cd6c7741c05324fa1820
3 changes: 3 additions & 0 deletions src/client/common/terminal/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ export class TerminalService implements ITerminalService, Disposable {
if (listener) {
this.executeCommandListeners.add(listener);
}
// setTimeout(() => {
// resolve(undefined);
// }, 10000); // This would be a work around for testing scenario -- would it be a good design outside of testing case?
});
} else {
terminal.sendText(commandLine);
Expand Down
29 changes: 27 additions & 2 deletions src/test/common/terminals/service.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,34 @@ suite('Terminal Service', () => {
terminal = TypeMoq.Mock.ofType<VSCodeTerminal>();
terminalShellIntegration = TypeMoq.Mock.ofType<TerminalShellIntegration>();
terminal.setup((t) => t.shellIntegration).returns(() => terminalShellIntegration.object);
// terminal.setup((t) => t.shellIntegration).returns(() => undefined);
// terminal.setup((t) => t.shellIntegration).returns(() => undefined); -- always disable shell integration => passes test
const shellExecution: TypeMoq.IMock<TerminalShellExecution> = TypeMoq.Mock.ofType<TerminalShellExecution>();

terminalShellIntegration
.setup((t) => t.executeCommand(TypeMoq.It.isAny()))
.callback(() => {
const execution: TerminalShellExecution = {
commandLine: {
value: 'dummy text',
isTrusted: true,
confidence: 2,
},
cwd: undefined,
read: function (): AsyncIterable<string> {
throw new Error('Function not implemented.');
},
};
const exitCode = 0;

const event: TerminalShellExecutionEndEvent = {
execution,
exitCode,
terminal: terminal.object,
shellIntegration: terminalShellIntegration.object,
};

onDidEndTerminalShellExecutionEmitter.fire(event);
})
.returns(() => shellExecution.object);

terminalManager = TypeMoq.Mock.ofType<ITerminalManager>();
Expand Down Expand Up @@ -81,8 +104,10 @@ suite('Terminal Service', () => {
// Add a listener to capture the event argument
onDidEndTerminalShellExecutionEmitter.event((e) => {
try {
expect(e.execution).to.equal(execution);
expect(e.execution.commandLine.value).to.equal(execution.commandLine.value);
expect(e.exitCode).to.equal(exitCode);
// resolve
return;
} catch (error) {
console.error(error);
}
Expand Down
Loading