Skip to content

Commit 782391d

Browse files
pfaffeDevtools-frontend LUCI CQ
authored and
Devtools-frontend LUCI CQ
committed
[testing] add an --artifacts-dir to store unittest coverage info
Drive-by: Add help text for command line arguments. Bug: b:333423685 Change-Id: I7b91e4fac4f345ea66a60b93f83f34105a15343a Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5461358 Commit-Queue: Simon Zünd <[email protected]> Auto-Submit: Philip Pfaffe <[email protected]> Reviewed-by: Simon Zünd <[email protected]>
1 parent 10c4bbf commit 782391d

File tree

4 files changed

+23
-12
lines changed

4 files changed

+23
-12
lines changed

test/conductor/commandline.ts

+19-10
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ function validateDiffBehaviors(args: undefined|string|string[]) {
3030
}
3131
}
3232
if (failed.length > 0) {
33-
throw new Error(`Invalid options for --on-diff: ${failed}`);
33+
throw new Error(
34+
`Invalid options for --on-diff: ${failed}. Valid options are: ${Object.values(DiffBehaviors).join(', ')}`);
3435
}
3536
return asArray(args);
3637
}
@@ -39,13 +40,21 @@ function validateDiffBehaviors(args: undefined|string|string[]) {
3940
export function commandLineArgs(yargs: any) {
4041
return yargs.parserConfiguration({'camel-case-expansion': false})
4142
.command('$0 [tests..]')
42-
.option('debug', {type: 'boolean'})
43-
.option('coverage', {type: 'boolean'})
44-
.option('chrome-binary', {type: 'string'})
45-
.option('repeat', {type: 'number', default: 1})
46-
.option('on-diff', {type: 'string', coerce: validateDiffBehaviors})
47-
.option('shuffle', {type: 'boolean'})
48-
.option('grep', {type: 'string', conflicts: 'fgrep'})
49-
.option('fgrep', {type: 'string', conflicts: 'grep'})
50-
.option('invert-grep', {type: 'boolean'});
43+
.option(
44+
'artifacts-dir',
45+
{type: 'string', desc: 'Path to a directory to store test artifacts in (e.g., coverage reports)'})
46+
.option('debug', {type: 'boolean', desc: 'Execute tests in debug mode'})
47+
.option('coverage', {type: 'boolean', desc: 'Enable coverage reporting'})
48+
.option('chrome-binary', {type: 'string', desc: 'Run tests with a custom chrome binary'})
49+
.option('repeat', {type: 'number', default: 1, desc: 'Repeat tests'})
50+
.option('on-diff', {
51+
type: 'string',
52+
coerce: validateDiffBehaviors,
53+
desc: `Define how to deal with diffs in snapshots/screenshots. Options are: ${
54+
Object.values(DiffBehaviors).join(', ')}`,
55+
})
56+
.option('shuffle', {type: 'boolean', desc: 'Execute tests in random order'})
57+
.option('grep', {type: 'string', conflicts: 'fgrep', desc: 'Filter tests by name using grep'})
58+
.option('fgrep', {type: 'string', conflicts: 'grep', desc: 'Filter tests by name using fgrep'})
59+
.option('invert-grep', {type: 'boolean', desc: 'Invert the grep/fgrep result'});
5160
}

test/conductor/test_config.ts

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export const enum ServerType {
2929

3030
interface Config {
3131
tests: string[];
32+
artifactsDir: string;
3233
chromeBinary: string;
3334
serverType: ServerType;
3435
debug: boolean;
@@ -74,6 +75,7 @@ function mochaGrep(): Config['mochaGrep'] {
7475

7576
export const TestConfig: Config = {
7677
tests: options['tests'],
78+
artifactsDir: options['artifacts-dir'] || SOURCE_ROOT,
7779
chromeBinary: options['chrome-binary'] ?? chromePath(),
7880
serverType: ServerType.HostedMode,
7981
debug: options['debug'],

test/run.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const yargs = require('yargs');
1414
const unparse = require('yargs-unparser');
1515
const options = commandLineArgs(yargs(process.argv.slice(2)))
1616
.options('skip-ninja', {type: 'boolean', desc: 'Skip rebuilding'})
17-
.options('debug-driver', {type: 'boolean', hidden: true})
17+
.options('debug-driver', {type: 'boolean', hidden: true, desc: 'Debug the driver part of tests'})
1818
.positional('tests', {
1919
type: 'string',
2020
desc: 'Path to the test suite, starting from out/Target/gen directory.',

test/unit/karma.conf.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ module.exports = function(config: any) {
108108
},
109109

110110
coverageReporter: {
111-
dir: path.join(GEN_DIR, COVERAGE_OUTPUT_DIRECTORY),
111+
dir: path.join(TestConfig.artifactsDir, COVERAGE_OUTPUT_DIRECTORY),
112112
subdir: '.',
113113
reporters: [
114114
{type: 'json-summary'},

0 commit comments

Comments
 (0)