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:convert'; | |
kevmoo
2016/04/14 22:50:36
many unused imports
Do you use crypto?
| |
6 import 'dart:io'; | 7 import 'dart:io'; |
8 import 'dart:typed_data'; | |
7 | 9 |
8 import 'package:async/async.dart'; | 10 import 'package:async/async.dart'; |
11 import 'package:crypto/crypto.dart'; | |
9 | 12 |
10 import 'backend/group.dart'; | 13 import 'backend/group.dart'; |
11 import 'backend/group_entry.dart'; | 14 import 'backend/group_entry.dart'; |
12 import 'backend/operating_system.dart'; | 15 import 'backend/operating_system.dart'; |
13 import 'backend/platform_selector.dart'; | 16 import 'backend/platform_selector.dart'; |
14 import 'backend/suite.dart'; | 17 import 'backend/suite.dart'; |
15 import 'backend/test.dart'; | 18 import 'backend/test.dart'; |
16 import 'backend/test_platform.dart'; | 19 import 'backend/test_platform.dart'; |
17 import 'runner/application_exception.dart'; | 20 import 'runner/application_exception.dart'; |
18 import 'runner/configuration.dart'; | 21 import 'runner/configuration.dart'; |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
237 if (new File(path).existsSync()) return _loader.loadFile(path); | 240 if (new File(path).existsSync()) return _loader.loadFile(path); |
238 | 241 |
239 return new Stream.fromIterable([ | 242 return new Stream.fromIterable([ |
240 new LoadSuite.forLoadException( | 243 new LoadSuite.forLoadException( |
241 new LoadException(path, 'Does not exist.')) | 244 new LoadException(path, 'Does not exist.')) |
242 ]); | 245 ]); |
243 })).map((loadSuite) { | 246 })).map((loadSuite) { |
244 return loadSuite.changeSuite((suite) { | 247 return loadSuite.changeSuite((suite) { |
245 _warnForUnknownTags(suite); | 248 _warnForUnknownTags(suite); |
246 | 249 |
247 return suite.filter((test) { | 250 return _shardSuite(suite.filter((test) { |
248 // Skip any tests that don't match all the given patterns. | 251 // Skip any tests that don't match all the given patterns. |
249 if (!_config.patterns.every(test.name.contains)) { | 252 if (!_config.patterns.every(test.name.contains)) { |
250 return false; | 253 return false; |
251 } | 254 } |
252 | 255 |
253 // If the user provided tags, skip tests that don't match all of them. | 256 // If the user provided tags, skip tests that don't match all of them. |
254 if (!_config.includeTags.evaluate(test.metadata.tags)) return false; | 257 if (!_config.includeTags.evaluate(test.metadata.tags)) return false; |
255 | 258 |
256 // Skip tests that do match any tags the user wants to exclude. | 259 // Skip tests that do match any tags the user wants to exclude. |
257 if (_config.excludeTags.evaluate(test.metadata.tags)) return false; | 260 if (_config.excludeTags.evaluate(test.metadata.tags)) return false; |
258 | 261 |
259 return true; | 262 return true; |
260 }); | 263 })); |
261 }); | 264 }); |
262 }); | 265 }); |
263 } | 266 } |
264 | 267 |
265 /// Prints a warning for any unknown tags referenced in [suite] or its | 268 /// Prints a warning for any unknown tags referenced in [suite] or its |
266 /// children. | 269 /// children. |
267 void _warnForUnknownTags(Suite suite) { | 270 void _warnForUnknownTags(Suite suite) { |
268 if (_tagWarningSuites.contains(suite.path)) return; | 271 if (_tagWarningSuites.contains(suite.path)) return; |
269 _tagWarningSuites.add(suite.path); | 272 _tagWarningSuites.add(suite.path); |
270 | 273 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
330 return unknownTags; | 333 return unknownTags; |
331 } | 334 } |
332 | 335 |
333 /// Returns a human-readable description of [entry], including its type. | 336 /// Returns a human-readable description of [entry], including its type. |
334 String _entryDescription(GroupEntry entry) { | 337 String _entryDescription(GroupEntry entry) { |
335 if (entry is Test) return 'the test "${entry.name}"'; | 338 if (entry is Test) return 'the test "${entry.name}"'; |
336 if (entry.name != null) return 'the group "${entry.name}"'; | 339 if (entry.name != null) return 'the group "${entry.name}"'; |
337 return 'the suite itself'; | 340 return 'the suite itself'; |
338 } | 341 } |
339 | 342 |
343 /// If sharding is enabled, filters [suite] to only include the tests that | |
344 /// should be run in this shard. | |
345 /// | |
346 /// We just take a slice of the tests in each suite corresponding to the shard | |
347 /// index. This makes the tests pretty tests across shards, and since the | |
348 /// tests are continuous, makes us more likely to be able to re-use | |
349 /// `setUpAll()` logic. | |
350 void _shardSuite(Suite suite) { | |
kevmoo
2016/04/14 22:50:36
Suppose to return a Suite, no? Not void...
nweiz
2016/04/22 21:30:53
Done.
| |
351 if (_config.totalShards == null) return suite; | |
352 | |
353 var shardSize = suite.group.testCount / _config.totalShards; | |
354 var shardStart = (shardSize * _config.shardIndex).round(); | |
355 var shardEnd = (shardSize * (_config.shardIndex + 1)).round(); | |
356 | |
357 var count = -1; | |
358 var filtered = suite.filter((test) { | |
359 count++; | |
360 return count >= shardStart && count < shardEnd; | |
361 }); | |
362 | |
363 return filtered; | |
364 } | |
365 | |
340 /// Loads each suite in [suites] in order, pausing after load for platforms | 366 /// Loads each suite in [suites] in order, pausing after load for platforms |
341 /// that support debugging. | 367 /// that support debugging. |
342 Future<bool> _loadThenPause(Stream<LoadSuite> suites) async { | 368 Future<bool> _loadThenPause(Stream<LoadSuite> suites) async { |
343 if (_config.platforms.contains(TestPlatform.vm)) { | 369 if (_config.platforms.contains(TestPlatform.vm)) { |
344 warn("Debugging is currently unsupported on the Dart VM.", | 370 warn("Debugging is currently unsupported on the Dart VM.", |
345 color: _config.color); | 371 color: _config.color); |
346 } | 372 } |
347 | 373 |
348 _suiteSubscription = suites.asyncMap((loadSuite) async { | 374 _suiteSubscription = suites.asyncMap((loadSuite) async { |
349 _debugOperation = debug(_config, _engine, _reporter, loadSuite); | 375 _debugOperation = debug(_config, _engine, _reporter, loadSuite); |
350 await _debugOperation.valueOrCancellation(); | 376 await _debugOperation.valueOrCancellation(); |
351 }).listen(null); | 377 }).listen(null); |
352 | 378 |
353 var results = await Future.wait([ | 379 var results = await Future.wait([ |
354 _suiteSubscription.asFuture().then((_) => _engine.suiteSink.close()), | 380 _suiteSubscription.asFuture().then((_) => _engine.suiteSink.close()), |
355 _engine.run() | 381 _engine.run() |
356 ]); | 382 ]); |
357 return results.last; | 383 return results.last; |
358 } | 384 } |
359 } | 385 } |
OLD | NEW |