Skip to content

Commit 0d0aa65

Browse files
committed
Move debug functionality to a --debug flag, disentangle --pause-after-load
1 parent 99d2dfc commit 0d0aa65

File tree

9 files changed

+29
-8
lines changed

9 files changed

+29
-8
lines changed

pkgs/test/doc/json_reporter.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class DebugEvent extends Event {
156156

157157
A debug event is emitted after (although not necessarily directly after) a
158158
`SuiteEvent`, and includes information about how to debug that suite. It's only
159-
emitted if the `--pause-after-load` flag is passed to the test runner.
159+
emitted if the `--debug` flag is passed to the test runner.
160160

161161
Note that the `remoteDebugger` URL refers to a remote debugger whose protocol
162162
may differ based on the browser the suite is running on. You can tell which

pkgs/test/lib/src/runner/browser/platform.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,12 +397,12 @@ class BrowserPlatform extends PlatformPlugin
397397
.resolve('packages/test/src/runner/browser/static/index.html')
398398
.replace(queryParameters: {
399399
'managerUrl': webSocketUrl.toString(),
400-
'debug': _config.pauseAfterLoad.toString()
400+
'debug': _config.debug.toString()
401401
});
402402

403403
var future = BrowserManager.start(
404404
browser, hostUrl, completer.future, _browserSettings[browser],
405-
debug: _config.pauseAfterLoad);
405+
debug: _config.debug);
406406

407407
// Store null values for browsers that error out so we know not to load them
408408
// again.

