Skip to content

Commit cbf6c41

Browse files
authored
more test cleanup (microsoft#165233)
1 parent ff51b87 commit cbf6c41

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

src/vs/base/parts/ipc/test/node/ipc.cp.integrationTest.ts

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55

66
import * as assert from 'assert';
77
import { Event } from 'vs/base/common/event';
8+
import { IChannel } from 'vs/base/parts/ipc/common/ipc';
89
import { Client } from 'vs/base/parts/ipc/node/ipc.cp';
910
import { getPathFromAmdModule } from 'vs/base/test/node/testUtils';
10-
import { TestServiceClient } from './testService';
11+
import { ITestService, TestServiceClient } from './testService';
1112

1213
function createClient(): Client {
1314
return new Client(getPathFromAmdModule(require, 'bootstrap-fork'), {
@@ -20,39 +21,37 @@ suite('IPC, Child Process', function () {
2021
this.slow(2000);
2122
this.timeout(10000);
2223

23-
test('createChannel', async () => {
24-
const client = createClient();
25-
const channel = client.getChannel('test');
26-
const service = new TestServiceClient(channel);
24+
let client: Client;
25+
let channel: IChannel;
26+
let service: ITestService;
27+
28+
setup(() => {
29+
client = createClient();
30+
channel = client.getChannel('test');
31+
service = new TestServiceClient(channel);
32+
});
33+
34+
teardown(() => {
35+
client.dispose();
36+
});
2737

38+
test('createChannel', async () => {
2839
const result = await service.pong('ping');
2940
assert.strictEqual(result.incoming, 'ping');
3041
assert.strictEqual(result.outgoing, 'pong');
31-
32-
client.dispose();
3342
});
3443

3544
test('events', async () => {
36-
const client = createClient();
37-
const channel = client.getChannel('test');
38-
const service = new TestServiceClient(channel);
39-
4045
const event = Event.toPromise(Event.once(service.onMarco));
4146
const promise = service.marco();
4247

4348
const [promiseResult, eventResult] = await Promise.all([promise, event]);
4449

4550
assert.strictEqual(promiseResult, 'polo');
4651
assert.strictEqual(eventResult.answer, 'polo');
47-
48-
client.dispose();
4952
});
5053

5154
test('event dispose', async () => {
52-
const client = createClient();
53-
const channel = client.getChannel('test');
54-
const service = new TestServiceClient(channel);
55-
5655
let count = 0;
5756
const disposable = service.onMarco(() => count++);
5857

@@ -68,7 +67,5 @@ suite('IPC, Child Process', function () {
6867
const answer_2 = await service.marco();
6968
assert.strictEqual(answer_2, 'polo');
7069
assert.strictEqual(count, 2);
71-
72-
client.dispose();
7370
});
7471
});

0 commit comments

Comments
 (0)