Skip to content

Commit b0cecbd

Browse files
committed
Fix warnings printed during SwiftOutputChannel tests
Output channels were not designed to be created and immediately disposed because they're added to the disposable store internal to VS Code asynchronously. Issue #1197
1 parent ffae87a commit b0cecbd

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

test/integration-tests/ui/SwiftOutputChannel.test.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,24 @@ import { SwiftOutputChannel } from "../../../src/ui/SwiftOutputChannel";
1717

1818
suite("SwiftOutputChannel", function () {
1919
let channel: SwiftOutputChannel;
20-
setup(() => {
21-
channel = new SwiftOutputChannel("SwiftOutputChannel Tests", false, 3);
20+
const channels: SwiftOutputChannel[] = [];
21+
setup(function () {
22+
const channelName = `SwiftOutputChannel Tests ${this.currentTest?.id ?? "<unknown test>"}`;
23+
channel = new SwiftOutputChannel(channelName, false, 3);
24+
channels.push(channel);
2225
});
2326

24-
teardown(() => {
25-
channel.dispose();
27+
suiteTeardown(async function () {
28+
// Output channels are added to their disposable store asynchronously, which leads
29+
// to warnings in the console if we dispose of them immediately after the test.
30+
// https://github.com/microsoft/vscode/blob/1f8fd7adeff6c113f9226787bdf4f417e6bdfb11/src/vs/workbench/api/common/extHostOutput.ts#L150
31+
// As a workaround, we wait for a short period of time before disposing of the channels
32+
await new Promise(resolve =>
33+
setTimeout(() => {
34+
channels.forEach(channel => channel.dispose());
35+
resolve(void 0);
36+
}, 50)
37+
);
2638
});
2739

2840
test("Appends logs", () => {

0 commit comments

Comments
 (0)