| 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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 bool _equal(Command other) { | 286 bool _equal(Command other) { |
| 287 return other is ContentShellCommand && super._equal(other); | 287 return other is ContentShellCommand && super._equal(other); |
| 288 } | 288 } |
| 289 | 289 |
| 290 int get maxNumRetries => 3; | 290 int get maxNumRetries => 3; |
| 291 } | 291 } |
| 292 | 292 |
| 293 class BrowserTestCommand extends Command { | 293 class BrowserTestCommand extends Command { |
| 294 final String browser; | 294 final String browser; |
| 295 final String url; | 295 final String url; |
| 296 final bool checkedMode; // needed for dartium | 296 final Map configuration; |
| 297 | 297 |
| 298 BrowserTestCommand._(String _browser, | 298 BrowserTestCommand._(String _browser, |
| 299 this.url, | 299 this.url, |
| 300 {bool this.checkedMode: false}) | 300 this.configuration) |
| 301 : super._(_browser), browser = _browser; | 301 : super._(_browser), browser = _browser; |
| 302 | 302 |
| 303 void _buildHashCode(HashCodeBuilder builder) { | 303 void _buildHashCode(HashCodeBuilder builder) { |
| 304 super._buildHashCode(builder); | 304 super._buildHashCode(builder); |
| 305 builder.add(browser); | 305 builder.add(browser); |
| 306 builder.add(url); | 306 builder.add(url); |
| 307 builder.add(checkedMode); | 307 builder.add(configuration); |
| 308 } | 308 } |
| 309 | 309 |
| 310 bool _equal(Command other) { | 310 bool _equal(Command other) { |
| 311 return | 311 return |
| 312 other is BrowserTestCommand && | 312 other is BrowserTestCommand && |
| 313 super._equal(other) && | 313 super._equal(other) && |
| 314 browser == other.browser && | 314 browser == other.browser && |
| 315 url == other.url && | 315 url == other.url && |
| 316 checkedMode == other.checkedMode; | 316 identical(configuration, other.configuration); |
| 317 } | 317 } |
| 318 | 318 |
| 319 String get reproductionCommand { | 319 String get reproductionCommand { |
| 320 var parts = [TestUtils.dartTestExecutable.toString(), | 320 var parts = [TestUtils.dartTestExecutable.toString(), |
| 321 'tools/testing/dart/launch_browser.dart', | 321 'tools/testing/dart/launch_browser.dart', |
| 322 browser, | 322 browser, |
| 323 url]; | 323 url]; |
| 324 return parts.map(escapeCommandLineArgument).join(' '); | 324 return parts.map(escapeCommandLineArgument).join(' '); |
| 325 } | 325 } |
| 326 } | 326 } |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 List<String> options, | 591 List<String> options, |
| 592 List<String> dartFlags, | 592 List<String> dartFlags, |
| 593 Map<String, String> environment) { | 593 Map<String, String> environment) { |
| 594 ContentShellCommand command = new ContentShellCommand._( | 594 ContentShellCommand command = new ContentShellCommand._( |
| 595 executable, htmlFile, options, dartFlags, environment); | 595 executable, htmlFile, options, dartFlags, environment); |
| 596 return _getUniqueCommand(command); | 596 return _getUniqueCommand(command); |
| 597 } | 597 } |
| 598 | 598 |
| 599 BrowserTestCommand getBrowserTestCommand(String browser, | 599 BrowserTestCommand getBrowserTestCommand(String browser, |
| 600 String url, | 600 String url, |
| 601 {bool checkedMode: false}) { | 601 Map configuration) { |
| 602 var command = new BrowserTestCommand._( | 602 var command = new BrowserTestCommand._(browser, url, configuration); |
| 603 browser, url, checkedMode: checkedMode); | |
| 604 return _getUniqueCommand(command); | 603 return _getUniqueCommand(command); |
| 605 } | 604 } |
| 606 | 605 |
| 607 CompilationCommand getCompilationCommand(String displayName, | 606 CompilationCommand getCompilationCommand(String displayName, |
| 608 outputFile, | 607 outputFile, |
| 609 neverSkipCompilation, | 608 neverSkipCompilation, |
| 610 List<Uri> bootstrapDependencies, | 609 List<Uri> bootstrapDependencies, |
| 611 String executable, | 610 String executable, |
| 612 List<String> arguments, | 611 List<String> arguments, |
| 613 Map<String, String> environment) { | 612 Map<String, String> environment) { |
| (...skipping 1841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2455 dgraph.Node node, Command command, int timeout); | 2454 dgraph.Node node, Command command, int timeout); |
| 2456 } | 2455 } |
| 2457 | 2456 |
| 2458 class CommandExecutorImpl implements CommandExecutor { | 2457 class CommandExecutorImpl implements CommandExecutor { |
| 2459 final Map globalConfiguration; | 2458 final Map globalConfiguration; |
| 2460 final int maxProcesses; | 2459 final int maxProcesses; |
| 2461 final int maxBrowserProcesses; | 2460 final int maxBrowserProcesses; |
| 2462 | 2461 |
| 2463 // For dartanalyzer batch processing we keep a list of batch processes. | 2462 // For dartanalyzer batch processing we keep a list of batch processes. |
| 2464 final _batchProcesses = new Map<String, List<BatchRunnerProcess>>(); | 2463 final _batchProcesses = new Map<String, List<BatchRunnerProcess>>(); |
| 2465 // We keep a BrowserTestRunner for every "browserName-checked" configuration. | 2464 // We keep a BrowserTestRunner for every configuration. |
| 2466 final _browserTestRunners = new Map<String, BrowserTestRunner>(); | 2465 final _browserTestRunners = new Map<Map, BrowserTestRunner>(); |
| 2467 | 2466 |
| 2468 bool _finishing = false; | 2467 bool _finishing = false; |
| 2469 | 2468 |
| 2470 CommandExecutorImpl( | 2469 CommandExecutorImpl( |
| 2471 this.globalConfiguration, this.maxProcesses, this.maxBrowserProcesses); | 2470 this.globalConfiguration, this.maxProcesses, this.maxBrowserProcesses); |
| 2472 | 2471 |
| 2473 Future cleanup() { | 2472 Future cleanup() { |
| 2474 assert(!_finishing); | 2473 assert(!_finishing); |
| 2475 _finishing = true; | 2474 _finishing = true; |
| 2476 | 2475 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2548 BrowserTestCommand browserCommand, int timeout) { | 2547 BrowserTestCommand browserCommand, int timeout) { |
| 2549 var completer = new Completer<CommandOutput>(); | 2548 var completer = new Completer<CommandOutput>(); |
| 2550 | 2549 |
| 2551 var callback = (BrowserTestOutput output) { | 2550 var callback = (BrowserTestOutput output) { |
| 2552 completer.complete( | 2551 completer.complete( |
| 2553 new BrowserControllerTestOutcome(browserCommand, output)); | 2552 new BrowserControllerTestOutcome(browserCommand, output)); |
| 2554 }; | 2553 }; |
| 2555 BrowserTest browserTest = new BrowserTest(browserCommand.url, | 2554 BrowserTest browserTest = new BrowserTest(browserCommand.url, |
| 2556 callback, | 2555 callback, |
| 2557 timeout); | 2556 timeout); |
| 2558 _getBrowserTestRunner(browserCommand.browser, browserCommand.checkedMode) | 2557 _getBrowserTestRunner(browserCommand.browser, browserCommand.configuration) |
| 2559 .then((testRunner) { | 2558 .then((testRunner) { |
| 2560 testRunner.queueTest(browserTest); | 2559 testRunner.queueTest(browserTest); |
| 2561 }); | 2560 }); |
| 2562 | 2561 |
| 2563 return completer.future; | 2562 return completer.future; |
| 2564 } | 2563 } |
| 2565 | 2564 |
| 2566 Future<BrowserTestRunner> _getBrowserTestRunner( | 2565 Future<BrowserTestRunner> _getBrowserTestRunner(String browser, |
| 2567 String browser, bool checkedMode) { | 2566 Map configuration) { |
| 2568 var browserCheckedString = "$browser-$checkedMode"; | |
| 2569 | |
| 2570 var localIp = globalConfiguration['local_ip']; | 2567 var localIp = globalConfiguration['local_ip']; |
| 2571 var num_browsers = maxBrowserProcesses; | 2568 var num_browsers = maxBrowserProcesses; |
| 2572 if (_browserTestRunners[browserCheckedString] == null) { | 2569 if (_browserTestRunners[configuration] == null) { |
| 2573 var testRunner = new BrowserTestRunner( | 2570 var testRunner = new BrowserTestRunner( |
| 2574 globalConfiguration, localIp, browser, num_browsers, | 2571 configuration, localIp, browser, num_browsers); |
| 2575 checkedMode: checkedMode); | |
| 2576 if (globalConfiguration['verbose']) { | 2572 if (globalConfiguration['verbose']) { |
| 2577 testRunner.logger = DebugLogger.info; | 2573 testRunner.logger = DebugLogger.info; |
| 2578 } | 2574 } |
| 2579 _browserTestRunners[browserCheckedString] = testRunner; | 2575 _browserTestRunners[configuration] = testRunner; |
| 2580 return testRunner.start().then((started) { | 2576 return testRunner.start().then((started) { |
| 2581 if (started) { | 2577 if (started) { |
| 2582 return testRunner; | 2578 return testRunner; |
| 2583 } | 2579 } |
| 2584 print("Issue starting browser test runner"); | 2580 print("Issue starting browser test runner"); |
| 2585 io.exit(1); | 2581 io.exit(1); |
| 2586 }); | 2582 }); |
| 2587 } | 2583 } |
| 2588 return new Future.value(_browserTestRunners[browserCheckedString]); | 2584 return new Future.value(_browserTestRunners[configuration]); |
| 2589 } | 2585 } |
| 2590 } | 2586 } |
| 2591 | 2587 |
| 2592 class RecordingCommandExecutor implements CommandExecutor { | 2588 class RecordingCommandExecutor implements CommandExecutor { |
| 2593 TestCaseRecorder _recorder; | 2589 TestCaseRecorder _recorder; |
| 2594 | 2590 |
| 2595 RecordingCommandExecutor(Path path) | 2591 RecordingCommandExecutor(Path path) |
| 2596 : _recorder = new TestCaseRecorder(path); | 2592 : _recorder = new TestCaseRecorder(path); |
| 2597 | 2593 |
| 2598 Future<CommandOutput> runCommand(node, ProcessCommand command, int timeout) { | 2594 Future<CommandOutput> runCommand(node, ProcessCommand command, int timeout) { |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2957 } | 2953 } |
| 2958 } | 2954 } |
| 2959 | 2955 |
| 2960 void eventAllTestsDone() { | 2956 void eventAllTestsDone() { |
| 2961 for (var listener in _eventListener) { | 2957 for (var listener in _eventListener) { |
| 2962 listener.allDone(); | 2958 listener.allDone(); |
| 2963 } | 2959 } |
| 2964 _allDone(); | 2960 _allDone(); |
| 2965 } | 2961 } |
| 2966 } | 2962 } |
| OLD | NEW |