Skip to content

Commit 48e4ac9

Browse files
simplify types
1 parent 96e6180 commit 48e4ac9

File tree

2 files changed

+5
-20
lines changed

2 files changed

+5
-20
lines changed

src/interfaces.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,3 @@ export interface ICLICompilers {
5656
compilers: string[];
5757
extensions: string[];
5858
}
59-
60-
export type Task = () => Promise<any>;
61-
export interface ITaskOutput<T> {
62-
task: Task;
63-
output?: T;
64-
}

src/main/mocha.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
ISubprocessRunnerMessage,
1919
ISubprocessSyncedData,
2020
ISuite,
21-
ITaskOutput,
2221
} from '../interfaces';
2322

2423
const debugLog = debug('mocha-parallel-tests');
@@ -84,9 +83,9 @@ export default class MochaWrapper extends Mocha {
8483
runner.fullStackTrace = fullStackTrace;
8584
runner.asyncOnly = asyncOnly;
8685

87-
const tasks: Array<() => Promise<ITaskOutput<ISubprocessResult>>> = [];
86+
const tasks: Array<() => Promise<ISubprocessResult>> = [];
8887
for (const file of this.files) {
89-
const task = () => this.spawnTestProcess(file, task);
88+
const task = () => this.spawnTestProcess(file);
9089
tasks.push(task);
9190
}
9291

@@ -135,11 +134,7 @@ export default class MochaWrapper extends Mocha {
135134

136135
Promise.all(tasks.map(async (task) => {
137136
const res = await task();
138-
const output = res.output;
139-
assert(output);
140-
if (output) {
141-
onTaskFinished(output);
142-
}
137+
onTaskFinished(res);
143138
})).then(() => {
144139
debugLog('All tests finished processing');
145140

@@ -177,8 +172,8 @@ export default class MochaWrapper extends Mocha {
177172
return retriesTests as IRetriedTest[];
178173
}
179174

180-
private async spawnTestProcess(file: string, task: any): Promise<ITaskOutput<ISubprocessResult>> {
181-
const output: ISubprocessResult = await new Promise<ISubprocessResult>(async (resolve, reject) => {
175+
private async spawnTestProcess(file: string): Promise<ISubprocessResult> {
176+
return new Promise<ISubprocessResult>(async (resolve, reject) => {
182177
const resolvedFilePath = pathResolve(file);
183178

184179
const testOptions: {[key: string]: any} = { test: resolvedFilePath };
@@ -284,9 +279,5 @@ export default class MochaWrapper extends Mocha {
284279
return null;
285280
}
286281
});
287-
return {
288-
output,
289-
task,
290-
};
291282
}
292283
}

0 commit comments

Comments
 (0)