| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 100 |
| 101 /** Command line arguments to the executable. */ | 101 /** Command line arguments to the executable. */ |
| 102 List<String> arguments; | 102 List<String> arguments; |
| 103 | 103 |
| 104 /** Environment for the command */ | 104 /** Environment for the command */ |
| 105 Map<String,String> environment; | 105 Map<String,String> environment; |
| 106 | 106 |
| 107 /** The actual command line that will be executed. */ | 107 /** The actual command line that will be executed. */ |
| 108 String commandLine; | 108 String commandLine; |
| 109 | 109 |
| 110 Command(this.executable, this.arguments, [this.environment = null]) { | 110 /** A descriptive name for this command. */ |
| 111 String displayName; |
| 112 |
| 113 Command(this.displayName, this.executable, |
| 114 this.arguments, [this.environment = null]) { |
| 111 if (io.Platform.operatingSystem == 'windows') { | 115 if (io.Platform.operatingSystem == 'windows') { |
| 112 // Windows can't handle the first command if it is a .bat file or the like | 116 // Windows can't handle the first command if it is a .bat file or the like |
| 113 // with the slashes going the other direction. | 117 // with the slashes going the other direction. |
| 114 // TODO(efortuna): Remove this when fixed (Issue 1306). | 118 // TODO(efortuna): Remove this when fixed (Issue 1306). |
| 115 executable = executable.replaceAll('/', '\\'); | 119 executable = executable.replaceAll('/', '\\'); |
| 116 } | 120 } |
| 117 var quotedArguments = []; | 121 var quotedArguments = []; |
| 118 quotedArguments.add(escapeCommandLineArgument(executable)); | 122 quotedArguments.add(escapeCommandLineArgument(executable)); |
| 119 quotedArguments.addAll(arguments.map(escapeCommandLineArgument)); | 123 quotedArguments.addAll(arguments.map(escapeCommandLineArgument)); |
| 120 commandLine = quotedArguments.join(' '); | 124 commandLine = quotedArguments.join(' '); |
| 121 } | 125 } |
| 122 | 126 |
| 123 String toString() => commandLine; | 127 String toString() => commandLine; |
| 124 | 128 |
| 125 Future<bool> get outputIsUpToDate => new Future.value(false); | 129 Future<bool> get outputIsUpToDate => new Future.value(false); |
| 126 io.Path get expectedOutputFile => null; | 130 io.Path get expectedOutputFile => null; |
| 127 bool get isPixelTest => false; | 131 bool get isPixelTest => false; |
| 128 } | 132 } |
| 129 | 133 |
| 130 class CompilationCommand extends Command { | 134 class CompilationCommand extends Command { |
| 131 String _outputFile; | 135 String _outputFile; |
| 132 bool _neverSkipCompilation; | 136 bool _neverSkipCompilation; |
| 133 List<Uri> _bootstrapDependencies; | 137 List<Uri> _bootstrapDependencies; |
| 134 | 138 |
| 135 CompilationCommand(this._outputFile, | 139 CompilationCommand(String displayName, |
| 140 this._outputFile, |
| 136 this._neverSkipCompilation, | 141 this._neverSkipCompilation, |
| 137 this._bootstrapDependencies, | 142 this._bootstrapDependencies, |
| 138 String executable, | 143 String executable, |
| 139 List<String> arguments) | 144 List<String> arguments) |
| 140 : super(executable, arguments); | 145 : super(displayName, executable, arguments); |
| 141 | 146 |
| 142 Future<bool> get outputIsUpToDate { | 147 Future<bool> get outputIsUpToDate { |
| 143 if (_neverSkipCompilation) return new Future.value(false); | 148 if (_neverSkipCompilation) return new Future.value(false); |
| 144 | 149 |
| 145 Future<List<Uri>> readDepsFile(String path) { | 150 Future<List<Uri>> readDepsFile(String path) { |
| 146 var file = new io.File(new io.Path(path).toNativePath()); | 151 var file = new io.File(new io.Path(path).toNativePath()); |
| 147 if (!file.existsSync()) { | 152 if (!file.existsSync()) { |
| 148 return new Future.value(null); | 153 return new Future.value(null); |
| 149 } | 154 } |
| 150 return file.readAsLines().then((List<String> lines) { | 155 return file.readAsLines().then((List<String> lines) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 * This is used for example for pixel tests, where [expectedOutputPath] points | 193 * This is used for example for pixel tests, where [expectedOutputPath] points |
| 189 * to a *png file. | 194 * to a *png file. |
| 190 */ | 195 */ |
| 191 io.Path expectedOutputPath; | 196 io.Path expectedOutputPath; |
| 192 | 197 |
| 193 ContentShellCommand(String executable, | 198 ContentShellCommand(String executable, |
| 194 String htmlFile, | 199 String htmlFile, |
| 195 List<String> options, | 200 List<String> options, |
| 196 List<String> dartFlags, | 201 List<String> dartFlags, |
| 197 io.Path this.expectedOutputPath) | 202 io.Path this.expectedOutputPath) |
| 198 : super(executable, | 203 : super("content_shell", |
| 204 executable, |
| 199 _getArguments(options, htmlFile), | 205 _getArguments(options, htmlFile), |
| 200 _getEnvironment(dartFlags)); | 206 _getEnvironment(dartFlags)); |
| 201 | 207 |
| 202 static Map _getEnvironment(List<String> dartFlags) { | 208 static Map _getEnvironment(List<String> dartFlags) { |
| 203 var needDartFlags = dartFlags != null && dartFlags.length > 0; | 209 var needDartFlags = dartFlags != null && dartFlags.length > 0; |
| 204 | 210 |
| 205 var env = null; | 211 var env = null; |
| 206 if (needDartFlags) { | 212 if (needDartFlags) { |
| 207 env = new Map.from(io.Platform.environment); | 213 env = new Map.from(io.Platform.environment); |
| 208 if (needDartFlags) { | 214 if (needDartFlags) { |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 incomplete, | 456 incomplete, |
| 451 timedOut, | 457 timedOut, |
| 452 stdout, | 458 stdout, |
| 453 stderr, | 459 stderr, |
| 454 time, | 460 time, |
| 455 compilationSkipped); | 461 compilationSkipped); |
| 456 } | 462 } |
| 457 | 463 |
| 458 Command get command; | 464 Command get command; |
| 459 | 465 |
| 466 TestCase testCase; |
| 467 |
| 460 bool get incomplete; | 468 bool get incomplete; |
| 461 | 469 |
| 462 String get result; | 470 String get result; |
| 463 | 471 |
| 464 bool get unexpectedOutput; | 472 bool get unexpectedOutput; |
| 465 | 473 |
| 466 bool get hasCrashed; | 474 bool get hasCrashed; |
| 467 | 475 |
| 468 bool get hasTimedOut; | 476 bool get hasTimedOut; |
| 469 | 477 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 } | 622 } |
| 615 | 623 |
| 616 // Reverse result of a negative test. | 624 // Reverse result of a negative test. |
| 617 bool get hasFailed { | 625 bool get hasFailed { |
| 618 // Always fail if a runtime-error is expected and compilation failed. | 626 // Always fail if a runtime-error is expected and compilation failed. |
| 619 if (testCase.info != null && testCase.info.hasRuntimeError && incomplete) { | 627 if (testCase.info != null && testCase.info.hasRuntimeError && incomplete) { |
| 620 return true; | 628 return true; |
| 621 } | 629 } |
| 622 return testCase.isNegative ? !didFail : didFail; | 630 return testCase.isNegative ? !didFail : didFail; |
| 623 } | 631 } |
| 624 | |
| 625 } | 632 } |
| 626 | 633 |
| 627 class BrowserCommandOutputImpl extends CommandOutputImpl { | 634 class BrowserCommandOutputImpl extends CommandOutputImpl { |
| 628 BrowserCommandOutputImpl( | 635 BrowserCommandOutputImpl( |
| 629 testCase, | 636 testCase, |
| 630 command, | 637 command, |
| 631 exitCode, | 638 exitCode, |
| 632 incomplete, | 639 incomplete, |
| 633 timedOut, | 640 timedOut, |
| 634 stdout, | 641 stdout, |
| (...skipping 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1920 } | 1927 } |
| 1921 } | 1928 } |
| 1922 | 1929 |
| 1923 void eventAllTestsDone() { | 1930 void eventAllTestsDone() { |
| 1924 for (var listener in _eventListener) { | 1931 for (var listener in _eventListener) { |
| 1925 listener.allDone(); | 1932 listener.allDone(); |
| 1926 } | 1933 } |
| 1927 } | 1934 } |
| 1928 } | 1935 } |
| 1929 | 1936 |
| OLD | NEW |