| OLD | NEW |
| 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.runner; | 5 library test.runner; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 import 'package:async/async.dart'; | 10 import 'package:async/async.dart'; |
| 11 | 11 |
| 12 import 'backend/metadata.dart'; | 12 import 'backend/metadata.dart'; |
| 13 import 'backend/test_platform.dart'; | 13 import 'backend/test_platform.dart'; |
| 14 import 'frontend/timeout.dart'; | 14 import 'frontend/timeout.dart'; |
| 15 import 'runner/application_exception.dart'; | 15 import 'runner/application_exception.dart'; |
| 16 import 'runner/configuration.dart'; | 16 import 'runner/configuration.dart'; |
| 17 import 'runner/engine.dart'; | 17 import 'runner/engine.dart'; |
| 18 import 'runner/load_exception.dart'; | 18 import 'runner/load_exception.dart'; |
| 19 import 'runner/load_suite.dart'; | 19 import 'runner/load_suite.dart'; |
| 20 import 'runner/loader.dart'; | 20 import 'runner/loader.dart'; |
| 21 import 'runner/reporter.dart'; | 21 import 'runner/reporter.dart'; |
| 22 import 'runner/reporter/compact.dart'; | 22 import 'runner/reporter/compact.dart'; |
| 23 import 'runner/reporter/expanded.dart'; | 23 import 'runner/reporter/expanded.dart'; |
| 24 import 'runner/runner_suite.dart'; | 24 import 'runner/runner_suite.dart'; |
| 25 import 'util/io.dart'; | 25 import 'util/io.dart'; |
| 26 import 'utils.dart'; | 26 import 'utils.dart'; |
| 27 | 27 |
| 28 /// The set of platforms for which debug flags are (currently) not supported. | 28 /// The set of platforms for which debug flags are (currently) not supported. |
| 29 final _debugUnsupportedPlatforms = new Set.from( | 29 final _debugUnsupportedPlatforms = new Set.from( |
| 30 [TestPlatform.vm, TestPlatform.phantomJS, TestPlatform.contentShell]); | 30 [TestPlatform.vm, TestPlatform.phantomJS]); |
| 31 | 31 |
| 32 /// A class that loads and runs tests based on a [Configuration]. | 32 /// A class that loads and runs tests based on a [Configuration]. |
| 33 /// | 33 /// |
| 34 /// This maintains a [Loader] and an [Engine] and passes test suites from one to | 34 /// This maintains a [Loader] and an [Engine] and passes test suites from one to |
| 35 /// the other, as well as printing out tests with a [CompactReporter] or an | 35 /// the other, as well as printing out tests with a [CompactReporter] or an |
| 36 /// [ExpandedReporter]. | 36 /// [ExpandedReporter]. |
| 37 class Runner { | 37 class Runner { |
| 38 /// The configuration for the runner. | 38 /// The configuration for the runner. |
| 39 final Configuration _configuration; | 39 final Configuration _configuration; |
| 40 | 40 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 /// This is a no-op for test suites that aren't on platforms where debugging | 224 /// This is a no-op for test suites that aren't on platforms where debugging |
| 225 /// is supported. | 225 /// is supported. |
| 226 Future _pause(RunnerSuite suite) async { | 226 Future _pause(RunnerSuite suite) async { |
| 227 if (suite.platform == null) return; | 227 if (suite.platform == null) return; |
| 228 if (_debugUnsupportedPlatforms.contains(suite.platform)) return; | 228 if (_debugUnsupportedPlatforms.contains(suite.platform)) return; |
| 229 | 229 |
| 230 try { | 230 try { |
| 231 _reporter.pause(); | 231 _reporter.pause(); |
| 232 | 232 |
| 233 var bold = _configuration.color ? '\u001b[1m' : ''; | 233 var bold = _configuration.color ? '\u001b[1m' : ''; |
| 234 var yellow = _configuration.color ? '\u001b[33m' : ''; |
| 234 var noColor = _configuration.color ? '\u001b[0m' : ''; | 235 var noColor = _configuration.color ? '\u001b[0m' : ''; |
| 235 print(''); | 236 print(''); |
| 236 print(wordWrap( | |
| 237 "${bold}The test runner is paused.${noColor} Open the dev console in " | |
| 238 "${suite.platform} and set breakpoints. Once you're finished, " | |
| 239 "return to this terminal and press Enter.")); | |
| 240 | 237 |
| 241 await race([ | 238 if (suite.platform.isDartVM) { |
| 239 var url = suite.environment.observatoryUrl; |
| 240 if (url == null) { |
| 241 print("${yellow}Observatory URL not found. Make sure you're using " |
| 242 "${suite.platform.name} 1.11 or later.$noColor"); |
| 243 } else { |
| 244 print("Observatory URL: $bold$url$noColor"); |
| 245 } |
| 246 } |
| 247 |
| 248 var buffer = new StringBuffer( |
| 249 "${bold}The test runner is paused.${noColor} "); |
| 250 if (!suite.platform.isHeadless) { |
| 251 buffer.write("Open the dev console in ${suite.platform} "); |
| 252 if (suite.platform.isDartVM) buffer.write("or "); |
| 253 } else { |
| 254 buffer.write("Open "); |
| 255 } |
| 256 if (suite.platform.isDartVM) buffer.write("the Observatory "); |
| 257 |
| 258 buffer.write("and set breakpoints. Once you're finished, return to this " |
| 259 "terminal and press Enter."); |
| 260 |
| 261 print(wordWrap(buffer.toString())); |
| 262 |
| 263 await inCompletionOrder([ |
| 242 suite.environment.displayPause(), | 264 suite.environment.displayPause(), |
| 243 cancelableNext(stdinLines) | 265 cancelableNext(stdinLines) |
| 244 ]); | 266 ]).first; |
| 245 } finally { | 267 } finally { |
| 246 _reporter.resume(); | 268 _reporter.resume(); |
| 247 } | 269 } |
| 248 } | 270 } |
| 249 } | 271 } |
| OLD | NEW |