Skip to content

Commit 10417e7

Browse files
and-oliDevtools-frontend LUCI CQ
authored and
Devtools-frontend LUCI CQ
committed
Export merged results of unit and interaction test coverage as text file
For convenience, since the bots will still use the JSON file. Also, an option to define the folders on which coverage will be calculated is added to the interaction tests. The flag works identically to the COVERAGE_FOLDERS of unit tests, i.e. a pattern is provided to define the included folders. For example: the flag can be set like COVERAGE_FOLDERS= front_end/{models/trace,models/timeline_model,panels/timeline} These two changes should help to calculate the total OPP coverage in go/opp-test-coverage Bug: 1424729 Change-Id: Ie982f62dfac0014c05075e53173a8e7710d3b9e0 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/4345493 Commit-Queue: Andres Olivares <andoli@chromium.org> Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
1 parent f567b83 commit 10417e7

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

scripts/component_server/server.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ const defaultIstanbulSchema = require('@istanbuljs/schema');
1414

1515
const {getTestRunnerConfigSetting} = require('../test/test_config_helpers.js');
1616

17+
const match = require('minimatch');
18+
1719
const serverPort = parseInt(process.env.PORT, 10) || 8090;
1820
const target = argv.target || process.env.TARGET || 'Default';
1921

@@ -200,6 +202,8 @@ async function checkFileExists(filePath) {
200202

201203
const EXCLUDED_COVERAGE_FOLDERS = new Set(['third_party', 'ui/components/docs', 'Images']);
202204

205+
const USER_DEFINED_COVERAGE_FOLDERS = process.env['COVERAGE_FOLDERS'];
206+
203207
/**
204208
* @param {string} filePath
205209
* @returns {boolean}
@@ -210,6 +214,10 @@ function isIncludedForCoverageComputation(filePath) {
210214
return false;
211215
}
212216
}
217+
if (USER_DEFINED_COVERAGE_FOLDERS) {
218+
const matchPattern = `/${USER_DEFINED_COVERAGE_FOLDERS}/**/*.{js,mjs}`;
219+
return match(filePath, matchPattern);
220+
}
213221

214222
return true;
215223
}

scripts/test/merge_coverage_reports.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ const context = report.createContext({
1717
defaultSummarizer: 'nested',
1818
});
1919
reports.create('json-summary').execute(context);
20+
reports.create('text', {file: 'coverage.txt'}).execute(context);

test/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
coverage-summary.json
1+
coverage-summary.json
2+
coverage.txt

test/conductor/mocha_hooks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ export const mochaHooks = {
103103
});
104104
reports.create('html').execute(context);
105105
reports.create('json').execute(context);
106+
reports.create('text', {file: 'coverage.txt'}).execute(context);
106107
reports.create('json-summary').execute(context);
107108
},
108109
// In both modes, run before each test.

0 commit comments

Comments
 (0)