pkgs/test/test/runner/configuration/configuration_test.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ void main() {
1818
expect(merged.help, isFalse);
1919
expect(merged.version, isFalse);
2020
expect(merged.pauseAfterLoad, isFalse);
21+
expect(merged.debug, isFalse);
2122
expect(merged.color, equals(canUseSpecialChars));
2223
expect(merged.configurationPath, equals('dart_test.yaml'));
2324
expect(merged.dart2jsPath, equals(p.join(sdkDir, 'bin', 'dart2js')));
@@ -33,6 +34,7 @@ void main() {
3334
help: true,
3435
version: true,
3536
pauseAfterLoad: true,
37+
debug: true,
3638
color: true,
3739
configurationPath: "special_test.yaml",
3840
dart2jsPath: "/tmp/dart2js",
@@ -45,6 +47,7 @@ void main() {
4547
expect(merged.help, isTrue);
4648
expect(merged.version, isTrue);
4749
expect(merged.pauseAfterLoad, isTrue);
50+
expect(merged.debug, isTrue);
4851
expect(merged.color, isTrue);
4952
expect(merged.configurationPath, equals("special_test.yaml"));
5053
expect(merged.dart2jsPath, equals("/tmp/dart2js"));
@@ -60,6 +63,7 @@ void main() {
6063
help: true,
6164
version: true,
6265
pauseAfterLoad: true,
66+
debug: true,
6367
color: true,
6468
configurationPath: "special_test.yaml",
6569
dart2jsPath: "/tmp/dart2js",
@@ -72,6 +76,7 @@ void main() {
7276
expect(merged.help, isTrue);
7377
expect(merged.version, isTrue);
7478
expect(merged.pauseAfterLoad, isTrue);
79+
expect(merged.debug, isTrue);
7580
expect(merged.color, isTrue);
7681
expect(merged.configurationPath, equals("special_test.yaml"));
7782
expect(merged.dart2jsPath, equals("/tmp/dart2js"));
@@ -89,6 +94,7 @@ void main() {
8994
help: true,
9095
version: false,
9196
pauseAfterLoad: true,
97+
debug: true,
9298
color: false,
9399
configurationPath: "special_test.yaml",
94100
dart2jsPath: "/tmp/dart2js",
@@ -101,6 +107,7 @@ void main() {
101107
help: false,
102108
version: true,
103109
pauseAfterLoad: false,
110+
debug: false,
104111
color: true,
105112
configurationPath: "test_special.yaml",
106113
dart2jsPath: "../dart2js",
@@ -114,6 +121,7 @@ void main() {
114121
expect(merged.help, isFalse);
115122
expect(merged.version, isTrue);
116123
expect(merged.pauseAfterLoad, isFalse);
124+
expect(merged.debug, isFalse);
117125
expect(merged.color, isTrue);
118126
expect(merged.configurationPath, equals("test_special.yaml"));
119127
expect(merged.dart2jsPath, equals("../dart2js"));

pkgs/test/test/runner/runner_test.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,10 @@ Usage: pub run test [files or directories...]
8989
(defaults to "30s")
9090
9191
--pause-after-load Pauses for debugging before any tests execute.
92-
Implies --concurrency=1 and --timeout=none.
92+
Implies --concurrency=1, --debug, and --timeout=none.
9393
Currently only supported for browser tests.
9494
95+
--debug Runs the VM and Chrome tests in debug mode.
9596
--[no-]chain-stack-traces Chained stack traces to provide greater exception details
9697
especially for asynchronous code. It may be useful to disable
9798
to provide improved test performance but at the cost of

pkgs/test_core/lib/src/runner.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class Runner {
9898
// https://github.com/dart-lang/sdk/issues/31308 is resolved.
9999
if (!_silentObservatory &&
100100
runTimes.contains(Runtime.vm) &&
101-
_config.pauseAfterLoad) {
101+
_config.debug) {
102102
warn('You should set `SILENT_OBSERVATORY` to true when debugging the '
103103
'VM as it will output the observatory URL by '
104104
'default.\nThis breaks the various reporter contracts.'

pkgs/test_core/lib/src/runner/configuration.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ class Configuration {
5151
bool get pauseAfterLoad => _pauseAfterLoad ?? false;
5252
final bool _pauseAfterLoad;
5353

54+
/// Whether to run browsers in their respective debug modes
55+
bool get debug => pauseAfterLoad || (_debug ?? false);
56+
final bool _debug;
57+
5458
/// The path to the file from which to load more configuration information.
5559
///
5660
/// This is *not* resolved automatically.
@@ -210,6 +214,7 @@ class Configuration {
210214
{bool help,
211215
bool version,
212216
bool pauseAfterLoad,
217+
bool debug,
213218
bool color,
214219
String configurationPath,
215220
String dart2jsPath,
@@ -254,6 +259,7 @@ class Configuration {
254259
help: help,
255260
version: version,
256261
pauseAfterLoad: pauseAfterLoad,
262+
debug: debug,
257263
color: color,
258264
configurationPath: configurationPath,
259265
dart2jsPath: dart2jsPath,
@@ -311,6 +317,7 @@ class Configuration {
311317
{bool help,
312318
bool version,
313319
bool pauseAfterLoad,
320+
bool debug,
314321
bool color,
315322
String configurationPath,
316323
String dart2jsPath,
@@ -332,6 +339,7 @@ class Configuration {
332339
: _help = help,
333340
_version = version,
334341
_pauseAfterLoad = pauseAfterLoad,
342+
_debug = debug,
335343
_color = color,
336344
_configurationPath = configurationPath,
337345
_dart2jsPath = dart2jsPath,

pkgs/test_core/lib/src/runner/configuration/args.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,12 @@ final ArgParser _parser = (() {
8282
defaultsTo: '30s');
8383
parser.addFlag("pause-after-load",
8484
help: 'Pauses for debugging before any tests execute.\n'
85-
'Implies --concurrency=1 and --timeout=none.\n'
85+
'Implies --concurrency=1, --debug, and --timeout=none.\n'
8686
'Currently only supported for browser tests.',
8787
negatable: false);
88+
parser.addFlag("debug",
89+
help: 'Runs the VM and Chrome tests in debug mode.',
90+
negatable: false);
8891
parser.addFlag("chain-stack-traces",
8992
help: 'Chained stack traces to provide greater exception details\n'
9093
'especially for asynchronous code. It may be useful to disable\n'
@@ -207,6 +210,7 @@ class _Parser {
207210
chainStackTraces: _ifParsed('chain-stack-traces'),
208211
jsTrace: _ifParsed('js-trace'),
209212
pauseAfterLoad: _ifParsed('pause-after-load'),
213+
debug: _ifParsed('debug'),
210214
color: _ifParsed('color'),
211215
configurationPath: _ifParsed('configuration'),
212216
dart2jsPath: _ifParsed('dart2js-path'),

pkgs/test_core/lib/src/runner/reporter/json.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class JsonReporter implements Reporter {
172172
if (suite is LoadSuite) {
173173
suite.suite.then((runnerSuite) {
174174
_suiteIDs[runnerSuite] = id;
175-
if (!_config.pauseAfterLoad) return;
175+
if (!_config.debug) return;
176176

177177
// TODO(nweiz): test this when we have a library for communicating with
178178
// the Chrome remote debugger, or when we have VM debug support.

pkgs/test_core/lib/src/runner/vm/platform.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class VMPlatform extends PlatformPlugin {
6161

6262
VMEnvironment environment;
6363
IsolateRef isolateRef;
64-
if (_config.pauseAfterLoad) {
64+
if (_config.debug) {
6565
// Print an empty line because the VM prints an "Observatory listening on"
6666
// line and we don't want that to end up on the same line as the reporter
6767
// info.

0 commit comments

Comments
 (0)