Skip to content

Commit 40fdfc4

Browse files
committed
[test] Remove the test/unittests/ folder completely.
Move the last bits from the old tree structure and don't use the `test/unittests/` folder from now on. Fixed: b:325903709, b:323795674 Doc: http://go/chrome-devtools:move-unit-tests-design Change-Id: I47d727348d115d07f6b04b818359940c4361109a Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5332214 Commit-Queue: Benedikt Meurer <[email protected]> Auto-Submit: Benedikt Meurer <[email protected]> Reviewed-by: Simon Zünd <[email protected]>
1 parent 4f0073d commit 40fdfc4

File tree

9 files changed

+181
-199
lines changed

9 files changed

+181
-199
lines changed

front_end/BUILD.gn

+143
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,146 @@ group("embedder-scripts") {
9393
grd_files = get_target_outputs(":embedder-scripts-gen")
9494
}
9595
}
96+
97+
group("unittests") {
98+
deps = [
99+
"Images:optimize_images",
100+
"core/common:unittests",
101+
"core/dom_extension:unittests",
102+
"core/host:unittests",
103+
"core/i18n:unittests",
104+
"core/i18n/locales",
105+
"core/platform:unittests",
106+
"core/protocol_client:unittests",
107+
"core/root:unittests",
108+
"core/sdk:unittests",
109+
"entrypoints/formatter_worker:unittests",
110+
"entrypoints/heap_snapshot_worker:unittests",
111+
"entrypoints/inspector_main:unittests",
112+
"entrypoints/main:unittests",
113+
"entrypoints/wasmparser_worker:unittests",
114+
"models/autofill_manager:unittests",
115+
"models/bindings:unittests",
116+
"models/breakpoints:unittests",
117+
"models/cpu_profile:unittests",
118+
"models/emulation:unittests",
119+
"models/extensions:unittests",
120+
"models/formatter:unittests",
121+
"models/har:unittests",
122+
"models/heap_snapshot_model:unittests",
123+
"models/issues_manager:unittests",
124+
"models/javascript_metadata:unittests",
125+
"models/logs:unittests",
126+
"models/persistence:unittests",
127+
"models/source_map_scopes:unittests",
128+
"models/text_utils:unittests",
129+
"models/timeline_model:unittests",
130+
"models/trace:unittests",
131+
"models/trace/extras:unittests",
132+
"models/trace/handlers:unittests",
133+
"models/trace/helpers:unittests",
134+
"models/trace/insights:unittests",
135+
"models/trace/root-causes:unittests",
136+
"models/trace/types:unittests",
137+
"models/workspace:unittests",
138+
"models/workspace_diff:unittests",
139+
"panels/accessibility:unittests",
140+
"panels/animation:unittests",
141+
"panels/application:unittests",
142+
"panels/application/components:unittests",
143+
"panels/application/fixtures",
144+
"panels/application/preloading/components:unittests",
145+
"panels/autofill:unittests",
146+
"panels/browser_debugger:unittests",
147+
"panels/changes:unittests",
148+
"panels/console:unittests",
149+
"panels/console_counters:unittests",
150+
"panels/coverage:unittests",
151+
"panels/css_overview:unittests",
152+
"panels/developer_resources:unittests",
153+
"panels/elements:unittests",
154+
"panels/emulation:unittests",
155+
"panels/explain:unittests",
156+
"panels/issues:unittests",
157+
"panels/layer_viewer:unittests",
158+
"panels/layers:unittests",
159+
"panels/lighthouse:unittests",
160+
"panels/linear_memory_inspector:unittests",
161+
"panels/linear_memory_inspector/components:unittests",
162+
"panels/media:unittests",
163+
"panels/mobile_throttling:unittests",
164+
"panels/network:unittests",
165+
"panels/network/components:unittests",
166+
"panels/performance_monitor:unittests",
167+
"panels/profiler:unittests",
168+
"panels/protocol_monitor:unittests",
169+
"panels/protocol_monitor/components:unittests",
170+
"panels/recorder:unittests",
171+
"panels/recorder/components:unittests",
172+
"panels/recorder/converters:unittests",
173+
"panels/recorder/injected/selectors:unittests",
174+
"panels/recorder/models:unittests",
175+
"panels/recorder/testing",
176+
"panels/recorder/util:unittests",
177+
"panels/screencast:unittests",
178+
"panels/search:unittests",
179+
"panels/security:unittests",
180+
"panels/settings/components:unittests",
181+
"panels/settings/emulation/components:unittests",
182+
"panels/settings/emulation/utils:unittests",
183+
"panels/snippets:unittests",
184+
"panels/sources:unittests",
185+
"panels/sources/components:unittests",
186+
"panels/timeline:unittests",
187+
"panels/timeline/components:unittests",
188+
"panels/timeline/fixtures/traces",
189+
"panels/timeline/track_appenders:unittests",
190+
"panels/utils:unittests",
191+
"panels/web_audio:unittests",
192+
"panels/webauthn:unittests",
193+
"services/trace_bounds:unittests",
194+
"testing",
195+
"third_party/chromium/client-variations:unittests",
196+
"third_party/i18n:unittests",
197+
"ui/components/adorners:unittests",
198+
"ui/components/buttons:unittests",
199+
"ui/components/chrome_link:unittests",
200+
"ui/components/code_highlighter:unittests",
201+
"ui/components/data_grid:unittests",
202+
"ui/components/dialogs:unittests",
203+
"ui/components/diff_view:unittests",
204+
"ui/components/expandable_list:unittests",
205+
"ui/components/helpers:unittests",
206+
"ui/components/highlighting:unittests",
207+
"ui/components/icon_button:unittests",
208+
"ui/components/issue_counter:unittests",
209+
"ui/components/linkifier:unittests",
210+
"ui/components/markdown_view:unittests",
211+
"ui/components/menus:unittests",
212+
"ui/components/node_text:unittests",
213+
"ui/components/panel_feedback:unittests",
214+
"ui/components/render_coordinator:unittests",
215+
"ui/components/report_view:unittests",
216+
"ui/components/request_link_icon:unittests",
217+
"ui/components/settings:unittests",
218+
"ui/components/split_view:unittests",
219+
"ui/components/survey_link:unittests",
220+
"ui/components/text_editor:unittests",
221+
"ui/components/text_prompt:unittests",
222+
"ui/components/tree_outline:unittests",
223+
"ui/components/two_states_counter:unittests",
224+
"ui/legacy:copy_stylesheets_for_server",
225+
"ui/legacy:unittests",
226+
"ui/legacy/components/color_picker:unittests",
227+
"ui/legacy/components/inline_editor:unittests",
228+
"ui/legacy/components/object_ui:unittests",
229+
"ui/legacy/components/perf_ui:unittests",
230+
"ui/legacy/components/quick_open:unittests",
231+
"ui/legacy/components/source_frame:unittests",
232+
"ui/legacy/components/utils:unittests",
233+
"ui/legacy/theme_support:unittests",
234+
"ui/legacy/utils:unittests",
235+
"ui/lit-html:unittests",
236+
"ui/visual_logging:unittests",
237+
]
238+
}

