Skip to content

Commit 01a7bd6

Browse files
committed
Fix formatting
1 parent 43126e7 commit 01a7bd6

File tree

1 file changed

+41
-34
lines changed

1 file changed

+41
-34
lines changed

src/test/common/process/pythonDaemonPool.functional.test.ts

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ suite('Daemon - Python Daemon Pool', () => {
6060
const pythonProc = spawn(fullyQualifiedPythonPath, ['-m', 'datascience.daemon'], { env });
6161
const connection = createMessageConnection(new StreamMessageReader(pythonProc.stdout), new StreamMessageWriter(pythonProc.stdin));
6262
connection.listen();
63-
disposables.push({dispose: () => pythonProc.kill()});
64-
disposables.push({dispose: () => connection.dispose()});
65-
// tslint:disable-next-line: no-any
66-
return {proc: pythonProc, dispose: noop, out: undefined as any};
63+
disposables.push({ dispose: () => pythonProc.kill() });
64+
disposables.push({ dispose: () => connection.dispose() });
65+
// tslint:disable-next-line: no-any
66+
return { proc: pythonProc, dispose: noop, out: undefined as any };
6767
});
6868
const options = { pythonPath: fullyQualifiedPythonPath, daemonModule: PythonDaemonModule, daemonCount: 2, observableDaemonCount: 1 };
6969
pythonDaemonPool = new DaemonPool(options, instance(pythonExecutionService), {}, 100);
@@ -78,7 +78,11 @@ suite('Daemon - Python Daemon Pool', () => {
7878
async function getStdOutFromObservable(output: ObservableExecutionResult<string>) {
7979
return new Promise<string>((resolve, reject) => {
8080
const data: string[] = [];
81-
output.out.subscribe(out => data.push(out.out.trim()), reject, () => resolve(data.join('')));
81+
output.out.subscribe(
82+
out => data.push(out.out.trim()),
83+
reject,
84+
() => resolve(data.join(''))
85+
);
8286
});
8387
}
8488

@@ -120,9 +124,9 @@ suite('Daemon - Python Daemon Pool', () => {
120124
await assert.eventually.equal(pythonDaemonPool.isModuleInstalled(moduleName), expectedToBeInstalled);
121125
}
122126

123-
test('\'pip\' module is installed', async () => testModuleInstalled('pip', true));
124-
test('\'unittest\' module is installed', async () => testModuleInstalled('unittest', true));
125-
test('\'VSCode-Python-Rocks\' module is not Installed', async () => testModuleInstalled('VSCode-Python-Rocks', false));
127+
test("'pip' module is installed", async () => testModuleInstalled('pip', true));
128+
test("'unittest' module is installed", async () => testModuleInstalled('unittest', true));
129+
test("'VSCode-Python-Rocks' module is not Installed", async () => testModuleInstalled('VSCode-Python-Rocks', false));
126130

127131
test('Execute a file and capture stdout (with unicode)', async () => {
128132
const source = dedent`
@@ -242,7 +246,10 @@ suite('Daemon - Python Daemon Pool', () => {
242246
await new Promise((resolve, reject) => {
243247
output.out.subscribe(out => outputsReceived.push(out.out.trim()), reject, resolve);
244248
});
245-
assert.deepEqual(outputsReceived.filter(item => item.length > 0), ['0', '1', '2', '3', '4']);
249+
assert.deepEqual(
250+
outputsReceived.filter(item => item.length > 0),
251+
['0', '1', '2', '3', '4']
252+
);
246253
}).timeout(1_000);
247254

248255
test('Execute a file and throw exception if stderr is not empty', async () => {
@@ -279,21 +286,18 @@ suite('Daemon - Python Daemon Pool', () => {
279286
// When using the python execution service, return a bogus value.
280287
when(pythonExecutionService.execObservable(deepEqual([fileToExecute]), anything())).thenCall(() => {
281288
const observable = new Observable<Output<string>>(s => {
282-
s.next({out: 'mypid', source: 'stdout'});
289+
s.next({ out: 'mypid', source: 'stdout' });
283290
s.complete();
284291
});
285-
// tslint:disable-next-line: no-any
286-
return {proc: new EventEmitter() as any, dispose: noop, out: observable};
292+
// tslint:disable-next-line: no-any
293+
return { proc: new EventEmitter() as any, dispose: noop, out: observable };
287294
});
288295
// This will use a damon.
289-
const output1 = pythonDaemonPool.execObservable([fileToExecute], { });
296+
const output1 = pythonDaemonPool.execObservable([fileToExecute], {});
290297
// These two will use a python execution service.
291-
const output2 = pythonDaemonPool.execObservable([fileToExecute], { });
292-
const output3 = pythonDaemonPool.execObservable([fileToExecute], { });
293-
const [result1, result2, result3] = await Promise.all([
294-
getStdOutFromObservable(output1), getStdOutFromObservable(output2),
295-
getStdOutFromObservable(output3)
296-
]);
298+
const output2 = pythonDaemonPool.execObservable([fileToExecute], {});
299+
const output3 = pythonDaemonPool.execObservable([fileToExecute], {});
300+
const [result1, result2, result3] = await Promise.all([getStdOutFromObservable(output1), getStdOutFromObservable(output2), getStdOutFromObservable(output3)]);
297301

298302
// Two process ids are used to run the code (one process for a daemon, another for bogus puthon process).
299303
expect(result1).to.not.equal('mypid');
@@ -308,22 +312,22 @@ suite('Daemon - Python Daemon Pool', () => {
308312
`;
309313
const fileToExecute = await createPythonFile(source);
310314
// This will use a damon.
311-
const output1 = await getStdOutFromObservable(pythonDaemonPool.execObservable([fileToExecute], { }));
315+
const output1 = await getStdOutFromObservable(pythonDaemonPool.execObservable([fileToExecute], {}));
312316
// Wait for daemon to go into the pool.
313317
await sleep(100);
314318
// This will use a damon.
315-
const output2 = await getStdOutFromObservable(pythonDaemonPool.execObservable([fileToExecute], { }));
319+
const output2 = await getStdOutFromObservable(pythonDaemonPool.execObservable([fileToExecute], {}));
316320
// Wait for daemon to go into the pool.
317321
await sleep(100);
318322
// This will use a damon.
319-
const output3 = await getStdOutFromObservable(pythonDaemonPool.execObservable([fileToExecute], { }));
323+
const output3 = await getStdOutFromObservable(pythonDaemonPool.execObservable([fileToExecute], {}));
320324

321325
// The pid for all processes is the same.
322326
// This means we're re-using the same daemon (process).
323327
expect(output1).to.equal(output2);
324328
expect(output1).to.equal(output3);
325329
}).timeout(3_000);
326-
test('Ensure two different daemons are used to execute code', async () => {
330+
test('Ensure two different daemons are used to execute code', async () => {
327331
const source = dedent`
328332
import os
329333
import time
@@ -332,10 +336,7 @@ suite('Daemon - Python Daemon Pool', () => {
332336
`;
333337
const fileToExecute = await createPythonFile(source);
334338

335-
const [output1, output2] = await Promise.all([
336-
pythonDaemonPool.exec([fileToExecute], { }),
337-
pythonDaemonPool.exec([fileToExecute], { })
338-
]);
339+
const [output1, output2] = await Promise.all([pythonDaemonPool.exec([fileToExecute], {}), pythonDaemonPool.exec([fileToExecute], {})]);
339340

340341
// The pid for both processes will be different.
341342
// This means we're running both in two separate daemons.
@@ -353,8 +354,8 @@ suite('Daemon - Python Daemon Pool', () => {
353354
const fileToExecute1 = await createPythonFile(source1);
354355

355356
let [pid1, pid2] = await Promise.all([
356-
pythonDaemonPool.exec([fileToExecute1], { }).then(out => out.stdout.trim()),
357-
pythonDaemonPool.exec([fileToExecute1], { }).then(out => out.stdout.trim())
357+
pythonDaemonPool.exec([fileToExecute1], {}).then(out => out.stdout.trim()),
358+
pythonDaemonPool.exec([fileToExecute1], {}).then(out => out.stdout.trim())
358359
]);
359360

360361
const processesUsedToRunCode = new Set<string>();
@@ -374,8 +375,14 @@ suite('Daemon - Python Daemon Pool', () => {
374375
`;
375376
const fileToExecute2 = await createPythonFile(source2);
376377
[pid1, pid2] = await Promise.all([
377-
pythonDaemonPool.exec([fileToExecute1], { }).then(out => out.stdout.trim()).catch(() => 'FAILED'),
378-
pythonDaemonPool.exec([fileToExecute2], { }).then(out => out.stdout.trim()).catch(() => 'FAILED')
378+
pythonDaemonPool
379+
.exec([fileToExecute1], {})
380+
.then(out => out.stdout.trim())
381+
.catch(() => 'FAILED'),
382+
pythonDaemonPool
383+
.exec([fileToExecute2], {})
384+
.then(out => out.stdout.trim())
385+
.catch(() => 'FAILED')
379386
]);
380387

381388
// Confirm that one of the executions failed due to an error.
@@ -386,13 +393,13 @@ suite('Daemon - Python Daemon Pool', () => {
386393
expect(processesUsedToRunCode.size).to.equal(2);
387394

388395
// Wait for a new daemon to be created.
389-
await waitForCondition(async () => (createDaemonServicesSpy.callCount - daemonsCreated) === 1, 5_000, 'Failed to create a new daemon');
396+
await waitForCondition(async () => createDaemonServicesSpy.callCount - daemonsCreated === 1, 5_000, 'Failed to create a new daemon');
390397

391398
// Confirm we have two daemons by checking the Pids again.
392399
// One of them will be new.
393400
[pid1, pid2] = await Promise.all([
394-
pythonDaemonPool.exec([fileToExecute1], { }).then(out => out.stdout.trim()),
395-
pythonDaemonPool.exec([fileToExecute1], { }).then(out => out.stdout.trim())
401+
pythonDaemonPool.exec([fileToExecute1], {}).then(out => out.stdout.trim()),
402+
pythonDaemonPool.exec([fileToExecute1], {}).then(out => out.stdout.trim())
396403
]);
397404

398405
// Keep track of the pids.

0 commit comments

Comments
 (0)