| 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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 return arguments; | 255 return arguments; |
| 256 } | 256 } |
| 257 | 257 |
| 258 int get maxNumRetries => 3; | 258 int get maxNumRetries => 3; |
| 259 } | 259 } |
| 260 | 260 |
| 261 class BrowserTestCommand extends Command { | 261 class BrowserTestCommand extends Command { |
| 262 final String browser; | 262 final String browser; |
| 263 final String url; | 263 final String url; |
| 264 final Map configuration; | 264 final Map configuration; |
| 265 final bool retry; |
| 265 | 266 |
| 266 BrowserTestCommand._(String _browser, | 267 BrowserTestCommand._(String _browser, |
| 267 this.url, | 268 this.url, |
| 268 this.configuration) | 269 this.configuration, |
| 270 this.retry) |
| 269 : super._(_browser), browser = _browser; | 271 : super._(_browser), browser = _browser; |
| 270 | 272 |
| 271 void _buildHashCode(HashCodeBuilder builder) { | 273 void _buildHashCode(HashCodeBuilder builder) { |
| 272 super._buildHashCode(builder); | 274 super._buildHashCode(builder); |
| 273 builder.addJson(browser); | 275 builder.addJson(browser); |
| 274 builder.addJson(url); | 276 builder.addJson(url); |
| 275 builder.add(configuration); | 277 builder.add(configuration); |
| 278 builder.add(retry); |
| 276 } | 279 } |
| 277 | 280 |
| 278 bool _equal(BrowserTestCommand other) => | 281 bool _equal(BrowserTestCommand other) => |
| 279 super._equal(other) && | 282 super._equal(other) && |
| 280 browser == other.browser && | 283 browser == other.browser && |
| 281 url == other.url && | 284 url == other.url && |
| 282 identical(configuration, other.configuration); | 285 identical(configuration, other.configuration) && |
| 286 retry == other.retry; |
| 283 | 287 |
| 284 String get reproductionCommand { | 288 String get reproductionCommand { |
| 285 var parts = [TestUtils.dartTestExecutable.toString(), | 289 var parts = [TestUtils.dartTestExecutable.toString(), |
| 286 'tools/testing/dart/launch_browser.dart', | 290 'tools/testing/dart/launch_browser.dart', |
| 287 browser, | 291 browser, |
| 288 url]; | 292 url]; |
| 289 return parts.map(escapeCommandLineArgument).join(' '); | 293 return parts.map(escapeCommandLineArgument).join(' '); |
| 290 } | 294 } |
| 291 } | 295 } |
| 292 | 296 |
| 293 class BrowserHtmlTestCommand extends BrowserTestCommand { | 297 class BrowserHtmlTestCommand extends BrowserTestCommand { |
| 294 List<String> expectedMessages; | 298 List<String> expectedMessages; |
| 295 BrowserHtmlTestCommand._(String browser, | 299 BrowserHtmlTestCommand._(String browser, |
| 296 String url, | 300 String url, |
| 297 Map configuration, | 301 Map configuration, |
| 298 this.expectedMessages) | 302 this.expectedMessages, |
| 299 : super._(browser, url, configuration); | 303 bool retry) |
| 304 : super._(browser, url, configuration, retry); |
| 300 | 305 |
| 301 void _buildHashCode(HashCodeBuilder builder) { | 306 void _buildHashCode(HashCodeBuilder builder) { |
| 302 super._buildHashCode(builder); | 307 super._buildHashCode(builder); |
| 303 builder.addJson(expectedMessages); | 308 builder.addJson(expectedMessages); |
| 304 } | 309 } |
| 305 | 310 |
| 306 bool _equal(BrowserHtmlTestCommand other) => | 311 bool _equal(BrowserHtmlTestCommand other) => |
| 307 super._equal(other) && | 312 super._equal(other) && |
| 308 identical(expectedMessages, other.expectedMessages); | 313 identical(expectedMessages, other.expectedMessages); |
| 309 } | 314 } |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 List<String> options, | 564 List<String> options, |
| 560 List<String> dartFlags, | 565 List<String> dartFlags, |
| 561 Map<String, String> environment) { | 566 Map<String, String> environment) { |
| 562 ContentShellCommand command = new ContentShellCommand._( | 567 ContentShellCommand command = new ContentShellCommand._( |
| 563 executable, htmlFile, options, dartFlags, environment); | 568 executable, htmlFile, options, dartFlags, environment); |
| 564 return _getUniqueCommand(command); | 569 return _getUniqueCommand(command); |
| 565 } | 570 } |
| 566 | 571 |
| 567 BrowserTestCommand getBrowserTestCommand(String browser, | 572 BrowserTestCommand getBrowserTestCommand(String browser, |
| 568 String url, | 573 String url, |
| 569 Map configuration) { | 574 Map configuration, |
| 570 var command = new BrowserTestCommand._(browser, url, configuration); | 575 bool retry) { |
| 576 var command = new BrowserTestCommand._(browser, url, configuration, retry); |
| 571 return _getUniqueCommand(command); | 577 return _getUniqueCommand(command); |
| 572 } | 578 } |
| 573 | 579 |
| 574 BrowserHtmlTestCommand getBrowserHtmlTestCommand(String browser, | 580 BrowserHtmlTestCommand getBrowserHtmlTestCommand(String browser, |
| 575 String url, | 581 String url, |
| 576 Map configuration, | 582 Map configuration, |
| 577 List<String> expectedMessages) { | 583 List<String> expectedMessages, |
| 584 bool retry) { |
| 578 var command = new BrowserHtmlTestCommand._( | 585 var command = new BrowserHtmlTestCommand._( |
| 579 browser, url, configuration, expectedMessages); | 586 browser, url, configuration, expectedMessages, retry); |
| 580 return _getUniqueCommand(command); | 587 return _getUniqueCommand(command); |
| 581 } | 588 } |
| 582 | 589 |
| 583 CompilationCommand getCompilationCommand(String displayName, | 590 CompilationCommand getCompilationCommand(String displayName, |
| 584 outputFile, | 591 outputFile, |
| 585 neverSkipCompilation, | 592 neverSkipCompilation, |
| 586 List<Uri> bootstrapDependencies, | 593 List<Uri> bootstrapDependencies, |
| 587 String executable, | 594 String executable, |
| 588 List<String> arguments, | 595 List<String> arguments, |
| 589 Map<String, String> environment) { | 596 Map<String, String> environment) { |
| (...skipping 2019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2609 | 2616 |
| 2610 Future<CommandOutput> runCommand(node, ProcessCommand command, int timeout) { | 2617 Future<CommandOutput> runCommand(node, ProcessCommand command, int timeout) { |
| 2611 assert(node.dependencies.length == 0); | 2618 assert(node.dependencies.length == 0); |
| 2612 return new Future.value(_archive.outputOf(command)); | 2619 return new Future.value(_archive.outputOf(command)); |
| 2613 } | 2620 } |
| 2614 } | 2621 } |
| 2615 | 2622 |
| 2616 bool shouldRetryCommand(CommandOutput output) { | 2623 bool shouldRetryCommand(CommandOutput output) { |
| 2617 var command = output.command; | 2624 var command = output.command; |
| 2618 // We rerun tests on Safari because 6.2 and 7.1 are flaky. Issue 21434. | 2625 // We rerun tests on Safari because 6.2 and 7.1 are flaky. Issue 21434. |
| 2619 if (command is BrowserTestCommand && command.browser == 'safari' && | 2626 if (command is BrowserTestCommand && |
| 2627 command.retry && |
| 2628 command.browser == 'safari' && |
| 2620 output is BrowserControllerTestOutcome && | 2629 output is BrowserControllerTestOutcome && |
| 2621 output._rawOutcome != Expectation.PASS) { | 2630 output._rawOutcome != Expectation.PASS) { |
| 2622 // TODO(whesse): This retries tests that fail intentionally. Fix this | |
| 2623 return true; | 2631 return true; |
| 2624 } | 2632 } |
| 2625 | 2633 |
| 2626 if (!output.successful) { | 2634 if (!output.successful) { |
| 2627 List<String> stdout, stderr; | 2635 List<String> stdout, stderr; |
| 2628 | 2636 |
| 2629 decodeOutput() { | 2637 decodeOutput() { |
| 2630 if (stdout == null && stderr == null) { | 2638 if (stdout == null && stderr == null) { |
| 2631 stdout = decodeUtf8(output.stderr).split("\n"); | 2639 stdout = decodeUtf8(output.stderr).split("\n"); |
| 2632 stderr = decodeUtf8(output.stderr).split("\n"); | 2640 stderr = decodeUtf8(output.stderr).split("\n"); |
| 2633 } | 2641 } |
| 2634 } | 2642 } |
| 2635 | 2643 |
| 2636 if (io.Platform.operatingSystem == 'linux') { | 2644 if (io.Platform.operatingSystem == 'linux') { |
| 2637 decodeOutput(); | 2645 decodeOutput(); |
| 2638 // No matter which command we ran: If we get failures due to the | 2646 // No matter which command we ran: If we get failures due to the |
| 2639 // "xvfb-run" issue 7564, try re-running the test. | 2647 // "xvfb-run" issue 7564, try re-running the test. |
| 2640 bool containsFailureMsg(String line) { | 2648 bool containsFailureMsg(String line) { |
| 2641 return line.contains(MESSAGE_CANNOT_OPEN_DISPLAY) || | 2649 return line.contains(MESSAGE_CANNOT_OPEN_DISPLAY) || |
| 2642 line.contains(MESSAGE_FAILED_TO_RUN_COMMAND); | 2650 line.contains(MESSAGE_FAILED_TO_RUN_COMMAND); |
| 2643 } | 2651 } |
| 2644 if (stdout.any(containsFailureMsg) || stderr.any(containsFailureMsg)) { | 2652 if (stdout.any(containsFailureMsg) || stderr.any(containsFailureMsg)) { |
| 2645 return true; | 2653 return true; |
| 2646 } | 2654 } |
| 2647 } | 2655 } |
| 2648 | 2656 |
| 2649 // We currently rerun dartium tests, see issue 14074. | 2657 // We currently rerun dartium tests, see issue 14074. |
| 2650 if (command is BrowserTestCommand && command.browser == 'dartium') { | 2658 if (command is BrowserTestCommand && |
| 2659 command.retry && |
| 2660 command.browser == 'dartium') { |
| 2651 return true; | 2661 return true; |
| 2652 } | 2662 } |
| 2653 } | 2663 } |
| 2654 return false; | 2664 return false; |
| 2655 } | 2665 } |
| 2656 | 2666 |
| 2657 /* | 2667 /* |
| 2658 * [TestCaseCompleter] will listen for | 2668 * [TestCaseCompleter] will listen for |
| 2659 * NodeState.Processing -> NodeState.{Successful,Failed} state changes and | 2669 * NodeState.Processing -> NodeState.{Successful,Failed} state changes and |
| 2660 * will complete a TestCase if it is finished. | 2670 * will complete a TestCase if it is finished. |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2942 } | 2952 } |
| 2943 } | 2953 } |
| 2944 | 2954 |
| 2945 void eventAllTestsDone() { | 2955 void eventAllTestsDone() { |
| 2946 for (var listener in _eventListener) { | 2956 for (var listener in _eventListener) { |
| 2947 listener.allDone(); | 2957 listener.allDone(); |
| 2948 } | 2958 } |
| 2949 _allDone(); | 2959 _allDone(); |
| 2950 } | 2960 } |
| 2951 } | 2961 } |
| OLD | NEW |