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

Side by Side Diff: test/runner/browser/loader_test.dart

Issue 1379203002: Refactor groups to pipe them through to the runner. (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/backend/declarer_test.dart ('k') | test/runner/engine_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:io'; 7 import 'dart:io';
8 8
9 import 'package:path/path.dart' as p; 9 import 'package:path/path.dart' as p;
10 import 'package:test/src/backend/state.dart'; 10 import 'package:test/src/backend/state.dart';
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 var loadSuite = suites.first; 59 var loadSuite = suites.first;
60 suite = await loadSuite.getSuite(); 60 suite = await loadSuite.getSuite();
61 }); 61 });
62 62
63 test("returns a suite with the file path and platform", () { 63 test("returns a suite with the file path and platform", () {
64 expect(suite.path, equals(p.join(_sandbox, 'a_test.dart'))); 64 expect(suite.path, equals(p.join(_sandbox, 'a_test.dart')));
65 expect(suite.platform, equals(TestPlatform.chrome)); 65 expect(suite.platform, equals(TestPlatform.chrome));
66 }); 66 });
67 67
68 test("returns tests with the correct names", () { 68 test("returns tests with the correct names", () {
69 expect(suite.tests, hasLength(3)); 69 expect(suite.entries, hasLength(3));
70 expect(suite.tests[0].name, equals("success")); 70 expect(suite.entries[0].name, equals("success"));
71 expect(suite.tests[1].name, equals("failure")); 71 expect(suite.entries[1].name, equals("failure"));
72 expect(suite.tests[2].name, equals("error")); 72 expect(suite.entries[2].name, equals("error"));
73 }); 73 });
74 74
75 test("can load and run a successful test", () { 75 test("can load and run a successful test", () {
76 var liveTest = suite.tests[0].load(suite); 76 var liveTest = suite.entries[0].load(suite);
77 77
78 expectStates(liveTest, [ 78 expectStates(liveTest, [
79 const State(Status.running, Result.success), 79 const State(Status.running, Result.success),
80 const State(Status.complete, Result.success) 80 const State(Status.complete, Result.success)
81 ]); 81 ]);
82 expectErrors(liveTest, []); 82 expectErrors(liveTest, []);
83 83
84 return liveTest.run().whenComplete(() => liveTest.close()); 84 return liveTest.run().whenComplete(() => liveTest.close());
85 }); 85 });
86 86
87 test("can load and run a failing test", () { 87 test("can load and run a failing test", () {
88 var liveTest = suite.tests[1].load(suite); 88 var liveTest = suite.entries[1].load(suite);
89 expectSingleFailure(liveTest); 89 expectSingleFailure(liveTest);
90 return liveTest.run().whenComplete(() => liveTest.close()); 90 return liveTest.run().whenComplete(() => liveTest.close());
91 }); 91 });
92 }); 92 });
93 93
94 94
95 test("loads tests that are defined asynchronously", () async { 95 test("loads tests that are defined asynchronously", () async {
96 new File(p.join(_sandbox, 'a_test.dart')).writeAsStringSync(""" 96 new File(p.join(_sandbox, 'a_test.dart')).writeAsStringSync("""
97 import 'dart:async'; 97 import 'dart:async';
98 98
(...skipping 12 matching lines...) Expand all
111 }); 111 });
112 }); 112 });
113 } 113 }
114 """); 114 """);
115 115
116 var suites = await _loader.loadFile(p.join(_sandbox, 'a_test.dart')) 116 var suites = await _loader.loadFile(p.join(_sandbox, 'a_test.dart'))
117 .toList(); 117 .toList();
118 expect(suites, hasLength(1)); 118 expect(suites, hasLength(1));
119 var loadSuite = suites.first; 119 var loadSuite = suites.first;
120 var suite = await loadSuite.getSuite(); 120 var suite = await loadSuite.getSuite();
121 expect(suite.tests, hasLength(3)); 121 expect(suite.entries, hasLength(3));
122 expect(suite.tests[0].name, equals("success")); 122 expect(suite.entries[0].name, equals("success"));
123 expect(suite.tests[1].name, equals("failure")); 123 expect(suite.entries[1].name, equals("failure"));
124 expect(suite.tests[2].name, equals("error")); 124 expect(suite.entries[2].name, equals("error"));
125 }); 125 });
126 126
127 test("loads a suite both in the browser and the VM", () async { 127 test("loads a suite both in the browser and the VM", () async {
128 var loader = new Loader( 128 var loader = new Loader(
129 new Configuration( 129 new Configuration(
130 platforms: [TestPlatform.vm, TestPlatform.chrome], 130 platforms: [TestPlatform.vm, TestPlatform.chrome],
131 packageRoot: p.join(packageDir, 'packages')), 131 packageRoot: p.join(packageDir, 'packages')),
132 root: _sandbox); 132 root: _sandbox);
133 var path = p.join(_sandbox, 'a_test.dart'); 133 var path = p.join(_sandbox, 'a_test.dart');
134 134
135 try { 135 try {
136 var suites = await loader.loadFile(path) 136 var suites = await loader.loadFile(path)
137 .asyncMap((loadSuite) => loadSuite.getSuite()).toList(); 137 .asyncMap((loadSuite) => loadSuite.getSuite()).toList();
138 expect(suites[0].platform, equals(TestPlatform.vm)); 138 expect(suites[0].platform, equals(TestPlatform.vm));
139 expect(suites[0].path, equals(path)); 139 expect(suites[0].path, equals(path));
140 expect(suites[1].platform, equals(TestPlatform.chrome)); 140 expect(suites[1].platform, equals(TestPlatform.chrome));
141 expect(suites[1].path, equals(path)); 141 expect(suites[1].path, equals(path));
142 142
143 for (var suite in suites) { 143 for (var suite in suites) {
144 expect(suite.tests, hasLength(3)); 144 expect(suite.entries, hasLength(3));
145 expect(suite.tests[0].name, equals("success")); 145 expect(suite.entries[0].name, equals("success"));
146 expect(suite.tests[1].name, equals("failure")); 146 expect(suite.entries[1].name, equals("failure"));
147 expect(suite.tests[2].name, equals("error")); 147 expect(suite.entries[2].name, equals("error"));
148 } 148 }
149 } finally { 149 } finally {
150 await loader.close(); 150 await loader.close();
151 } 151 }
152 }); 152 });
153 153
154 test("a print in a loaded file is piped through the LoadSuite", () async { 154 test("a print in a loaded file is piped through the LoadSuite", () async {
155 new File(p.join(_sandbox, 'a_test.dart')).writeAsStringSync(""" 155 new File(p.join(_sandbox, 'a_test.dart')).writeAsStringSync("""
156 void main() { 156 void main() {
157 print('print within test'); 157 print('print within test');
158 } 158 }
159 """); 159 """);
160 var suites = await _loader.loadFile(p.join(_sandbox, 'a_test.dart')) 160 var suites = await _loader.loadFile(p.join(_sandbox, 'a_test.dart'))
161 .toList(); 161 .toList();
162 expect(suites, hasLength(1)); 162 expect(suites, hasLength(1));
163 var loadSuite = suites.first; 163 var loadSuite = suites.first;
164 164
165 var liveTest = await loadSuite.tests.single.load(loadSuite); 165 var liveTest = await loadSuite.entries.single.load(loadSuite);
166 expect(liveTest.onPrint.first, completion(equals("print within test"))); 166 expect(liveTest.onPrint.first, completion(equals("print within test")));
167 await liveTest.run(); 167 await liveTest.run();
168 expectTestPassed(liveTest); 168 expectTestPassed(liveTest);
169 }); 169 });
170 } 170 }
OLDNEW
« no previous file with comments | « test/backend/declarer_test.dart ('k') | test/runner/engine_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698