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

Side by Side Diff: test/runner/isolate_listener_test.dart

Issue 1390883002: Make Suite contain a single Group. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 5 years, 2 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/engine_test.dart ('k') | test/runner/load_suite_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 @TestOn("vm") 5 @TestOn("vm")
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:isolate'; 8 import 'dart:isolate';
9 9
10 import 'package:test/src/backend/group.dart';
10 import 'package:test/src/backend/invoker.dart'; 11 import 'package:test/src/backend/invoker.dart';
11 import 'package:test/src/backend/live_test.dart'; 12 import 'package:test/src/backend/live_test.dart';
12 import 'package:test/src/backend/metadata.dart'; 13 import 'package:test/src/backend/metadata.dart';
13 import 'package:test/src/backend/state.dart'; 14 import 'package:test/src/backend/state.dart';
14 import 'package:test/src/backend/suite.dart'; 15 import 'package:test/src/backend/suite.dart';
15 import 'package:test/src/runner/vm/isolate_listener.dart'; 16 import 'package:test/src/runner/vm/isolate_listener.dart';
16 import 'package:test/src/runner/vm/isolate_test.dart'; 17 import 'package:test/src/runner/vm/isolate_test.dart';
17 import 'package:test/src/util/remote_exception.dart'; 18 import 'package:test/src/util/remote_exception.dart';
18 import 'package:test/test.dart'; 19 import 'package:test/test.dart';
19 20
(...skipping 14 matching lines...) Expand all
34 if (_isolate != null) _isolate.kill(); 35 if (_isolate != null) _isolate.kill();
35 _isolate = null; 36 _isolate = null;
36 37
37 if (_liveTest != null) _liveTest.close(); 38 if (_liveTest != null) _liveTest.close();
38 _liveTest = null; 39 _liveTest = null;
39 }); 40 });
40 41
41 test("sends a list of available tests and groups on startup", () async { 42 test("sends a list of available tests and groups on startup", () async {
42 var response = await (await _spawnIsolate(_successfulTests)).first; 43 var response = await (await _spawnIsolate(_successfulTests)).first;
43 expect(response, containsPair("type", "success")); 44 expect(response, containsPair("type", "success"));
44 expect(response, contains("entries")); 45 expect(response, contains("root"));
45 46
46 var tests = response["entries"]; 47 var root = response["root"];
48 expect(root, containsPair("type", "group"));
49 expect(root, containsPair("name", null));
50
51 var tests = root["entries"];
47 expect(tests, hasLength(3)); 52 expect(tests, hasLength(3));
48 expect(tests[0], containsPair("name", "successful 1")); 53 expect(tests[0], containsPair("name", "successful 1"));
49 expect(tests[1], containsPair("name", "successful 2")); 54 expect(tests[1], containsPair("name", "successful 2"));
50 expect(tests[2], containsPair("type", "group")); 55 expect(tests[2], containsPair("type", "group"));
51 expect(tests[2], containsPair("name", "successful")); 56 expect(tests[2], containsPair("name", "successful"));
52 expect(tests[2], contains("entries")); 57 expect(tests[2], contains("entries"));
53 expect(tests[2]["entries"][0], containsPair("name", "successful 3")); 58 expect(tests[2]["entries"][0], containsPair("name", "successful 3"));
54 }); 59 });
55 60
56 test("waits for a returned future sending a response", () async { 61 test("waits for a returned future sending a response", () async {
57 var response = await (await _spawnIsolate(_asyncTests)).first; 62 var response = await (await _spawnIsolate(_asyncTests)).first;
58 expect(response, containsPair("type", "success")); 63 expect(response, containsPair("type", "success"));
59 expect(response, contains("entries")); 64 expect(response, contains("root"));
60 65
61 var tests = response["entries"]; 66 var tests = response["root"]["entries"];
62 expect(tests, hasLength(3)); 67 expect(tests, hasLength(3));
63 expect(tests[0], containsPair("name", "successful 1")); 68 expect(tests[0], containsPair("name", "successful 1"));
64 expect(tests[1], containsPair("name", "successful 2")); 69 expect(tests[1], containsPair("name", "successful 2"));
65 expect(tests[2], containsPair("name", "successful 3")); 70 expect(tests[2], containsPair("name", "successful 3"));
66 }); 71 });
67 72
68 test("sends an error response if loading fails", () async { 73 test("sends an error response if loading fails", () async {
69 var response = await (await _spawnIsolate(_loadError)).first; 74 var response = await (await _spawnIsolate(_loadError)).first;
70 expect(response, containsPair("type", "error")); 75 expect(response, containsPair("type", "error"));
71 expect(response, contains("error")); 76 expect(response, contains("error"));
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 }); 264 });
260 } 265 }
261 266
262 /// Loads the first test defined in [entryPoint] in another isolate. 267 /// Loads the first test defined in [entryPoint] in another isolate.
263 /// 268 ///
264 /// This test will be automatically closed when the test is finished. 269 /// This test will be automatically closed when the test is finished.
265 Future<LiveTest> _isolateTest(void entryPoint(SendPort sendPort)) async { 270 Future<LiveTest> _isolateTest(void entryPoint(SendPort sendPort)) async {
266 var response = await (await _spawnIsolate(entryPoint)).first; 271 var response = await (await _spawnIsolate(entryPoint)).first;
267 expect(response, containsPair("type", "success")); 272 expect(response, containsPair("type", "success"));
268 273
269 var testMap = response["entries"].first; 274 var testMap = response["root"]["entries"].first;
270 expect(testMap, containsPair("type", "test")); 275 expect(testMap, containsPair("type", "test"));
271 var metadata = new Metadata.deserialize(testMap["metadata"]); 276 var metadata = new Metadata.deserialize(testMap["metadata"]);
272 var test = new IsolateTest(testMap["name"], metadata, testMap["sendPort"]); 277 var test = new IsolateTest(testMap["name"], metadata, testMap["sendPort"]);
273 var suite = new Suite([test]); 278 var suite = new Suite(new Group.root([test]));
274 _liveTest = test.load(suite); 279 _liveTest = test.load(suite);
275 return _liveTest; 280 return _liveTest;
276 } 281 }
277 282
278 /// Spawns an isolate from [entryPoint], sends it a new [SendPort], and returns 283 /// Spawns an isolate from [entryPoint], sends it a new [SendPort], and returns
279 /// the corresponding [ReceivePort]. 284 /// the corresponding [ReceivePort].
280 /// 285 ///
281 /// This isolate will be automatically killed when the test is finished. 286 /// This isolate will be automatically killed when the test is finished.
282 Future<ReceivePort> _spawnIsolate(void entryPoint(SendPort sendPort)) async { 287 Future<ReceivePort> _spawnIsolate(void entryPoint(SendPort sendPort)) async {
283 var receivePort = new ReceivePort(); 288 var receivePort = new ReceivePort();
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 /// An isolate entrypoint that defines a test that prints twice. 403 /// An isolate entrypoint that defines a test that prints twice.
399 void _printTest(SendPort sendPort) { 404 void _printTest(SendPort sendPort) {
400 IsolateListener.start(sendPort, new Metadata(), () => () { 405 IsolateListener.start(sendPort, new Metadata(), () => () {
401 test("prints", () { 406 test("prints", () {
402 print("Hello,"); 407 print("Hello,");
403 return new Future(() => print("world!")); 408 return new Future(() => print("world!"));
404 }); 409 });
405 }); 410 });
406 } 411 }
407 412
OLDNEW
« no previous file with comments | « test/runner/engine_test.dart ('k') | test/runner/load_suite_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698