OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** | 5 /** |
6 * Classes and methods for executing tests. | 6 * Classes and methods for executing tests. |
7 * | 7 * |
8 * This module includes: | 8 * This module includes: |
9 * - Managing parallel execution of tests, including timeout checks. | 9 * - Managing parallel execution of tests, including timeout checks. |
10 * - Evaluating the output of each test as pass/fail/crash/timeout. | 10 * - Evaluating the output of each test as pass/fail/crash/timeout. |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 StreamSubscription<String> _stdoutSubscription; | 598 StreamSubscription<String> _stdoutSubscription; |
599 StreamSubscription<String> _stderrSubscription; | 599 StreamSubscription<String> _stderrSubscription; |
600 Function _processExitHandler; | 600 Function _processExitHandler; |
601 | 601 |
602 bool _currentlyRunning = false; | 602 bool _currentlyRunning = false; |
603 OutputLog _testStdout; | 603 OutputLog _testStdout; |
604 OutputLog _testStderr; | 604 OutputLog _testStderr; |
605 String _status; | 605 String _status; |
606 DateTime _startTime; | 606 DateTime _startTime; |
607 Timer _timer; | 607 Timer _timer; |
| 608 int _testCount = 0; |
608 | 609 |
609 Future<CommandOutput> runCommand(String runnerType, ProcessCommand command, | 610 Future<CommandOutput> runCommand(String runnerType, ProcessCommand command, |
610 int timeout, List<String> arguments) { | 611 int timeout, List<String> arguments) { |
611 assert(_completer == null); | 612 assert(_completer == null); |
612 assert(!_currentlyRunning); | 613 assert(!_currentlyRunning); |
613 | 614 |
614 _completer = new Completer(); | 615 _completer = new Completer(); |
615 bool sameRunnerType = _runnerType == runnerType && | 616 bool sameRunnerType = _runnerType == runnerType && |
616 _dictEquals(_processEnvironmentOverrides, command.environmentOverrides); | 617 _dictEquals(_processEnvironmentOverrides, command.environmentOverrides); |
617 _runnerType = runnerType; | 618 _runnerType = runnerType; |
618 _currentlyRunning = true; | 619 _currentlyRunning = true; |
619 _command = command; | 620 _command = command; |
620 _arguments = arguments; | 621 _arguments = arguments; |
621 _processEnvironmentOverrides = command.environmentOverrides; | 622 _processEnvironmentOverrides = command.environmentOverrides; |
622 | 623 |
| 624 // TOOD(jmesserly): this restarts `dartdevc --batch` to work around a |
| 625 // memory leak, see https://github.com/dart-lang/sdk/issues/30314. |
| 626 var clearMemoryLeak = command is CompilationCommand && |
| 627 command.displayName == 'dartdevc' && |
| 628 ++_testCount % 100 == 0; |
623 if (_process == null) { | 629 if (_process == null) { |
624 // Start process if not yet started. | 630 // Start process if not yet started. |
625 _startProcess(() { | 631 _startProcess(() { |
626 doStartTest(command, timeout); | 632 doStartTest(command, timeout); |
627 }); | 633 }); |
628 } else if (!sameRunnerType) { | 634 } else if (!sameRunnerType || clearMemoryLeak) { |
629 // Restart this runner with the right executable for this test if needed. | 635 // Restart this runner with the right executable for this test if needed. |
630 _processExitHandler = (_) { | 636 _processExitHandler = (_) { |
631 _startProcess(() { | 637 _startProcess(() { |
632 doStartTest(command, timeout); | 638 doStartTest(command, timeout); |
633 }); | 639 }); |
634 }; | 640 }; |
635 _process.kill(); | 641 _process.kill(); |
636 _stdoutSubscription.cancel(); | 642 _stdoutSubscription.cancel(); |
637 _stderrSubscription.cancel(); | 643 _stderrSubscription.cancel(); |
638 } else { | 644 } else { |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1157 assert(name == 'dartk'); | 1163 assert(name == 'dartk'); |
1158 return _getBatchRunner(name) | 1164 return _getBatchRunner(name) |
1159 .runCommand(name, command, timeout, command.arguments); | 1165 .runCommand(name, command, timeout, command.arguments); |
1160 } else if (command is CompilationCommand && | 1166 } else if (command is CompilationCommand && |
1161 globalConfiguration.batchDart2JS) { | 1167 globalConfiguration.batchDart2JS) { |
1162 return _getBatchRunner("dart2js") | 1168 return _getBatchRunner("dart2js") |
1163 .runCommand("dart2js", command, timeout, command.arguments); | 1169 .runCommand("dart2js", command, timeout, command.arguments); |
1164 } else if (command is AnalysisCommand && globalConfiguration.batch) { | 1170 } else if (command is AnalysisCommand && globalConfiguration.batch) { |
1165 return _getBatchRunner(command.displayName) | 1171 return _getBatchRunner(command.displayName) |
1166 .runCommand(command.displayName, command, timeout, command.arguments); | 1172 .runCommand(command.displayName, command, timeout, command.arguments); |
| 1173 } else if (command is CompilationCommand && |
| 1174 command.displayName == 'dartdevc' && |
| 1175 globalConfiguration.batch) { |
| 1176 return _getBatchRunner(command.displayName) |
| 1177 .runCommand(command.displayName, command, timeout, command.arguments); |
1167 } else if (command is ScriptCommand) { | 1178 } else if (command is ScriptCommand) { |
1168 return command.run(); | 1179 return command.run(); |
1169 } else if (command is AdbPrecompilationCommand) { | 1180 } else if (command is AdbPrecompilationCommand) { |
1170 assert(adbDevicePool != null); | 1181 assert(adbDevicePool != null); |
1171 return adbDevicePool.acquireDevice().then((AdbDevice device) { | 1182 return adbDevicePool.acquireDevice().then((AdbDevice device) { |
1172 return _runAdbPrecompilationCommand(device, command, timeout) | 1183 return _runAdbPrecompilationCommand(device, command, timeout) |
1173 .whenComplete(() { | 1184 .whenComplete(() { |
1174 adbDevicePool.releaseDevice(device); | 1185 adbDevicePool.releaseDevice(device); |
1175 }); | 1186 }); |
1176 }); | 1187 }); |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1636 } | 1647 } |
1637 } | 1648 } |
1638 | 1649 |
1639 void eventAllTestsDone() { | 1650 void eventAllTestsDone() { |
1640 for (var listener in _eventListener) { | 1651 for (var listener in _eventListener) { |
1641 listener.allDone(); | 1652 listener.allDone(); |
1642 } | 1653 } |
1643 _allDone(); | 1654 _allDone(); |
1644 } | 1655 } |
1645 } | 1656 } |
OLD | NEW |