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

Side by Side Diff: test/utils.dart

Issue 1055083004: Normalize handling of the package root in the runner. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Unused import Created 5 years, 8 months 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 | « test/runner/loader_test.dart ('k') | no next file » | 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.test.utils; 5 library test.test.utils;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:test/src/backend/invoker.dart'; 10 import 'package:test/src/backend/invoker.dart';
11 import 'package:test/src/backend/live_test.dart'; 11 import 'package:test/src/backend/live_test.dart';
12 import 'package:test/src/backend/metadata.dart'; 12 import 'package:test/src/backend/metadata.dart';
13 import 'package:test/src/backend/state.dart'; 13 import 'package:test/src/backend/state.dart';
14 import 'package:test/src/backend/suite.dart'; 14 import 'package:test/src/backend/suite.dart';
15 import 'package:test/src/runner/application_exception.dart';
15 import 'package:test/src/runner/load_exception.dart'; 16 import 'package:test/src/runner/load_exception.dart';
16 import 'package:test/src/util/remote_exception.dart'; 17 import 'package:test/src/util/remote_exception.dart';
17 import 'package:test/test.dart'; 18 import 'package:test/test.dart';
18 19
19 /// The string representation of an untyped closure with no arguments. 20 /// The string representation of an untyped closure with no arguments.
20 /// 21 ///
21 /// This differs between dart2js and the VM. 22 /// This differs between dart2js and the VM.
22 final String closureString = (() {}).toString(); 23 final String closureString = (() {}).toString();
23 24
24 // The last state change detected via [expectStates]. 25 // The last state change detected via [expectStates].
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } else { 162 } else {
162 return mismatchDescription 163 return mismatchDescription
163 .add('inner error ') 164 .add('inner error ')
164 .addDescriptionOf(item) 165 .addDescriptionOf(item)
165 .add(' is not ') 166 .add(' is not ')
166 .addDescriptionOf(_innerError); 167 .addDescriptionOf(_innerError);
167 } 168 }
168 } 169 }
169 } 170 }
170 171
172 /// Returns a matcher that matches a [ApplicationException] with the given
173 /// [message].
174 ///
175 /// [message] can be a string or a [Matcher].
176 Matcher isApplicationException(message) =>
177 new _IsApplicationException(wrapMatcher(message));
178
179 class _IsApplicationException extends Matcher {
180 final Matcher _message;
181
182 _IsApplicationException(this._message);
183
184 bool matches(item, Map matchState) =>
185 item is ApplicationException && _message.matches(item.message, matchState) ;
186
187 Description describe(Description description) =>
188 description.add('a ApplicationException with message ')
189 .addDescriptionOf(_message);
190
191 Description describeMismatch(item, Description mismatchDescription,
192 Map matchState, bool verbose) {
193 if (item is! ApplicationException) {
194 return mismatchDescription.addDescriptionOf(item)
195 .add('is not a ApplicationException');
196 } else {
197 return mismatchDescription
198 .add('message ')
199 .addDescriptionOf(item)
200 .add(' is not ')
201 .addDescriptionOf(_message);
202 }
203 }
204 }
205
171 /// Returns a [Future] that completes after pumping the event queue [times] 206 /// Returns a [Future] that completes after pumping the event queue [times]
172 /// times. 207 /// times.
173 /// 208 ///
174 /// By default, this should pump the event queue enough times to allow any code 209 /// By default, this should pump the event queue enough times to allow any code
175 /// to run, as long as it's not waiting on some external event. 210 /// to run, as long as it's not waiting on some external event.
176 Future pumpEventQueue([int times=20]) { 211 Future pumpEventQueue([int times=20]) {
177 if (times == 0) return new Future.value(); 212 if (times == 0) return new Future.value();
178 // Use [new Future] future to allow microtask events to finish. The [new 213 // Use [new Future] future to allow microtask events to finish. The [new
179 // Future.value] constructor uses scheduleMicrotask itself and would therefore 214 // Future.value] constructor uses scheduleMicrotask itself and would therefore
180 // not wait for microtask callbacks that are scheduled after invoking this 215 // not wait for microtask callbacks that are scheduled after invoking this
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 }); 273 });
239 }); 274 });
240 275
241 return liveTest.run().then((_) { 276 return liveTest.run().then((_) {
242 expectTestPassed(liveTest); 277 expectTestPassed(liveTest);
243 // Ensure that the outer test doesn't complete until the inner future 278 // Ensure that the outer test doesn't complete until the inner future
244 // completes. 279 // completes.
245 return future; 280 return future;
246 }); 281 });
247 } 282 }
OLDNEW
« no previous file with comments | « test/runner/loader_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698