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

Side by Side Diff: lib/src/backend/invoker.dart

Issue 1469863005: Add JSON protocol support for groups. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 5 years 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 | « json_reporter.schema.json ('k') | lib/src/backend/live_test.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.backend.invoker; 5 library test.backend.invoker;
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 '../backend/group.dart';
11 import '../frontend/expect.dart'; 12 import '../frontend/expect.dart';
12 import '../utils.dart'; 13 import '../utils.dart';
13 import 'closed_exception.dart'; 14 import 'closed_exception.dart';
14 import 'live_test.dart'; 15 import 'live_test.dart';
15 import 'live_test_controller.dart'; 16 import 'live_test_controller.dart';
16 import 'metadata.dart'; 17 import 'metadata.dart';
17 import 'operating_system.dart'; 18 import 'operating_system.dart';
18 import 'outstanding_callback_counter.dart'; 19 import 'outstanding_callback_counter.dart';
19 import 'state.dart'; 20 import 'state.dart';
20 import 'suite.dart'; 21 import 'suite.dart';
21 import 'test.dart'; 22 import 'test.dart';
22 import 'test_platform.dart'; 23 import 'test_platform.dart';
23 24
24 /// A test in this isolate. 25 /// A test in this isolate.
25 class LocalTest extends Test { 26 class LocalTest extends Test {
26 final String name; 27 final String name;
27 final Metadata metadata; 28 final Metadata metadata;
28 29
29 /// The test body. 30 /// The test body.
30 final AsyncFunction _body; 31 final AsyncFunction _body;
31 32
32 LocalTest(this.name, this.metadata, body()) 33 LocalTest(this.name, this.metadata, body())
33 : _body = body; 34 : _body = body;
34 35
35 /// Loads a single runnable instance of this test. 36 /// Loads a single runnable instance of this test.
36 LiveTest load(Suite suite) { 37 LiveTest load(Suite suite, {Iterable<Group> groups}) {
37 var invoker = new Invoker._(suite, this); 38 var invoker = new Invoker._(suite, this, groups: groups);
38 return invoker.liveTest; 39 return invoker.liveTest;
39 } 40 }
40 41
41 Test forPlatform(TestPlatform platform, {OperatingSystem os}) { 42 Test forPlatform(TestPlatform platform, {OperatingSystem os}) {
42 if (!metadata.testOn.evaluate(platform, os: os)) return null; 43 if (!metadata.testOn.evaluate(platform, os: os)) return null;
43 return new LocalTest(name, metadata.forPlatform(platform, os: os), _body); 44 return new LocalTest(name, metadata.forPlatform(platform, os: os), _body);
44 } 45 }
45 } 46 }
46 47
47 /// The class responsible for managing the lifecycle of a single local test. 48 /// The class responsible for managing the lifecycle of a single local test.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 /// 111 ///
111 /// Tracking this ensures that [_timeoutTimer] isn't created in a 112 /// Tracking this ensures that [_timeoutTimer] isn't created in a
112 /// timer-mocking zone created by the test. 113 /// timer-mocking zone created by the test.
113 Zone _invokerZone; 114 Zone _invokerZone;
114 115
115 /// The timer for tracking timeouts. 116 /// The timer for tracking timeouts.
116 /// 117 ///
117 /// This will be `null` until the test starts running. 118 /// This will be `null` until the test starts running.
118 Timer _timeoutTimer; 119 Timer _timeoutTimer;
119 120
120 Invoker._(Suite suite, LocalTest test) { 121 Invoker._(Suite suite, LocalTest test, {Iterable<Group> groups}) {
121 _controller = new LiveTestController( 122 _controller = new LiveTestController(
122 suite, test, _onRun, _onCloseCompleter.complete); 123 suite, test, _onRun, _onCloseCompleter.complete, groups: groups);
123 } 124 }
124 125
125 /// Tells the invoker that there's a callback running that it should wait for 126 /// Tells the invoker that there's a callback running that it should wait for
126 /// before considering the test successful. 127 /// before considering the test successful.
127 /// 128 ///
128 /// Each call to [addOutstandingCallback] should be followed by a call to 129 /// Each call to [addOutstandingCallback] should be followed by a call to
129 /// [removeOutstandingCallback] once the callbak is no longer running. Note 130 /// [removeOutstandingCallback] once the callbak is no longer running. Note
130 /// that only successful tests wait for outstanding callbacks; as soon as a 131 /// that only successful tests wait for outstanding callbacks; as soon as a
131 /// test experiences an error, any further calls to [addOutstandingCallback] 132 /// test experiences an error, any further calls to [addOutstandingCallback]
132 /// or [removeOutstandingCallback] will do nothing. 133 /// or [removeOutstandingCallback] will do nothing.
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 // outstanding callback counters at once. 278 // outstanding callback counters at once.
278 _counterKey: outstandingCallbacksForBody, 279 _counterKey: outstandingCallbacksForBody,
279 _closableKey: true 280 _closableKey: true
280 }, 281 },
281 zoneSpecification: new ZoneSpecification( 282 zoneSpecification: new ZoneSpecification(
282 print: (self, parent, zone, line) => _controller.print(line)), 283 print: (self, parent, zone, line) => _controller.print(line)),
283 onError: _handleError); 284 onError: _handleError);
284 }); 285 });
285 } 286 }
286 } 287 }
OLDNEW
« no previous file with comments | « json_reporter.schema.json ('k') | lib/src/backend/live_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698