scripts/test/run_auto_unittests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def main():
7979
help='Save coverage files to swarming output.')
8080
args = parser.parse_args(sys.argv[1:])
8181

82-
efficiently_recompile.recompile(args.target, 'test/unittests')
82+
efficiently_recompile.recompile(args.target, 'test:unittests')
8383
run_unittests.run_unit_tests_on_ninja_build_target(
8484
args.target, args.no_text_coverage, args.no_html_coverage,
8585
args.coverage, args.expanded_reporting, args.chrome_binary, args.cwd,

scripts/test/run_unittests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def run_tests(chrome_binary, target, no_text_coverage, no_html_coverage,
3232
coverage, expanded_reporting, cwd, log_level, mocha_fgrep,
3333
shuffle, karma_args):
3434
karmaconfig_path = os.path.join(cwd, 'out', target, 'gen', 'test',
35-
'unittests', 'karma.conf.js')
35+
'karma.conf.js')
3636

3737
if not os.path.exists(karmaconfig_path):
3838
log_message('Unable to find Karma config at ' + karmaconfig_path,

test/BUILD.gn

+14-2
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,26 @@ import("../scripts/build/ninja/copy.gni")
77
group("test") {
88
deps = [
99
":config",
10+
":unittests",
1011
"e2e",
1112
"interactions",
1213
"perf",
1314
"shared",
14-
"unittests",
15+
]
16+
}
17+
18+
group("unittests") {
19+
deps = [
20+
":config",
21+
"../front_end:unittests",
22+
"../inspector_overlay:unittests",
23+
"shared",
1524
]
1625
}
1726

1827
copy_to_gen("config") {
19-
sources = [ "base-mocharc.js" ]
28+
sources = [
29+
"base-mocharc.js",
30+
"karma.conf.js",
31+
]
2032
}

test/unittests/karma.conf.js renamed to test/karma.conf.js

+13-11
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ const path = require('path');
99
const glob = require('glob');
1010
const fs = require('fs');
1111
const rimraf = require('rimraf');
12-
const debugCheck = require('./debug-check.js');
13-
const ResultsDb = require('../shared/resultsdb.js');
12+
const {debugCheck} = require('./shared/debug-check.js');
13+
const ResultsDb = require('./shared/resultsdb.js');
1414

1515
const USER_DEFINED_COVERAGE_FOLDERS = process.env['COVERAGE_FOLDERS'];
1616

@@ -28,7 +28,7 @@ const COVERAGE_OUTPUT_DIRECTORY = 'karma-coverage';
2828
// Initially set this to true if the user has enabled it, but we then check
2929
// because coverage only gives accurate results in debug builds, so if this
3030
// build is not a debug build, we disable coverage and log a warning.
31-
let coverageEnabled = COVERAGE_ENABLED_BY_USER;
31+
const coverageEnabled = COVERAGE_ENABLED_BY_USER;
3232
if (coverageEnabled) {
3333
/* Clear out the old coverage directory so you can't accidentally open old,
3434
* out of date coverage output.
@@ -38,19 +38,21 @@ if (coverageEnabled) {
3838
rimraf.sync(fullPathToDirectory);
3939
}
4040

41-
debugCheck(__dirname).then(isDebug => {
42-
if (!isDebug) {
43-
const warning = `The unit tests appear to be running against a non-debug build and
41+
if (!debugCheck(__dirname)) {
42+
const warning = `The unit tests appear to be running against a non-debug build and
4443
your coverage report will be inaccurate and incomplete due to the bundle being rolled-up.
4544
4645
Therefore, coverage has been disabled.
4746
4847
In order to get a complete coverage report please run against a
4948
target with is_debug = true in the args.gn file.`;
50-
console.warn(colors.magenta(warning));
51-
coverageEnabled = false;
52-
}
53-
});
49+
console.warn(colors.magenta(warning));
50+
// TODO(bmeurer): Apparently the debug-check.js was broken before and didn't work,
51+
// at least on the Release bots. Which means that we never disabled coverage for
52+
// those Release builds. We might want to look into updating the infra to also not
53+
// expect the coverage to be there.
54+
// coverageEnabled = false;
55+
}
5456
}
5557
// true by default
5658
const TEXT_COVERAGE_ENABLED = coverageEnabled && !process.env['NO_TEXT_COVERAGE'];
@@ -59,7 +61,7 @@ const HTML_COVERAGE_ENABLED = coverageEnabled && !process.env['NO_HTML_COVERAGE'
5961
// false by default
6062
const SHUFFLE = process.env['SHUFFLE'];
6163

62-
const GEN_DIRECTORY = path.join(__dirname, '..', '..');
64+
const GEN_DIRECTORY = path.join(__dirname, '..');
6365
const ROOT_DIRECTORY = path.join(GEN_DIRECTORY, '..', '..', '..');
6466
const singleRun = !(DEBUG_ENABLED || REPEAT_ENABLED);
6567

test/shared/BUILD.gn

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ node_ts_library("shared") {
88
sources = [
99
"async-scope.ts",
1010
"config.ts",
11+
"debug-check.ts",
1112
"helper.ts",
1213
"mocha-extensions.ts",
1314
"mocha-resultsdb-reporter.ts",
@@ -17,5 +18,6 @@ node_ts_library("shared") {
1718
"snapshots.ts",
1819
"text-color.ts",
1920
]
21+
2022
deps = [ "../conductor:implementation" ]
2123
}

test/unittests/debug-check.js renamed to test/shared/debug-check.ts

+7-9
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
const fs = require('fs').promises;
6-
const path = require('path');
5+
import {readFileSync} from 'fs';
6+
import {join} from 'path';
7+
78
const isDebug = /^\s*is_debug\s*=\s*(.*)/;
89

910
/**
1011
* Tests the args.gn file to ensure that the is_debug flag is set to true.
1112
* We don't cover every case here, for example where is_debug is redefined
1213
* in the gn.args several times. Instead we use the first declaration of
1314
* is_debug's value.
14-
* @param {string} dirName
1515
*/
16-
async function debugCheck(dirName) {
17-
const argsFile = path.join(dirName, '..', '..', '..', 'args.gn');
16+
export function debugCheck(dirName: string): boolean {
17+
const argsFile = join(dirName, '..', '..', 'args.gn');
1818
try {
19-
const fileDetails = await fs.readFile(argsFile, {encoding: 'utf8'});
19+
const fileDetails = readFileSync(argsFile, {encoding: 'utf8'});
2020
for (const line of fileDetails.split('\n')) {
2121
if (!isDebug.test(line)) {
2222
continue;
@@ -40,9 +40,7 @@ async function debugCheck(dirName) {
4040
// By default, a DevTools build is always a debug build,
4141
// unless `is_debug` is explicitly set to false
4242
return true;
43-
} catch (error) {
43+
} catch {
4444
return false;
4545
}
4646
}
47-
48-
module.exports = debugCheck;

test/unittests/BUILD.gn

-33
This file was deleted.

0 commit comments

Comments
 (0)