Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: lib/src/runner/load_suite.dart

Issue 1422963004: Add RunnerSuite.{on,is}Debugging properties. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/src/runner/browser/suite.dart ('k') | lib/src/runner/runner_suite.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.runner.load_suite; 5 library test.runner.load_suite;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:stack_trace/stack_trace.dart'; 9 import 'package:stack_trace/stack_trace.dart';
10 10
11 import '../../test.dart'; 11 import '../../test.dart';
12 import '../backend/group.dart'; 12 import '../backend/group.dart';
13 import '../backend/invoker.dart'; 13 import '../backend/invoker.dart';
14 import '../backend/metadata.dart'; 14 import '../backend/metadata.dart';
15 import '../backend/suite.dart';
15 import '../backend/test.dart'; 16 import '../backend/test.dart';
16 import '../backend/test_platform.dart'; 17 import '../backend/test_platform.dart';
17 import '../utils.dart'; 18 import '../utils.dart';
18 import 'load_exception.dart'; 19 import 'load_exception.dart';
19 import 'runner_suite.dart'; 20 import 'runner_suite.dart';
20 import 'vm/environment.dart'; 21 import 'vm/environment.dart';
21 22
22 /// A [Suite] emitted by a [Loader] that provides a test-like interface for 23 /// A [Suite] emitted by a [Loader] that provides a test-like interface for
23 /// loading a test file. 24 /// loading a test file.
24 /// 25 ///
25 /// This is used to expose the current status of test loading to the user. It's 26 /// This is used to expose the current status of test loading to the user. It's
26 /// important to provide users visibility into what's taking a long time and 27 /// important to provide users visibility into what's taking a long time and
27 /// where failures occur. And since some tests may be loaded at the same time as 28 /// where failures occur. And since some tests may be loaded at the same time as
28 /// others are run, it's useful to provide that visibility in the form of a test 29 /// others are run, it's useful to provide that visibility in the form of a test
29 /// suite so that it can integrate well into the existing reporting interface 30 /// suite so that it can integrate well into the existing reporting interface
30 /// without too much extra logic. 31 /// without too much extra logic.
31 /// 32 ///
32 /// A suite is constructed with logic necessary to produce a test suite. As with 33 /// A suite is constructed with logic necessary to produce a test suite. As with
33 /// a normal test body, this logic isn't run until [LiveTest.run] is called. The 34 /// a normal test body, this logic isn't run until [LiveTest.run] is called. The
34 /// suite itself is returned by [suite] once it's avaialble, but any errors or 35 /// suite itself is returned by [suite] once it's avaialble, but any errors or
35 /// prints will be emitted through the running [LiveTest]. 36 /// prints will be emitted through the running [LiveTest].
36 class LoadSuite extends RunnerSuite { 37 class LoadSuite extends Suite implements RunnerSuite {
38 final environment = const VMEnvironment();
39 final isDebugging = false;
40 final onDebugging = new StreamController<bool>().stream;
41
37 /// A future that completes to the loaded suite once the suite's test has been 42 /// A future that completes to the loaded suite once the suite's test has been
38 /// run and completed successfully. 43 /// run and completed successfully.
39 /// 44 ///
40 /// This will return `null` if the suite is unavailable for some reason (for 45 /// This will return `null` if the suite is unavailable for some reason (for
41 /// example if an error occurred while loading it). 46 /// example if an error occurred while loading it).
42 final Future<RunnerSuite> suite; 47 final Future<RunnerSuite> suite;
43 48
44 /// Returns the test that loads the suite. 49 /// Returns the test that loads the suite.
45 /// 50 ///
46 /// Load suites are guaranteed to only contain one test. This is a utility 51 /// Load suites are guaranteed to only contain one test. This is a utility
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 }, platform: platform); 106 }, platform: platform);
102 } 107 }
103 108
104 /// A utility constructor for a load suite that just emits [suite]. 109 /// A utility constructor for a load suite that just emits [suite].
105 factory LoadSuite.forSuite(RunnerSuite suite) { 110 factory LoadSuite.forSuite(RunnerSuite suite) {
106 return new LoadSuite("loading ${suite.path}", () => suite, 111 return new LoadSuite("loading ${suite.path}", () => suite,
107 platform: suite.platform); 112 platform: suite.platform);
108 } 113 }
109 114
110 LoadSuite._(String name, void body(), this.suite, {TestPlatform platform}) 115 LoadSuite._(String name, void body(), this.suite, {TestPlatform platform})
111 : super(const VMEnvironment(), new Group.root([ 116 : super(new Group.root([
112 new LocalTest(name, 117 new LocalTest(name,
113 new Metadata(timeout: new Timeout(new Duration(minutes: 5))), 118 new Metadata(timeout: new Timeout(new Duration(minutes: 5))),
114 body) 119 body)
115 ]), platform: platform); 120 ]), platform: platform);
116 121
117 /// A constructor used by [changeSuite]. 122 /// A constructor used by [changeSuite].
118 LoadSuite._changeSuite(LoadSuite old, Future<RunnerSuite> this.suite) 123 LoadSuite._changeSuite(LoadSuite old, Future<RunnerSuite> this.suite)
119 : super(const VMEnvironment(), old.group, platform: old.platform); 124 : super(old.group, platform: old.platform);
120 125
121 /// Creates a new [LoadSuite] that's identical to this one, but that 126 /// Creates a new [LoadSuite] that's identical to this one, but that
122 /// transforms [suite] once it's loaded. 127 /// transforms [suite] once it's loaded.
123 /// 128 ///
124 /// If [suite] completes to `null`, [change] won't be run. 129 /// If [suite] completes to `null`, [change] won't be run.
125 LoadSuite changeSuite(RunnerSuite change(RunnerSuite suite)) { 130 LoadSuite changeSuite(RunnerSuite change(RunnerSuite suite)) {
126 return new LoadSuite._changeSuite(this, suite.then((loadedSuite) { 131 return new LoadSuite._changeSuite(this, suite.then((loadedSuite) {
127 if (loadedSuite == null) return null; 132 if (loadedSuite == null) return null;
128 return change(loadedSuite); 133 return change(loadedSuite);
129 })); 134 }));
130 } 135 }
131 136
132 /// Runs the test and returns the suite. 137 /// Runs the test and returns the suite.
133 /// 138 ///
134 /// Rather than emitting errors through a [LiveTest], this just pipes them 139 /// Rather than emitting errors through a [LiveTest], this just pipes them
135 /// through the return value. 140 /// through the return value.
136 Future<RunnerSuite> getSuite() async { 141 Future<RunnerSuite> getSuite() async {
137 var liveTest = await test.load(this); 142 var liveTest = await test.load(this);
138 liveTest.onPrint.listen(print); 143 liveTest.onPrint.listen(print);
139 await liveTest.run(); 144 await liveTest.run();
140 145
141 if (liveTest.errors.isEmpty) return await suite; 146 if (liveTest.errors.isEmpty) return await suite;
142 147
143 var error = liveTest.errors.first; 148 var error = liveTest.errors.first;
144 await new Future.error(error.error, error.stackTrace); 149 await new Future.error(error.error, error.stackTrace);
145 throw 'unreachable'; 150 throw 'unreachable';
146 } 151 }
152
153 Future close() async {}
147 } 154 }
OLDNEW
« no previous file with comments | « lib/src/runner/browser/suite.dart ('k') | lib/src/runner/runner_suite.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698