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

Side by Side Diff: pkg/testing/lib/src/run_tests.dart

Issue 2693893004: Fix two problems with the analyzer suite: (Closed)
Patch Set: Created 3 years, 10 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 | « pkg/testing/lib/src/run.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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 4
5 library testing.run_tests; 5 library testing.run_tests;
6 6
7 import 'dart:async' show 7 import 'dart:async' show
8 Future; 8 Future;
9 9
10 import 'dart:io' show 10 import 'dart:io' show
(...skipping 20 matching lines...) Expand all
31 enableVerboseOutput, 31 enableVerboseOutput,
32 isVerbose, 32 isVerbose,
33 logMessage, 33 logMessage,
34 logSuiteComplete, 34 logSuiteComplete,
35 logTestComplete; 35 logTestComplete;
36 36
37 import 'run.dart' show 37 import 'run.dart' show
38 SuiteRunner, 38 SuiteRunner,
39 runProgram; 39 runProgram;
40 40
41 import 'suite.dart' show
42 Suite;
43
44 class CommandLine { 41 class CommandLine {
45 final Set<String> options; 42 final Set<String> options;
46 final List<String> arguments; 43 final List<String> arguments;
47 44
48 CommandLine(this.options, this.arguments); 45 CommandLine(this.options, this.arguments);
49 46
50 bool get verbose => options.contains("--verbose") || options.contains("-v"); 47 bool get verbose => options.contains("--verbose") || options.contains("-v");
51 48
52 Set<String> get skip => commaSeparated("--skip="); 49 Set<String> get skip => commaSeparated("--skip=");
53 50
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 if (cl.verbose) { 157 if (cl.verbose) {
161 enableVerboseOutput(); 158 enableVerboseOutput();
162 } 159 }
163 Map<String, String> environment = cl.environment; 160 Map<String, String> environment = cl.environment;
164 Uri configuration = await cl.configuration; 161 Uri configuration = await cl.configuration;
165 if (configuration == null) return; 162 if (configuration == null) return;
166 if (!isVerbose) { 163 if (!isVerbose) {
167 print("Use --verbose to display more details."); 164 print("Use --verbose to display more details.");
168 } 165 }
169 TestRoot root = await TestRoot.fromUri(configuration); 166 TestRoot root = await TestRoot.fromUri(configuration);
170 Set<String> skip = cl.skip; 167 SuiteRunner runner = new SuiteRunner(root.suites, environment, cl.selectors,
171 Set<String> selectedSuites = cl.selectedSuites; 168 cl.selectedSuites, cl.skip);
172 List<Suite> suites = root.suites.where((s) {
173 return !skip.contains(s.name) &&
174 (selectedSuites.isEmpty || selectedSuites.contains(s.name));
175 }).toList();
176 SuiteRunner runner = new SuiteRunner(suites, environment, cl.selectors);
177 String program = await runner.generateDartProgram(); 169 String program = await runner.generateDartProgram();
178 await runner.analyze(root.packages); 170 bool hasAnalyzerSuites = await runner.analyze(root.packages);
179 Stopwatch sw = new Stopwatch()..start(); 171 Stopwatch sw = new Stopwatch()..start();
180 if (program == null) { 172 if (program == null) {
181 fail("No tests configured."); 173 if (!hasAnalyzerSuites) {
174 fail("No tests configured.");
175 }
182 } else { 176 } else {
183 await runProgram(program, root.packages); 177 await runProgram(program, root.packages);
184 } 178 }
185 print("Running tests took: ${sw.elapsed}."); 179 print("Running tests took: ${sw.elapsed}.");
186 }); 180 });
187 181
188 Future<Null> runTests(Map<String, Function> tests) => 182 Future<Null> runTests(Map<String, Function> tests) =>
189 withErrorHandling(() async { 183 withErrorHandling(() async {
190 int completed = 0; 184 int completed = 0;
191 for (String name in tests.keys) { 185 for (String name in tests.keys) {
192 StringBuffer sb = new StringBuffer(); 186 StringBuffer sb = new StringBuffer();
193 try { 187 try {
194 await runGuarded(() { 188 await runGuarded(() {
195 print("Running test $name"); 189 print("Running test $name");
196 return tests[name](); 190 return tests[name]();
197 }, printLineOnStdout: sb.writeln); 191 }, printLineOnStdout: sb.writeln);
198 logMessage(sb); 192 logMessage(sb);
199 } catch (e) { 193 } catch (e) {
200 print(sb); 194 print(sb);
201 rethrow; 195 rethrow;
202 } 196 }
203 logTestComplete(++completed, 0, tests.length, null, null); 197 logTestComplete(++completed, 0, tests.length, null, null);
204 } 198 }
205 logSuiteComplete(); 199 logSuiteComplete();
206 }); 200 });
OLDNEW
« no previous file with comments | « pkg/testing/lib/src/run.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698