| 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:io'; | 6 import 'dart:io'; |
| 7 | 7 |
| 8 import 'package:async/async.dart'; | 8 import 'package:async/async.dart'; |
| 9 | 9 |
| 10 import 'backend/group.dart'; | 10 import 'backend/group.dart'; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 var results = await Future.wait([ | 119 var results = await Future.wait([ |
| 120 _suiteSubscription.asFuture().then((_) => _engine.suiteSink.close()), | 120 _suiteSubscription.asFuture().then((_) => _engine.suiteSink.close()), |
| 121 _engine.run() | 121 _engine.run() |
| 122 ], eagerError: true); | 122 ], eagerError: true); |
| 123 success = results.last; | 123 success = results.last; |
| 124 } | 124 } |
| 125 | 125 |
| 126 if (_closed) return false; | 126 if (_closed) return false; |
| 127 | 127 |
| 128 if (_engine.passed.length == 0 && _engine.failed.length == 0 && | 128 if (_engine.passed.length == 0 && _engine.failed.length == 0 && |
| 129 _engine.skipped.length == 0 && _config.pattern != null) { | 129 _engine.skipped.length == 0 && _config.patterns.isNotEmpty) { |
| 130 var message = 'No tests match '; | 130 var patterns = toSentence(_config.patterns.map( |
| 131 (pattern) => pattern is RegExp |
| 132 ? 'regular expression "${pattern.pattern}"' |
| 133 : '"$pattern"')) |
| 131 | 134 |
| 132 if (_config.pattern is RegExp) { | 135 throw new ApplicationException('No tests match $patterns.'); |
| 133 var pattern = (_config.pattern as RegExp).pattern; | |
| 134 message += 'regular expression "$pattern".'; | |
| 135 } else { | |
| 136 message += '"${_config.pattern}".'; | |
| 137 } | |
| 138 throw new ApplicationException(message); | |
| 139 } | 136 } |
| 140 | 137 |
| 141 // Explicitly check "== true" here because [Engine.run] can return `null` | 138 // Explicitly check "== true" here because [Engine.run] can return `null` |
| 142 // if the engine was closed prematurely. | 139 // if the engine was closed prematurely. |
| 143 return success == true; | 140 return success == true; |
| 144 } | 141 } |
| 145 | 142 |
| 146 /// Emits a warning if the user is trying to run on a platform that's | 143 /// Emits a warning if the user is trying to run on a platform that's |
| 147 /// unsupported for the entire package. | 144 /// unsupported for the entire package. |
| 148 void _warnForUnsupportedPlatforms() { | 145 void _warnForUnsupportedPlatforms() { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 await Future.wait([ | 222 await Future.wait([ |
| 226 _loader.closeEphemeral(), | 223 _loader.closeEphemeral(), |
| 227 _engine.close() | 224 _engine.close() |
| 228 ]); | 225 ]); |
| 229 if (timer != null) timer.cancel(); | 226 if (timer != null) timer.cancel(); |
| 230 await _loader.close(); | 227 await _loader.close(); |
| 231 }); | 228 }); |
| 232 | 229 |
| 233 /// Return a stream of [LoadSuite]s in [_config.paths]. | 230 /// Return a stream of [LoadSuite]s in [_config.paths]. |
| 234 /// | 231 /// |
| 235 /// Only tests that match [_config.pattern] will be included in the | 232 /// Only tests that match [_config.patterns] will be included in the |
| 236 /// suites once they're loaded. | 233 /// suites once they're loaded. |
| 237 Stream<LoadSuite> _loadSuites() { | 234 Stream<LoadSuite> _loadSuites() { |
| 238 return mergeStreams(_config.paths.map((path) { | 235 return mergeStreams(_config.paths.map((path) { |
| 239 if (new Directory(path).existsSync()) return _loader.loadDir(path); | 236 if (new Directory(path).existsSync()) return _loader.loadDir(path); |
| 240 if (new File(path).existsSync()) return _loader.loadFile(path); | 237 if (new File(path).existsSync()) return _loader.loadFile(path); |
| 241 | 238 |
| 242 return new Stream.fromIterable([ | 239 return new Stream.fromIterable([ |
| 243 new LoadSuite.forLoadException( | 240 new LoadSuite.forLoadException( |
| 244 new LoadException(path, 'Does not exist.')) | 241 new LoadException(path, 'Does not exist.')) |
| 245 ]); | 242 ]); |
| 246 })).map((loadSuite) { | 243 })).map((loadSuite) { |
| 247 return loadSuite.changeSuite((suite) { | 244 return loadSuite.changeSuite((suite) { |
| 248 _warnForUnknownTags(suite); | 245 _warnForUnknownTags(suite); |
| 249 | 246 |
| 250 return suite.filter((test) { | 247 return suite.filter((test) { |
| 251 // Skip any tests that don't match the given pattern. | 248 // Skip any tests that don't match all the given patterns. |
| 252 if (_config.pattern != null && !test.name.contains(_config.pattern)) { | 249 if (!_config.patterns.every(test.name.contains)) { |
| 253 return false; | 250 return false; |
| 254 } | 251 } |
| 255 | 252 |
| 256 // If the user provided tags, skip tests that don't match all of them. | 253 // If the user provided tags, skip tests that don't match all of them. |
| 257 if (!_config.includeTags.evaluate(test.metadata.tags)) return false; | 254 if (!_config.includeTags.evaluate(test.metadata.tags)) return false; |
| 258 | 255 |
| 259 // Skip tests that do match any tags the user wants to exclude. | 256 // Skip tests that do match any tags the user wants to exclude. |
| 260 if (_config.excludeTags.evaluate(test.metadata.tags)) return false; | 257 if (_config.excludeTags.evaluate(test.metadata.tags)) return false; |
| 261 | 258 |
| 262 return true; | 259 return true; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 await _debugOperation.valueOrCancellation(); | 350 await _debugOperation.valueOrCancellation(); |
| 354 }).listen(null); | 351 }).listen(null); |
| 355 | 352 |
| 356 var results = await Future.wait([ | 353 var results = await Future.wait([ |
| 357 _suiteSubscription.asFuture().then((_) => _engine.suiteSink.close()), | 354 _suiteSubscription.asFuture().then((_) => _engine.suiteSink.close()), |
| 358 _engine.run() | 355 _engine.run() |
| 359 ]); | 356 ]); |
| 360 return results.last; | 357 return results.last; |
| 361 } | 358 } |
| 362 } | 359 } |
| OLD | NEW |