| 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:collection'; | 6 import 'dart:collection'; |
| 7 | 7 |
| 8 import 'package:async/async.dart' hide Result; | 8 import 'package:async/async.dart' hide Result; |
| 9 import 'package:collection/collection.dart'; | 9 import 'package:collection/collection.dart'; |
| 10 import 'package:pool/pool.dart'; | 10 import 'package:pool/pool.dart'; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 /// A pool that limits the number of test suites running concurrently. | 67 /// A pool that limits the number of test suites running concurrently. |
| 68 final Pool _runPool; | 68 final Pool _runPool; |
| 69 | 69 |
| 70 /// A pool that limits the number of test suites loaded concurrently. | 70 /// A pool that limits the number of test suites loaded concurrently. |
| 71 /// | 71 /// |
| 72 /// Once this reaches its limit, loading any additional test suites will cause | 72 /// Once this reaches its limit, loading any additional test suites will cause |
| 73 /// previous suites to be unloaded in the order they completed. | 73 /// previous suites to be unloaded in the order they completed. |
| 74 final Pool _loadPool; | 74 final Pool _loadPool; |
| 75 | 75 |
| 76 /// Whether all tests passed. | 76 /// Whether all tests passed or were skipped. |
| 77 /// | 77 /// |
| 78 /// This fires once all tests have completed and [suiteSink] has been closed. | 78 /// This fires once all tests have completed and [suiteSink] has been closed. |
| 79 /// This will be `null` if [close] was called before all the tests finished | 79 /// This will be `null` if [close] was called before all the tests finished |
| 80 /// running. | 80 /// running. |
| 81 Future<bool> get success async { | 81 Future<bool> get success async { |
| 82 await _group.future; | 82 await _group.future; |
| 83 if (_closedBeforeDone) return null; | 83 if (_closedBeforeDone) return null; |
| 84 return liveTests.every((liveTest) => | 84 return liveTests.every((liveTest) => liveTest.state.result.isPassing); |
| 85 liveTest.state.result == Result.success); | |
| 86 } | 85 } |
| 87 | 86 |
| 88 /// A group of futures for each test suite. | 87 /// A group of futures for each test suite. |
| 89 final _group = new FutureGroup(); | 88 final _group = new FutureGroup(); |
| 90 | 89 |
| 91 /// A sink used to pass [RunnerSuite]s in to the engine to run. | 90 /// A sink used to pass [RunnerSuite]s in to the engine to run. |
| 92 /// | 91 /// |
| 93 /// Suites may be added as quickly as they're available; the Engine will only | 92 /// Suites may be added as quickly as they're available; the Engine will only |
| 94 /// run as many as necessary at a time based on its concurrency settings. | 93 /// run as many as necessary at a time based on its concurrency settings. |
| 95 /// | 94 /// |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 if (group.metadata.skip) { | 278 if (group.metadata.skip) { |
| 280 await _runSkippedTest(suiteController, group, parents); | 279 await _runSkippedTest(suiteController, group, parents); |
| 281 return; | 280 return; |
| 282 } | 281 } |
| 283 | 282 |
| 284 var setUpAllSucceeded = true; | 283 var setUpAllSucceeded = true; |
| 285 if (group.setUpAll != null) { | 284 if (group.setUpAll != null) { |
| 286 var liveTest = group.setUpAll.load(suiteController.liveSuite.suite, | 285 var liveTest = group.setUpAll.load(suiteController.liveSuite.suite, |
| 287 groups: parents); | 286 groups: parents); |
| 288 await _runLiveTest(suiteController, liveTest, countSuccess: false); | 287 await _runLiveTest(suiteController, liveTest, countSuccess: false); |
| 289 setUpAllSucceeded = liveTest.state.result == Result.success; | 288 setUpAllSucceeded = liveTest.state.result.isPassing; |
| 290 } | 289 } |
| 291 | 290 |
| 292 if (!_closed && setUpAllSucceeded) { | 291 if (!_closed && setUpAllSucceeded) { |
| 293 for (var entry in group.entries) { | 292 for (var entry in group.entries) { |
| 294 if (_closed) return; | 293 if (_closed) return; |
| 295 | 294 |
| 296 if (entry is Group) { | 295 if (entry is Group) { |
| 297 await _runGroup(suiteController, entry, parents); | 296 await _runGroup(suiteController, entry, parents); |
| 298 } else if (entry.metadata.skip) { | 297 } else if (entry.metadata.skip) { |
| 299 await _runSkippedTest(suiteController, entry, parents); | 298 await _runSkippedTest(suiteController, entry, parents); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 Future _runSkippedTest(LiveSuiteController suiteController, GroupEntry entry, | 364 Future _runSkippedTest(LiveSuiteController suiteController, GroupEntry entry, |
| 366 List<Group> parents) { | 365 List<Group> parents) { |
| 367 // The netry name will be `null` for the root group. | 366 // The netry name will be `null` for the root group. |
| 368 var test = new LocalTest(entry.name ?? "(suite)", entry.metadata, () {}, | 367 var test = new LocalTest(entry.name ?? "(suite)", entry.metadata, () {}, |
| 369 trace: entry.trace); | 368 trace: entry.trace); |
| 370 | 369 |
| 371 var controller; | 370 var controller; |
| 372 controller = new LiveTestController( | 371 controller = new LiveTestController( |
| 373 suiteController.liveSuite.suite, test, () { | 372 suiteController.liveSuite.suite, test, () { |
| 374 controller.setState(const State(Status.running, Result.success)); | 373 controller.setState(const State(Status.running, Result.success)); |
| 375 controller.setState(const State(Status.complete, Result.success)); | 374 controller.setState(const State(Status.running, Result.skipped)); |
| 375 controller.setState(const State(Status.complete, Result.skipped)); |
| 376 controller.completer.complete(); | 376 controller.completer.complete(); |
| 377 }, () {}, groups: parents); | 377 }, () {}, groups: parents); |
| 378 | 378 |
| 379 return _runLiveTest(suiteController, controller.liveTest); | 379 return _runLiveTest(suiteController, controller.liveTest); |
| 380 } | 380 } |
| 381 | 381 |
| 382 /// Closes [liveTest] and tells the engine to re-run it once it's done | 382 /// Closes [liveTest] and tells the engine to re-run it once it's done |
| 383 /// running. | 383 /// running. |
| 384 /// | 384 /// |
| 385 /// Returns the same future as [LiveTest.close]. | 385 /// Returns the same future as [LiveTest.close]. |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 var futures = allLiveTests.map((liveTest) => liveTest.close()).toList(); | 481 var futures = allLiveTests.map((liveTest) => liveTest.close()).toList(); |
| 482 | 482 |
| 483 // Closing the load pool will close the test suites as soon as their tests | 483 // Closing the load pool will close the test suites as soon as their tests |
| 484 // are done. For browser suites this is effectively immediate since their | 484 // are done. For browser suites this is effectively immediate since their |
| 485 // tests shut down as soon as they're closed, but for VM suites we may need | 485 // tests shut down as soon as they're closed, but for VM suites we may need |
| 486 // to wait for tearDowns or tearDownAlls to run. | 486 // to wait for tearDowns or tearDownAlls to run. |
| 487 futures.add(_loadPool.close()); | 487 futures.add(_loadPool.close()); |
| 488 await Future.wait(futures, eagerError: true); | 488 await Future.wait(futures, eagerError: true); |
| 489 } | 489 } |
| 490 } | 490 } |
| OLD | NEW |