| 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. |
| 11 */ | 11 */ |
| 12 import 'dart:async'; | 12 library test_runner; |
| 13 import 'dart:collection'; | 13 |
| 14 import 'dart:convert'; | 14 import "dart:async"; |
| 15 import "dart:collection" show Queue; |
| 16 import "dart:convert" show LineSplitter, UTF8, JSON; |
| 15 // We need to use the 'io' prefix here, otherwise io.exitCode will shadow | 17 // We need to use the 'io' prefix here, otherwise io.exitCode will shadow |
| 16 // CommandOutput.exitCode in subclasses of CommandOutput. | 18 // CommandOutput.exitCode in subclasses of CommandOutput. |
| 17 import 'dart:io' as io; | 19 import "dart:io" as io; |
| 18 import 'dart:math' as math; | 20 import "dart:math" as math; |
| 19 | 21 |
| 20 import 'android.dart'; | 22 import 'android.dart'; |
| 21 import 'browser_controller.dart'; | 23 import "browser_controller.dart"; |
| 22 import 'configuration.dart'; | |
| 23 import 'dependency_graph.dart' as dgraph; | 24 import 'dependency_graph.dart' as dgraph; |
| 24 import 'expectation.dart'; | 25 import "expectation.dart"; |
| 25 import 'path.dart'; | 26 import "path.dart"; |
| 26 import 'record_and_replay.dart'; | 27 import 'record_and_replay.dart'; |
| 27 import 'runtime_configuration.dart'; | 28 import "runtime_configuration.dart"; |
| 28 import 'test_progress.dart'; | 29 import "test_progress.dart"; |
| 29 import 'test_suite.dart'; | 30 import "test_suite.dart"; |
| 30 import 'utils.dart'; | 31 import "utils.dart"; |
| 31 | 32 |
| 32 const int CRASHING_BROWSER_EXITCODE = -10; | 33 const int CRASHING_BROWSER_EXITCODE = -10; |
| 33 const int SLOW_TIMEOUT_MULTIPLIER = 4; | 34 const int SLOW_TIMEOUT_MULTIPLIER = 4; |
| 34 const int NON_UTF_FAKE_EXITCODE = 0xFFFD; | 35 const int NON_UTF_FAKE_EXITCODE = 0xFFFD; |
| 35 | 36 |
| 36 const MESSAGE_CANNOT_OPEN_DISPLAY = 'Gtk-WARNING **: cannot open display'; | 37 const MESSAGE_CANNOT_OPEN_DISPLAY = 'Gtk-WARNING **: cannot open display'; |
| 37 const MESSAGE_FAILED_TO_RUN_COMMAND = 'Failed to run command. return code=1'; | 38 const MESSAGE_FAILED_TO_RUN_COMMAND = 'Failed to run command. return code=1'; |
| 38 | 39 |
| 39 typedef void TestCaseEvent(TestCase testCase); | 40 typedef void TestCaseEvent(TestCase testCase); |
| 40 typedef void ExitCodeEvent(int exitCode); | 41 typedef void ExitCodeEvent(int exitCode); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 static List<String> _getArguments(List<String> options, String htmlFile) { | 288 static List<String> _getArguments(List<String> options, String htmlFile) { |
| 288 var arguments = options.toList(); | 289 var arguments = options.toList(); |
| 289 arguments.add(htmlFile); | 290 arguments.add(htmlFile); |
| 290 return arguments; | 291 return arguments; |
| 291 } | 292 } |
| 292 | 293 |
| 293 int get maxNumRetries => 3; | 294 int get maxNumRetries => 3; |
| 294 } | 295 } |
| 295 | 296 |
| 296 class BrowserTestCommand extends Command { | 297 class BrowserTestCommand extends Command { |
| 297 Runtime get browser => configuration.runtime; | 298 final String browser; |
| 298 final String url; | 299 final String url; |
| 299 final Configuration configuration; | 300 final Map<String, dynamic> configuration; |
| 300 final bool retry; | 301 final bool retry; |
| 301 | 302 |
| 302 BrowserTestCommand._(this.url, this.configuration, this.retry) | 303 BrowserTestCommand._( |
| 303 : super._(configuration.runtime.name); | 304 String _browser, this.url, this.configuration, this.retry) |
| 305 : browser = _browser, |
| 306 super._(_browser); |
| 304 | 307 |
| 305 void _buildHashCode(HashCodeBuilder builder) { | 308 void _buildHashCode(HashCodeBuilder builder) { |
| 306 super._buildHashCode(builder); | 309 super._buildHashCode(builder); |
| 307 builder.addJson(browser.name); | 310 builder.addJson(browser); |
| 308 builder.addJson(url); | 311 builder.addJson(url); |
| 309 builder.add(configuration); | 312 builder.add(configuration); |
| 310 builder.add(retry); | 313 builder.add(retry); |
| 311 } | 314 } |
| 312 | 315 |
| 313 bool _equal(BrowserTestCommand other) => | 316 bool _equal(BrowserTestCommand other) => |
| 314 super._equal(other) && | 317 super._equal(other) && |
| 315 browser == other.browser && | 318 browser == other.browser && |
| 316 url == other.url && | 319 url == other.url && |
| 317 identical(configuration, other.configuration) && | 320 identical(configuration, other.configuration) && |
| 318 retry == other.retry; | 321 retry == other.retry; |
| 319 | 322 |
| 320 String get reproductionCommand { | 323 String get reproductionCommand { |
| 321 var parts = [ | 324 var parts = [ |
| 322 io.Platform.resolvedExecutable, | 325 io.Platform.resolvedExecutable, |
| 323 'tools/testing/dart/launch_browser.dart', | 326 'tools/testing/dart/launch_browser.dart', |
| 324 browser.name, | 327 browser, |
| 325 url | 328 url |
| 326 ]; | 329 ]; |
| 327 return parts.map(escapeCommandLineArgument).join(' '); | 330 return parts.map(escapeCommandLineArgument).join(' '); |
| 328 } | 331 } |
| 329 | 332 |
| 330 int get maxNumRetries => 4; | 333 int get maxNumRetries => 4; |
| 331 } | 334 } |
| 332 | 335 |
| 333 class BrowserHtmlTestCommand extends BrowserTestCommand { | 336 class BrowserHtmlTestCommand extends BrowserTestCommand { |
| 334 List<String> expectedMessages; | 337 List<String> expectedMessages; |
| 335 BrowserHtmlTestCommand._(String url, Configuration configuration, | 338 BrowserHtmlTestCommand._(String browser, String url, |
| 336 this.expectedMessages, bool retry) | 339 Map<String, dynamic> configuration, this.expectedMessages, bool retry) |
| 337 : super._(url, configuration, retry); | 340 : super._(browser, url, configuration, retry); |
| 338 | 341 |
| 339 void _buildHashCode(HashCodeBuilder builder) { | 342 void _buildHashCode(HashCodeBuilder builder) { |
| 340 super._buildHashCode(builder); | 343 super._buildHashCode(builder); |
| 341 builder.addJson(expectedMessages); | 344 builder.addJson(expectedMessages); |
| 342 } | 345 } |
| 343 | 346 |
| 344 bool _equal(BrowserHtmlTestCommand other) => | 347 bool _equal(BrowserHtmlTestCommand other) => |
| 345 super._equal(other) && | 348 super._equal(other) && |
| 346 identical(expectedMessages, other.expectedMessages); | 349 identical(expectedMessages, other.expectedMessages); |
| 347 } | 350 } |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 String executable, | 576 String executable, |
| 574 String htmlFile, | 577 String htmlFile, |
| 575 List<String> options, | 578 List<String> options, |
| 576 List<String> dartFlags, | 579 List<String> dartFlags, |
| 577 Map<String, String> environment) { | 580 Map<String, String> environment) { |
| 578 ContentShellCommand command = new ContentShellCommand._( | 581 ContentShellCommand command = new ContentShellCommand._( |
| 579 executable, htmlFile, options, dartFlags, environment); | 582 executable, htmlFile, options, dartFlags, environment); |
| 580 return _getUniqueCommand(command); | 583 return _getUniqueCommand(command); |
| 581 } | 584 } |
| 582 | 585 |
| 583 BrowserTestCommand getBrowserTestCommand( | 586 BrowserTestCommand getBrowserTestCommand(String browser, String url, |
| 584 String url, Configuration configuration, bool retry) { | 587 Map<String, dynamic> configuration, bool retry) { |
| 585 var command = new BrowserTestCommand._(url, configuration, retry); | 588 var command = new BrowserTestCommand._(browser, url, configuration, retry); |
| 586 return _getUniqueCommand(command); | 589 return _getUniqueCommand(command); |
| 587 } | 590 } |
| 588 | 591 |
| 589 BrowserHtmlTestCommand getBrowserHtmlTestCommand(String url, | 592 BrowserHtmlTestCommand getBrowserHtmlTestCommand( |
| 590 Configuration configuration, List<String> expectedMessages, bool retry) { | 593 String browser, |
| 594 String url, |
| 595 Map<String, dynamic> configuration, |
| 596 List<String> expectedMessages, |
| 597 bool retry) { |
| 591 var command = new BrowserHtmlTestCommand._( | 598 var command = new BrowserHtmlTestCommand._( |
| 592 url, configuration, expectedMessages, retry); | 599 browser, url, configuration, expectedMessages, retry); |
| 593 return _getUniqueCommand(command); | 600 return _getUniqueCommand(command); |
| 594 } | 601 } |
| 595 | 602 |
| 596 CompilationCommand getCompilationCommand( | 603 CompilationCommand getCompilationCommand( |
| 597 String displayName, | 604 String displayName, |
| 598 String outputFile, | 605 String outputFile, |
| 599 bool neverSkipCompilation, | 606 bool neverSkipCompilation, |
| 600 List<Uri> bootstrapDependencies, | 607 List<Uri> bootstrapDependencies, |
| 601 String executable, | 608 String executable, |
| 602 List<String> arguments, | 609 List<String> arguments, |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 /** | 753 /** |
| 747 * A list of commands to execute. Most test cases have a single command. | 754 * A list of commands to execute. Most test cases have a single command. |
| 748 * Dart2js tests have two commands, one to compile the source and another | 755 * Dart2js tests have two commands, one to compile the source and another |
| 749 * to execute it. Some isolate tests might even have three, if they require | 756 * to execute it. Some isolate tests might even have three, if they require |
| 750 * compiling multiple sources that are run in isolation. | 757 * compiling multiple sources that are run in isolation. |
| 751 */ | 758 */ |
| 752 List<Command> commands; | 759 List<Command> commands; |
| 753 Map<Command, CommandOutput> commandOutputs = | 760 Map<Command, CommandOutput> commandOutputs = |
| 754 new Map<Command, CommandOutput>(); | 761 new Map<Command, CommandOutput>(); |
| 755 | 762 |
| 756 Configuration configuration; | 763 Map configuration; |
| 757 String displayName; | 764 String displayName; |
| 758 int _expectations = 0; | 765 int _expectations = 0; |
| 759 int hash = 0; | 766 int hash = 0; |
| 760 Set<Expectation> expectedOutcomes; | 767 Set<Expectation> expectedOutcomes; |
| 761 | 768 |
| 762 TestCase(this.displayName, this.commands, this.configuration, | 769 TestCase(this.displayName, this.commands, this.configuration, |
| 763 this.expectedOutcomes, | 770 this.expectedOutcomes, |
| 764 {bool isNegative: false, TestInformation info}) { | 771 {bool isNegative: false, TestInformation info}) { |
| 765 if (isNegative || displayName.contains("negative_test")) { | 772 if (isNegative || displayName.contains("negative_test")) { |
| 766 _expectations |= IS_NEGATIVE; | 773 _expectations |= IS_NEGATIVE; |
| 767 } | 774 } |
| 768 if (info != null) { | 775 if (info != null) { |
| 769 _setExpectations(info); | 776 _setExpectations(info); |
| 770 hash = | 777 hash = |
| 771 info.originTestPath.relativeTo(TestUtils.dartDir).toString().hashCode; | 778 info.originTestPath.relativeTo(TestUtils.dartDir).toString().hashCode; |
| 772 } | 779 } |
| 773 } | 780 } |
| 774 | 781 |
| 775 void _setExpectations(TestInformation info) { | 782 void _setExpectations(TestInformation info) { |
| 776 // We don't want to keep the entire (large) TestInformation structure, | 783 // We don't want to keep the entire (large) TestInformation structure, |
| 777 // so we copy the needed bools into flags set in a single integer. | 784 // so we copy the needed bools into flags set in a single integer. |
| 778 if (info.hasRuntimeError) _expectations |= HAS_RUNTIME_ERROR; | 785 if (info.hasRuntimeError) _expectations |= HAS_RUNTIME_ERROR; |
| 779 if (info.hasStaticWarning) _expectations |= HAS_STATIC_WARNING; | 786 if (info.hasStaticWarning) _expectations |= HAS_STATIC_WARNING; |
| 780 if (info.isNegativeIfChecked) _expectations |= IS_NEGATIVE_IF_CHECKED; | 787 if (info.isNegativeIfChecked) _expectations |= IS_NEGATIVE_IF_CHECKED; |
| 781 if (info.hasCompileError) _expectations |= HAS_COMPILE_ERROR; | 788 if (info.hasCompileError) _expectations |= HAS_COMPILE_ERROR; |
| 782 if (info.hasCompileErrorIfChecked) { | 789 if (info.hasCompileErrorIfChecked) { |
| 783 _expectations |= HAS_COMPILE_ERROR_IF_CHECKED; | 790 _expectations |= HAS_COMPILE_ERROR_IF_CHECKED; |
| 784 } | 791 } |
| 785 if (info.hasCompileError || | 792 if (info.hasCompileError || |
| 786 (configuration.isChecked && info.hasCompileErrorIfChecked)) { | 793 ((configuration['checked'] as bool) && info.hasCompileErrorIfChecked)) { |
| 787 _expectations |= EXPECT_COMPILE_ERROR; | 794 _expectations |= EXPECT_COMPILE_ERROR; |
| 788 } | 795 } |
| 789 } | 796 } |
| 790 | 797 |
| 791 bool get isNegative => _expectations & IS_NEGATIVE != 0; | 798 bool get isNegative => _expectations & IS_NEGATIVE != 0; |
| 792 bool get hasRuntimeError => _expectations & HAS_RUNTIME_ERROR != 0; | 799 bool get hasRuntimeError => _expectations & HAS_RUNTIME_ERROR != 0; |
| 793 bool get hasStaticWarning => _expectations & HAS_STATIC_WARNING != 0; | 800 bool get hasStaticWarning => _expectations & HAS_STATIC_WARNING != 0; |
| 794 bool get isNegativeIfChecked => _expectations & IS_NEGATIVE_IF_CHECKED != 0; | 801 bool get isNegativeIfChecked => _expectations & IS_NEGATIVE_IF_CHECKED != 0; |
| 795 bool get hasCompileError => _expectations & HAS_COMPILE_ERROR != 0; | 802 bool get hasCompileError => _expectations & HAS_COMPILE_ERROR != 0; |
| 796 bool get hasCompileErrorIfChecked => | 803 bool get hasCompileErrorIfChecked => |
| (...skipping 21 matching lines...) Expand all Loading... |
| 818 Command get lastCommandExecuted { | 825 Command get lastCommandExecuted { |
| 819 if (commandOutputs.length == 0) { | 826 if (commandOutputs.length == 0) { |
| 820 throw new Exception("CommandOutputs is empty, maybe no command was run? (" | 827 throw new Exception("CommandOutputs is empty, maybe no command was run? (" |
| 821 "displayName: '$displayName', " | 828 "displayName: '$displayName', " |
| 822 "configurationString: '$configurationString')"); | 829 "configurationString: '$configurationString')"); |
| 823 } | 830 } |
| 824 return commands[commandOutputs.length - 1]; | 831 return commands[commandOutputs.length - 1]; |
| 825 } | 832 } |
| 826 | 833 |
| 827 int get timeout { | 834 int get timeout { |
| 828 var result = configuration.timeout; | |
| 829 if (expectedOutcomes.contains(Expectation.slow)) { | 835 if (expectedOutcomes.contains(Expectation.slow)) { |
| 830 result *= SLOW_TIMEOUT_MULTIPLIER; | 836 return (configuration['timeout'] as int) * SLOW_TIMEOUT_MULTIPLIER; |
| 837 } else { |
| 838 return configuration['timeout'] as int; |
| 831 } | 839 } |
| 832 return result; | |
| 833 } | 840 } |
| 834 | 841 |
| 835 String get configurationString { | 842 String get configurationString { |
| 836 var compiler = configuration.compiler.name; | 843 var compiler = configuration['compiler'] as String; |
| 837 var runtime = configuration.runtime.name; | 844 var runtime = configuration['runtime'] as String; |
| 838 var mode = configuration.mode.name; | 845 var mode = configuration['mode'] as String; |
| 839 var arch = configuration.architecture.name; | 846 var arch = configuration['arch'] as String; |
| 840 var checked = configuration.isChecked ? '-checked' : ''; | 847 var checked = configuration['checked'] as bool ? '-checked' : ''; |
| 841 return "$compiler-$runtime$checked ${mode}_$arch"; | 848 return "$compiler-$runtime$checked ${mode}_$arch"; |
| 842 } | 849 } |
| 843 | 850 |
| 844 List<String> get batchTestArguments { | 851 List<String> get batchTestArguments { |
| 845 assert(commands.last is ProcessCommand); | 852 assert(commands.last is ProcessCommand); |
| 846 return (commands.last as ProcessCommand).arguments; | 853 return (commands.last as ProcessCommand).arguments; |
| 847 } | 854 } |
| 848 | 855 |
| 849 bool get isFlaky { | 856 bool get isFlaky { |
| 850 if (expectedOutcomes.contains(Expectation.skip) || | 857 if (expectedOutcomes.contains(Expectation.skip) || |
| (...skipping 16 matching lines...) Expand all Loading... |
| 867 | 874 |
| 868 /** | 875 /** |
| 869 * BrowserTestCase has an extra compilation command that is run in a separate | 876 * BrowserTestCase has an extra compilation command that is run in a separate |
| 870 * process, before the regular test is run as in the base class [TestCase]. | 877 * process, before the regular test is run as in the base class [TestCase]. |
| 871 * If the compilation command fails, then the rest of the test is not run. | 878 * If the compilation command fails, then the rest of the test is not run. |
| 872 */ | 879 */ |
| 873 class BrowserTestCase extends TestCase { | 880 class BrowserTestCase extends TestCase { |
| 874 BrowserTestCase( | 881 BrowserTestCase( |
| 875 String displayName, | 882 String displayName, |
| 876 List<Command> commands, | 883 List<Command> commands, |
| 877 Configuration configuration, | 884 Map<String, dynamic> configuration, |
| 878 Set<Expectation> expectedOutcomes, | 885 Set<Expectation> expectedOutcomes, |
| 879 TestInformation info, | 886 TestInformation info, |
| 880 bool isNegative, | 887 bool isNegative, |
| 881 this._testingUrl) | 888 this._testingUrl) |
| 882 : super(displayName, commands, configuration, expectedOutcomes, | 889 : super(displayName, commands, configuration, expectedOutcomes, |
| 883 isNegative: isNegative, info: info); | 890 isNegative: isNegative, info: info); |
| 884 | 891 |
| 885 String _testingUrl; | 892 String _testingUrl; |
| 886 | 893 |
| 887 String get testingUrl => _testingUrl; | 894 String get testingUrl => _testingUrl; |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1071 } | 1078 } |
| 1072 // TODO(26739): See http://dartbug.com/26739 | 1079 // TODO(26739): See http://dartbug.com/26739 |
| 1073 if (zygoteCrash.hasMatch(stderr)) { | 1080 if (zygoteCrash.hasMatch(stderr)) { |
| 1074 DebugLogger.warning("Warning: Failure because of content_shell " | 1081 DebugLogger.warning("Warning: Failure because of content_shell " |
| 1075 "zygote crash. Test ignored"); | 1082 "zygote crash. Test ignored"); |
| 1076 return true; | 1083 return true; |
| 1077 } | 1084 } |
| 1078 // TODO(28955): See http://dartbug.com/28955 | 1085 // TODO(28955): See http://dartbug.com/28955 |
| 1079 if (timedOut && | 1086 if (timedOut && |
| 1080 command is BrowserTestCommand && | 1087 command is BrowserTestCommand && |
| 1081 command.browser == Runtime.ie11) { | 1088 command.browser == "ie11") { |
| 1082 DebugLogger.warning("Timeout of ie11 on test page ${command.url}"); | 1089 DebugLogger.warning("Timeout of ie11 on test page ${command.url}"); |
| 1083 return true; | 1090 return true; |
| 1084 } | 1091 } |
| 1085 return false; | 1092 return false; |
| 1086 } | 1093 } |
| 1087 | 1094 |
| 1088 bool _infraFailure; | 1095 bool _infraFailure; |
| 1089 | 1096 |
| 1090 BrowserCommandOutputImpl( | 1097 BrowserCommandOutputImpl( |
| 1091 Command command, | 1098 Command command, |
| (...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1926 int timeout; | 1933 int timeout; |
| 1927 bool timedOut = false; | 1934 bool timedOut = false; |
| 1928 DateTime startTime; | 1935 DateTime startTime; |
| 1929 Timer timeoutTimer; | 1936 Timer timeoutTimer; |
| 1930 int pid; | 1937 int pid; |
| 1931 OutputLog stdout = new OutputLog(); | 1938 OutputLog stdout = new OutputLog(); |
| 1932 OutputLog stderr = new OutputLog(); | 1939 OutputLog stderr = new OutputLog(); |
| 1933 List<String> diagnostics = <String>[]; | 1940 List<String> diagnostics = <String>[]; |
| 1934 bool compilationSkipped = false; | 1941 bool compilationSkipped = false; |
| 1935 Completer<CommandOutput> completer; | 1942 Completer<CommandOutput> completer; |
| 1936 Configuration configuration; | 1943 Map configuration; |
| 1937 | 1944 |
| 1938 RunningProcess(this.command, this.timeout, {this.configuration}); | 1945 RunningProcess(this.command, this.timeout, {this.configuration}); |
| 1939 | 1946 |
| 1940 Future<CommandOutput> run() { | 1947 Future<CommandOutput> run() { |
| 1941 completer = new Completer<CommandOutput>(); | 1948 completer = new Completer<CommandOutput>(); |
| 1942 startTime = new DateTime.now(); | 1949 startTime = new DateTime.now(); |
| 1943 _runCommand(); | 1950 _runCommand(); |
| 1944 return completer.future; | 1951 return completer.future; |
| 1945 } | 1952 } |
| 1946 | 1953 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2004 executable = 'eu-stack'; | 2011 executable = 'eu-stack'; |
| 2005 } else if (io.Platform.isMacOS) { | 2012 } else if (io.Platform.isMacOS) { |
| 2006 // Try to print stack traces of the timed out process. | 2013 // Try to print stack traces of the timed out process. |
| 2007 // `sample` is a sampling profiler but we ask it sample for 1 | 2014 // `sample` is a sampling profiler but we ask it sample for 1 |
| 2008 // second with a 4 second delay between samples so that we only | 2015 // second with a 4 second delay between samples so that we only |
| 2009 // sample the threads once. | 2016 // sample the threads once. |
| 2010 executable = '/usr/bin/sample'; | 2017 executable = '/usr/bin/sample'; |
| 2011 } else if (io.Platform.isWindows) { | 2018 } else if (io.Platform.isWindows) { |
| 2012 var isX64 = command.executable.contains("X64") || | 2019 var isX64 = command.executable.contains("X64") || |
| 2013 command.executable.contains("SIMARM64"); | 2020 command.executable.contains("SIMARM64"); |
| 2014 if (configuration.windowsSdkPath != null) { | 2021 var winSdkPath = configuration['win_sdk_path'] as String; |
| 2015 executable = configuration.windowsSdkPath + | 2022 if (winSdkPath != null) { |
| 2016 "\\Debuggers\\${isX64 ? 'x64' : 'x86'}\\cdb.exe"; | 2023 executable = winSdkPath + |
| 2024 "\\Debuggers\\" + |
| 2025 (isX64 ? "x64" : "x86") + |
| 2026 "\\cdb.exe"; |
| 2017 diagnostics.add("Using $executable to print stack traces"); | 2027 diagnostics.add("Using $executable to print stack traces"); |
| 2018 } else { | 2028 } else { |
| 2019 diagnostics.add("win_sdk_path not found"); | 2029 diagnostics.add("win_sdk path not found"); |
| 2020 } | 2030 } |
| 2021 } else { | 2031 } else { |
| 2022 diagnostics.add("Capturing stack traces on" | 2032 diagnostics.add("Capturing stack traces on" |
| 2023 "${io.Platform.operatingSystem} not supported"); | 2033 "${io.Platform.operatingSystem} not supported"); |
| 2024 } | 2034 } |
| 2025 if (executable != null) { | 2035 if (executable != null) { |
| 2026 var pids = await _getPidList(process.pid, diagnostics); | 2036 var pids = await _getPidList(process.pid, diagnostics); |
| 2027 diagnostics.add("Process list including children: $pids"); | 2037 diagnostics.add("Process list including children: $pids"); |
| 2028 for (pid in pids) { | 2038 for (pid in pids) { |
| 2029 List<String> arguments; | 2039 List<String> arguments; |
| (...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2657 * It provides a [cleanup] method to free all the allocated resources. | 2667 * It provides a [cleanup] method to free all the allocated resources. |
| 2658 */ | 2668 */ |
| 2659 abstract class CommandExecutor { | 2669 abstract class CommandExecutor { |
| 2660 Future cleanup(); | 2670 Future cleanup(); |
| 2661 // TODO(kustermann): The [timeout] parameter should be a property of Command | 2671 // TODO(kustermann): The [timeout] parameter should be a property of Command |
| 2662 Future<CommandOutput> runCommand( | 2672 Future<CommandOutput> runCommand( |
| 2663 dgraph.Node node, covariant Command command, int timeout); | 2673 dgraph.Node node, covariant Command command, int timeout); |
| 2664 } | 2674 } |
| 2665 | 2675 |
| 2666 class CommandExecutorImpl implements CommandExecutor { | 2676 class CommandExecutorImpl implements CommandExecutor { |
| 2667 final Configuration globalConfiguration; | 2677 final Map globalConfiguration; |
| 2668 final int maxProcesses; | 2678 final int maxProcesses; |
| 2669 final int maxBrowserProcesses; | 2679 final int maxBrowserProcesses; |
| 2670 AdbDevicePool adbDevicePool; | 2680 AdbDevicePool adbDevicePool; |
| 2671 | 2681 |
| 2672 // For dart2js and analyzer batch processing, | 2682 // For dart2js and analyzer batch processing, |
| 2673 // we keep a list of batch processes. | 2683 // we keep a list of batch processes. |
| 2674 final _batchProcesses = new Map<String, List<BatchRunnerProcess>>(); | 2684 final _batchProcesses = new Map<String, List<BatchRunnerProcess>>(); |
| 2675 // We keep a BrowserTestRunner for every configuration. | 2685 // We keep a BrowserTestRunner for every configuration. |
| 2676 final _browserTestRunners = new Map<Configuration, BrowserTestRunner>(); | 2686 final _browserTestRunners = new Map<Map, BrowserTestRunner>(); |
| 2677 | 2687 |
| 2678 bool _finishing = false; | 2688 bool _finishing = false; |
| 2679 | 2689 |
| 2680 CommandExecutorImpl( | 2690 CommandExecutorImpl( |
| 2681 this.globalConfiguration, this.maxProcesses, this.maxBrowserProcesses, | 2691 this.globalConfiguration, this.maxProcesses, this.maxBrowserProcesses, |
| 2682 {this.adbDevicePool}); | 2692 {this.adbDevicePool}); |
| 2683 | 2693 |
| 2684 Future cleanup() { | 2694 Future cleanup() { |
| 2685 assert(!_finishing); | 2695 assert(!_finishing); |
| 2686 _finishing = true; | 2696 _finishing = true; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2717 } else { | 2727 } else { |
| 2718 return new Future.value(output); | 2728 return new Future.value(output); |
| 2719 } | 2729 } |
| 2720 }); | 2730 }); |
| 2721 } | 2731 } |
| 2722 | 2732 |
| 2723 return runCommand(command.maxNumRetries); | 2733 return runCommand(command.maxNumRetries); |
| 2724 } | 2734 } |
| 2725 | 2735 |
| 2726 Future<CommandOutput> _runCommand(Command command, int timeout) { | 2736 Future<CommandOutput> _runCommand(Command command, int timeout) { |
| 2737 var batchMode = !(globalConfiguration['noBatch'] as bool); |
| 2738 var dart2jsBatchMode = globalConfiguration['dart2js_batch'] as bool; |
| 2739 |
| 2727 if (command is BrowserTestCommand) { | 2740 if (command is BrowserTestCommand) { |
| 2728 return _startBrowserControllerTest(command, timeout); | 2741 return _startBrowserControllerTest(command, timeout); |
| 2729 } else if (command is KernelCompilationCommand) { | 2742 } else if (command is KernelCompilationCommand) { |
| 2730 // For now, we always run dartk in batch mode. | 2743 // For now, we always run dartk in batch mode. |
| 2731 var name = command.displayName; | 2744 var name = command.displayName; |
| 2732 assert(name == 'dartk'); | 2745 assert(name == 'dartk'); |
| 2733 return _getBatchRunner(name) | 2746 return _getBatchRunner(name) |
| 2734 .runCommand(name, command, timeout, command.arguments); | 2747 .runCommand(name, command, timeout, command.arguments); |
| 2735 } else if (command is CompilationCommand && | 2748 } else if (command is CompilationCommand && dart2jsBatchMode) { |
| 2736 globalConfiguration.batchDart2JS) { | |
| 2737 return _getBatchRunner("dart2js") | 2749 return _getBatchRunner("dart2js") |
| 2738 .runCommand("dart2js", command, timeout, command.arguments); | 2750 .runCommand("dart2js", command, timeout, command.arguments); |
| 2739 } else if (command is AnalysisCommand && globalConfiguration.batch) { | 2751 } else if (command is AnalysisCommand && batchMode) { |
| 2740 return _getBatchRunner(command.flavor) | 2752 return _getBatchRunner(command.flavor) |
| 2741 .runCommand(command.flavor, command, timeout, command.arguments); | 2753 .runCommand(command.flavor, command, timeout, command.arguments); |
| 2742 } else if (command is ScriptCommand) { | 2754 } else if (command is ScriptCommand) { |
| 2743 return command.run(); | 2755 return command.run(); |
| 2744 } else if (command is AdbPrecompilationCommand) { | 2756 } else if (command is AdbPrecompilationCommand) { |
| 2745 assert(adbDevicePool != null); | 2757 assert(adbDevicePool != null); |
| 2746 return adbDevicePool.acquireDevice().then((AdbDevice device) { | 2758 return adbDevicePool.acquireDevice().then((AdbDevice device) { |
| 2747 return _runAdbPrecompilationCommand(device, command, timeout) | 2759 return _runAdbPrecompilationCommand(device, command, timeout) |
| 2748 .whenComplete(() { | 2760 .whenComplete(() { |
| 2749 adbDevicePool.releaseDevice(device); | 2761 adbDevicePool.releaseDevice(device); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2863 .complete(new BrowserControllerTestOutcome(browserCommand, output)); | 2875 .complete(new BrowserControllerTestOutcome(browserCommand, output)); |
| 2864 }; | 2876 }; |
| 2865 | 2877 |
| 2866 BrowserTest browserTest; | 2878 BrowserTest browserTest; |
| 2867 if (browserCommand is BrowserHtmlTestCommand) { | 2879 if (browserCommand is BrowserHtmlTestCommand) { |
| 2868 browserTest = new HtmlTest(browserCommand.url, callback, timeout, | 2880 browserTest = new HtmlTest(browserCommand.url, callback, timeout, |
| 2869 browserCommand.expectedMessages); | 2881 browserCommand.expectedMessages); |
| 2870 } else { | 2882 } else { |
| 2871 browserTest = new BrowserTest(browserCommand.url, callback, timeout); | 2883 browserTest = new BrowserTest(browserCommand.url, callback, timeout); |
| 2872 } | 2884 } |
| 2873 _getBrowserTestRunner(browserCommand.configuration).then((testRunner) { | 2885 _getBrowserTestRunner(browserCommand.browser, browserCommand.configuration) |
| 2886 .then((testRunner) { |
| 2874 testRunner.enqueueTest(browserTest); | 2887 testRunner.enqueueTest(browserTest); |
| 2875 }); | 2888 }); |
| 2876 | 2889 |
| 2877 return completer.future; | 2890 return completer.future; |
| 2878 } | 2891 } |
| 2879 | 2892 |
| 2880 Future<BrowserTestRunner> _getBrowserTestRunner( | 2893 Future<BrowserTestRunner> _getBrowserTestRunner( |
| 2881 Configuration configuration) async { | 2894 String browser, Map<String, dynamic> configuration) async { |
| 2895 var localIp = globalConfiguration['local_ip'] as String; |
| 2882 if (_browserTestRunners[configuration] == null) { | 2896 if (_browserTestRunners[configuration] == null) { |
| 2883 var testRunner = new BrowserTestRunner( | 2897 var testRunner = new BrowserTestRunner( |
| 2884 configuration, globalConfiguration.localIP, maxBrowserProcesses); | 2898 configuration, localIp, browser, maxBrowserProcesses); |
| 2885 if (globalConfiguration.isVerbose) { | 2899 if (globalConfiguration['verbose'] as bool) { |
| 2886 testRunner.logger = DebugLogger.info; | 2900 testRunner.logger = DebugLogger.info; |
| 2887 } | 2901 } |
| 2888 _browserTestRunners[configuration] = testRunner; | 2902 _browserTestRunners[configuration] = testRunner; |
| 2889 await testRunner.start(); | 2903 await testRunner.start(); |
| 2890 } | 2904 } |
| 2891 return _browserTestRunners[configuration]; | 2905 return _browserTestRunners[configuration]; |
| 2892 } | 2906 } |
| 2893 } | 2907 } |
| 2894 | 2908 |
| 2895 class RecordingCommandExecutor implements CommandExecutor { | 2909 class RecordingCommandExecutor implements CommandExecutor { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2961 if (stdout.any(containsOutOfMemoryMessage) || | 2975 if (stdout.any(containsOutOfMemoryMessage) || |
| 2962 stderr.any(containsOutOfMemoryMessage)) { | 2976 stderr.any(containsOutOfMemoryMessage)) { |
| 2963 return true; | 2977 return true; |
| 2964 } | 2978 } |
| 2965 } | 2979 } |
| 2966 } | 2980 } |
| 2967 | 2981 |
| 2968 // We currently rerun dartium tests, see issue 14074. | 2982 // We currently rerun dartium tests, see issue 14074. |
| 2969 if (command is BrowserTestCommand && | 2983 if (command is BrowserTestCommand && |
| 2970 command.retry && | 2984 command.retry && |
| 2971 command.browser == Runtime.dartium) { | 2985 command.browser == 'dartium') { |
| 2972 return true; | 2986 return true; |
| 2973 } | 2987 } |
| 2974 | 2988 |
| 2975 // As long as we use a legacy version of our custom content_shell (which | 2989 // As long as we use a legacy version of our custom content_shell (which |
| 2976 // became quite flaky after chrome-50 roll) we'll re-run tests on it. | 2990 // became quite flaky after chrome-50 roll) we'll re-run tests on it. |
| 2977 // The plan is to use chrome's content_shell instead of our own. | 2991 // The plan is to use chrome's content_shell instead of our own. |
| 2978 // See http://dartbug.com/29655 . | 2992 // See http://dartbug.com/29655 . |
| 2979 if (command is ContentShellCommand) { | 2993 if (command is ContentShellCommand) { |
| 2980 return true; | 2994 return true; |
| 2981 } | 2995 } |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3094 // [TestCase.isFinished] will return true if all commands were executed | 3108 // [TestCase.isFinished] will return true if all commands were executed |
| 3095 // or if a previous one failed. | 3109 // or if a previous one failed. |
| 3096 if (testCase.isFinished) { | 3110 if (testCase.isFinished) { |
| 3097 completeTestCase(testCase); | 3111 completeTestCase(testCase); |
| 3098 } | 3112 } |
| 3099 } | 3113 } |
| 3100 } | 3114 } |
| 3101 } | 3115 } |
| 3102 | 3116 |
| 3103 class ProcessQueue { | 3117 class ProcessQueue { |
| 3104 Configuration _globalConfiguration; | 3118 Map _globalConfiguration; |
| 3105 | 3119 |
| 3106 Function _allDone; | 3120 Function _allDone; |
| 3107 final dgraph.Graph _graph = new dgraph.Graph(); | 3121 final dgraph.Graph _graph = new dgraph.Graph(); |
| 3108 List<EventListener> _eventListener; | 3122 List<EventListener> _eventListener; |
| 3109 | 3123 |
| 3110 ProcessQueue( | 3124 ProcessQueue( |
| 3111 this._globalConfiguration, | 3125 this._globalConfiguration, |
| 3112 int maxProcesses, | 3126 int maxProcesses, |
| 3113 int maxBrowserProcesses, | 3127 int maxBrowserProcesses, |
| 3114 DateTime startTime, | 3128 DateTime startTime, |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3249 | 3263 |
| 3250 resetDebugTimer(); | 3264 resetDebugTimer(); |
| 3251 } | 3265 } |
| 3252 | 3266 |
| 3253 // Build up the dependency graph | 3267 // Build up the dependency graph |
| 3254 testCaseEnqueuer = new TestCaseEnqueuer(_graph, (TestCase newTestCase) { | 3268 testCaseEnqueuer = new TestCaseEnqueuer(_graph, (TestCase newTestCase) { |
| 3255 eventTestAdded(newTestCase); | 3269 eventTestAdded(newTestCase); |
| 3256 }); | 3270 }); |
| 3257 | 3271 |
| 3258 // Either list or run the tests | 3272 // Either list or run the tests |
| 3259 if (_globalConfiguration.listTests) { | 3273 if (_globalConfiguration['list'] as bool) { |
| 3260 setupForListing(testCaseEnqueuer); | 3274 setupForListing(testCaseEnqueuer); |
| 3261 } else { | 3275 } else { |
| 3262 setupForRunning(testCaseEnqueuer); | 3276 setupForRunning(testCaseEnqueuer); |
| 3263 } | 3277 } |
| 3264 | 3278 |
| 3265 // Start enqueing all TestCases | 3279 // Start enqueing all TestCases |
| 3266 testCaseEnqueuer.enqueueTestSuites(testSuites); | 3280 testCaseEnqueuer.enqueueTestSuites(testSuites); |
| 3267 } | 3281 } |
| 3268 | 3282 |
| 3269 void freeEnqueueingStructures() { | 3283 void freeEnqueueingStructures() { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3289 } | 3303 } |
| 3290 } | 3304 } |
| 3291 | 3305 |
| 3292 void eventAllTestsDone() { | 3306 void eventAllTestsDone() { |
| 3293 for (var listener in _eventListener) { | 3307 for (var listener in _eventListener) { |
| 3294 listener.allDone(); | 3308 listener.allDone(); |
| 3295 } | 3309 } |
| 3296 _allDone(); | 3310 _allDone(); |
| 3297 } | 3311 } |
| 3298 } | 3312 } |
| OLD | NEW |