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

Side by Side Diff: test/runner/loader_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/load_suite_test.dart ('k') | test/utils.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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 var loadSuite = suites.first; 57 var loadSuite = suites.first;
58 suite = await loadSuite.getSuite(); 58 suite = await loadSuite.getSuite();
59 }); 59 });
60 60
61 test("returns a suite with the file path and platform", () { 61 test("returns a suite with the file path and platform", () {
62 expect(suite.path, equals(p.join(_sandbox, 'a_test.dart'))); 62 expect(suite.path, equals(p.join(_sandbox, 'a_test.dart')));
63 expect(suite.platform, equals(TestPlatform.vm)); 63 expect(suite.platform, equals(TestPlatform.vm));
64 }); 64 });
65 65
66 test("returns entries with the correct names and platforms", () { 66 test("returns entries with the correct names and platforms", () {
67 expect(suite.entries, hasLength(3)); 67 expect(suite.group.entries, hasLength(3));
68 expect(suite.entries[0].name, equals("success")); 68 expect(suite.group.entries[0].name, equals("success"));
69 expect(suite.entries[1].name, equals("failure")); 69 expect(suite.group.entries[1].name, equals("failure"));
70 expect(suite.entries[2].name, equals("error")); 70 expect(suite.group.entries[2].name, equals("error"));
71 }); 71 });
72 72
73 test("can load and run a successful test", () { 73 test("can load and run a successful test", () {
74 var liveTest = suite.entries[0].load(suite); 74 var liveTest = suite.group.entries[0].load(suite);
75 75
76 expectStates(liveTest, [ 76 expectStates(liveTest, [
77 const State(Status.running, Result.success), 77 const State(Status.running, Result.success),
78 const State(Status.complete, Result.success) 78 const State(Status.complete, Result.success)
79 ]); 79 ]);
80 expectErrors(liveTest, []); 80 expectErrors(liveTest, []);
81 81
82 return liveTest.run().whenComplete(() => liveTest.close()); 82 return liveTest.run().whenComplete(() => liveTest.close());
83 }); 83 });
84 84
85 test("can load and run a failing test", () { 85 test("can load and run a failing test", () {
86 var liveTest = suite.entries[1].load(suite); 86 var liveTest = suite.group.entries[1].load(suite);
87 expectSingleFailure(liveTest); 87 expectSingleFailure(liveTest);
88 return liveTest.run().whenComplete(() => liveTest.close()); 88 return liveTest.run().whenComplete(() => liveTest.close());
89 }); 89 });
90 }); 90 });
91 91
92 group(".loadDir()", () { 92 group(".loadDir()", () {
93 test("ignores non-Dart files", () { 93 test("ignores non-Dart files", () {
94 new File(p.join(_sandbox, 'a_test.txt')).writeAsStringSync(_tests); 94 new File(p.join(_sandbox, 'a_test.txt')).writeAsStringSync(_tests);
95 expect(_loader.loadDir(_sandbox).toList(), completion(isEmpty)); 95 expect(_loader.loadDir(_sandbox).toList(), completion(isEmpty));
96 }); 96 });
(...skipping 30 matching lines...) Expand all
127 test("gives those suites the correct paths", () { 127 test("gives those suites the correct paths", () {
128 expect(suites.map((suite) => suite.path), unorderedEquals([ 128 expect(suites.map((suite) => suite.path), unorderedEquals([
129 p.join(_sandbox, 'a_test.dart'), 129 p.join(_sandbox, 'a_test.dart'),
130 p.join(_sandbox, 'another_test.dart'), 130 p.join(_sandbox, 'another_test.dart'),
131 p.join(_sandbox, 'dir', 'sub_test.dart') 131 p.join(_sandbox, 'dir', 'sub_test.dart')
132 ])); 132 ]));
133 }); 133 });
134 134
135 test("can run tests in those suites", () { 135 test("can run tests in those suites", () {
136 var suite = suites.firstWhere((suite) => suite.path.contains("a_test")); 136 var suite = suites.firstWhere((suite) => suite.path.contains("a_test"));
137 var liveTest = suite.entries[1].load(suite); 137 var liveTest = suite.group.entries[1].load(suite);
138 expectSingleFailure(liveTest); 138 expectSingleFailure(liveTest);
139 return liveTest.run().whenComplete(() => liveTest.close()); 139 return liveTest.run().whenComplete(() => liveTest.close());
140 }); 140 });
141 }); 141 });
142 }); 142 });
143 143
144 test("a print in a loaded file is piped through the LoadSuite", () async { 144 test("a print in a loaded file is piped through the LoadSuite", () async {
145 new File(p.join(_sandbox, 'a_test.dart')).writeAsStringSync(""" 145 new File(p.join(_sandbox, 'a_test.dart')).writeAsStringSync("""
146 void main() { 146 void main() {
147 print('print within test'); 147 print('print within test');
148 } 148 }
149 """); 149 """);
150 var suites = await _loader.loadFile(p.join(_sandbox, 'a_test.dart')) 150 var suites = await _loader.loadFile(p.join(_sandbox, 'a_test.dart'))
151 .toList(); 151 .toList();
152 expect(suites, hasLength(1)); 152 expect(suites, hasLength(1));
153 var loadSuite = suites.first; 153 var loadSuite = suites.first;
154 154
155 var liveTest = await loadSuite.entries.single.load(loadSuite); 155 var liveTest = await loadSuite.group.entries.single.load(loadSuite);
156 expect(liveTest.onPrint.first, completion(equals("print within test"))); 156 expect(liveTest.onPrint.first, completion(equals("print within test")));
157 await liveTest.run(); 157 await liveTest.run();
158 expectTestPassed(liveTest); 158 expectTestPassed(liveTest);
159 }); 159 });
160 160
161 // TODO: Test load suites. Don't forget to test that prints in loaded files 161 // TODO: Test load suites. Don't forget to test that prints in loaded files
162 // are piped through the suite. Also for browser tests! 162 // are piped through the suite. Also for browser tests!
163 } 163 }
OLDNEW
« no previous file with comments | « test/runner/load_suite_test.dart ('k') | test/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698