Skip to content

Commit

Permalink
perf(document): Improve preset test performance
Browse files Browse the repository at this point in the history
  • Loading branch information
wadackel committed Dec 13, 2020
1 parent d48a4d3 commit 51aa3d2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/cli/src/commands/preset-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default createCommand({
port,
});

const tester = new DocTester(server);
const tester = new DocTester(server, {});
const reporter = new DocResultReporter({
origin: `http://localhost:${port}`,
});
Expand Down
15 changes: 12 additions & 3 deletions packages/document/src/doc-tester.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os from 'os';
import type { TestcaseResult } from '@acot/types';
import { Acot } from '@acot/core';
import plur from 'plur';
Expand All @@ -8,11 +9,20 @@ import type { DocProject } from './doc-project';
import type { DocResult } from './doc-result';
import { debug } from './logging';

export type DocTesterConfig = {
parallel: number;
};

export class DocTester {
private _server: DocServer;
private _config: DocTesterConfig;

public constructor(server: DocServer) {
public constructor(server: DocServer, config: Partial<DocTesterConfig> = {}) {
this._server = server;
this._config = {
parallel: os.cpus().length,
...config,
};
}

public async test(project: DocProject): Promise<DocResult> {
Expand All @@ -30,7 +40,7 @@ export class DocTester {
launchOptions: {
executablePath: chromium?.executablePath,
},
parallel: 1, // TODO Handle parameters
parallel: this._config.parallel,
presets: [project.preset],
origin: `http://localhost:${port}`,
});
Expand Down Expand Up @@ -106,7 +116,6 @@ export class DocTester {
}
});
} catch (e) {
// TODO logging
debug('Unexpected doc-test error:', e);
}

Expand Down

0 comments on commit 51aa3d2

Please sign in to comment.