| 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 | 182 |
| 183 String get result(); | 183 String get result(); |
| 184 | 184 |
| 185 bool get unexpectedOutput(); | 185 bool get unexpectedOutput(); |
| 186 | 186 |
| 187 bool get hasCrashed(); | 187 bool get hasCrashed(); |
| 188 | 188 |
| 189 bool get hasTimedOut(); | 189 bool get hasTimedOut(); |
| 190 | 190 |
| 191 bool get didFail(); | 191 bool get didFail(); |
| 192 | 192 |
| 193 bool requestRetry; | 193 bool requestRetry; |
| 194 | 194 |
| 195 Duration get time(); | 195 Duration get time(); |
| 196 | 196 |
| 197 int get exitCode(); | 197 int get exitCode(); |
| 198 | 198 |
| 199 List<String> get stdout(); | 199 List<String> get stdout(); |
| 200 | 200 |
| 201 List<String> get stderr(); | 201 List<String> get stderr(); |
| 202 | 202 |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 void runCommand(Command command, | 593 void runCommand(Command command, |
| 594 void exitHandler(int exitCode)) { | 594 void exitHandler(int exitCode)) { |
| 595 if (Platform.operatingSystem() == 'windows') { | 595 if (Platform.operatingSystem() == 'windows') { |
| 596 // Windows can't handle the first command if it is a .bat file or the like | 596 // Windows can't handle the first command if it is a .bat file or the like |
| 597 // with the slashes going the other direction. | 597 // with the slashes going the other direction. |
| 598 // TODO(efortuna): Remove this when fixed (Issue 1306). | 598 // TODO(efortuna): Remove this when fixed (Issue 1306). |
| 599 command.executable = command.executable.replaceAll('/', '\\'); | 599 command.executable = command.executable.replaceAll('/', '\\'); |
| 600 } | 600 } |
| 601 process = new Process.start(command.executable, command.arguments); | 601 process = new Process.start(command.executable, command.arguments); |
| 602 process.onExit = exitHandler; | 602 process.onExit = exitHandler; |
| 603 process.onError = (e) { |
| 604 print("Error starting process:"); |
| 605 print(" Command: $command"); |
| 606 print(" Error: $e"); |
| 607 }; |
| 603 startTime = new Date.now(); | 608 startTime = new Date.now(); |
| 604 InputStream stdoutStream = process.stdout; | 609 InputStream stdoutStream = process.stdout; |
| 605 InputStream stderrStream = process.stderr; | 610 InputStream stderrStream = process.stderr; |
| 606 StringInputStream stdoutStringStream = new StringInputStream(stdoutStream); | 611 StringInputStream stdoutStringStream = new StringInputStream(stdoutStream); |
| 607 StringInputStream stderrStringStream = new StringInputStream(stderrStream); | 612 StringInputStream stderrStringStream = new StringInputStream(stderrStream); |
| 608 stdoutStringStream.onLine = | 613 stdoutStringStream.onLine = |
| 609 makeReadHandler(stdoutStringStream, stdout); | 614 makeReadHandler(stdoutStringStream, stdout); |
| 610 stderrStringStream.onLine = | 615 stderrStringStream.onLine = |
| 611 makeReadHandler(stderrStringStream, stderr); | 616 makeReadHandler(stderrStringStream, stderr); |
| 612 if (timeoutTimer == null) { | 617 if (timeoutTimer == null) { |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 _process = new Process.start(_executable, _batchArguments); | 805 _process = new Process.start(_executable, _batchArguments); |
| 801 _stdoutStream = new StringInputStream(_process.stdout); | 806 _stdoutStream = new StringInputStream(_process.stdout); |
| 802 _stderrStream = new StringInputStream(_process.stderr); | 807 _stderrStream = new StringInputStream(_process.stderr); |
| 803 _testStdout = new List<String>(); | 808 _testStdout = new List<String>(); |
| 804 _testStderr = new List<String>(); | 809 _testStderr = new List<String>(); |
| 805 _stdoutDrained = false; | 810 _stdoutDrained = false; |
| 806 _stderrDrained = false; | 811 _stderrDrained = false; |
| 807 _stdoutStream.onLine = _readStdout(_stdoutStream, _testStdout); | 812 _stdoutStream.onLine = _readStdout(_stdoutStream, _testStdout); |
| 808 _stderrStream.onLine = _readStderr(_stderrStream, _testStderr); | 813 _stderrStream.onLine = _readStderr(_stderrStream, _testStderr); |
| 809 _process.onExit = _exitHandler; | 814 _process.onExit = _exitHandler; |
| 815 _process.onError = (e) { |
| 816 print("Error starting process:"); |
| 817 print(" Command: $_executable ${Strings.join(_batchArguments, ' ')}"); |
| 818 print(" Error: $e"); |
| 819 }; |
| 810 _process.onStart = then; | 820 _process.onStart = then; |
| 811 } | 821 } |
| 812 } | 822 } |
| 813 | 823 |
| 814 /** | 824 /** |
| 815 * ProcessQueue is the master control class, responsible for running all | 825 * ProcessQueue is the master control class, responsible for running all |
| 816 * the tests in all the TestSuites that have been registered. It includes | 826 * the tests in all the TestSuites that have been registered. It includes |
| 817 * a rate-limited queue to run a limited number of tests in parallel, | 827 * a rate-limited queue to run a limited number of tests in parallel, |
| 818 * a ProgressIndicator which prints output when tests are started and | 828 * a ProgressIndicator which prints output when tests are started and |
| 819 * and completed, and a summary report when all tests are completed, | 829 * and completed, and a summary report when all tests are completed, |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 979 // Check to see if the jar was already running before the program started. | 989 // Check to see if the jar was already running before the program started. |
| 980 String cmd = 'ps'; | 990 String cmd = 'ps'; |
| 981 var arg = ['aux']; | 991 var arg = ['aux']; |
| 982 if (Platform.operatingSystem() == 'windows') { | 992 if (Platform.operatingSystem() == 'windows') { |
| 983 cmd = 'tasklist'; | 993 cmd = 'tasklist'; |
| 984 arg.add('/v'); | 994 arg.add('/v'); |
| 985 } | 995 } |
| 986 Process p = new Process.start(cmd, arg); | 996 Process p = new Process.start(cmd, arg); |
| 987 final StringInputStream stdoutStringStream = | 997 final StringInputStream stdoutStringStream = |
| 988 new StringInputStream(p.stdout); | 998 new StringInputStream(p.stdout); |
| 999 p.onError = (e) { |
| 1000 print("Error starting process:"); |
| 1001 print(" Command: $cmd ${Strings.join(arg, ' ')}"); |
| 1002 print(" Error: $e"); |
| 1003 }; |
| 989 stdoutStringStream.onLine = () { | 1004 stdoutStringStream.onLine = () { |
| 990 var line = stdoutStringStream.readLine(); | 1005 var line = stdoutStringStream.readLine(); |
| 991 while (null != line) { | 1006 while (null != line) { |
| 992 if (const RegExp(@".*selenium-server-standalone.*").hasMatch(line)) { | 1007 if (const RegExp(@".*selenium-server-standalone.*").hasMatch(line)) { |
| 993 _seleniumAlreadyRunning = true; | 1008 _seleniumAlreadyRunning = true; |
| 994 resumeTesting(); | 1009 resumeTesting(); |
| 995 } | 1010 } |
| 996 line = stdoutStringStream.readLine(); | 1011 line = stdoutStringStream.readLine(); |
| 997 } | 1012 } |
| 998 if (!_isSeleniumAvailable) { | 1013 if (!_isSeleniumAvailable) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 // Get the absolute path to the Selenium jar. | 1055 // Get the absolute path to the Selenium jar. |
| 1041 String filePath = new Options().script; | 1056 String filePath = new Options().script; |
| 1042 String pathSep = Platform.pathSeparator(); | 1057 String pathSep = Platform.pathSeparator(); |
| 1043 int index = filePath.lastIndexOf(pathSep); | 1058 int index = filePath.lastIndexOf(pathSep); |
| 1044 filePath = filePath.substring(0, index) + '${pathSep}testing${pathSep}'; | 1059 filePath = filePath.substring(0, index) + '${pathSep}testing${pathSep}'; |
| 1045 var dir = new Directory(filePath); | 1060 var dir = new Directory(filePath); |
| 1046 dir.onFile = (String file) { | 1061 dir.onFile = (String file) { |
| 1047 if (const RegExp(@"selenium-server-standalone-.*\.jar").hasMatch(file) | 1062 if (const RegExp(@"selenium-server-standalone-.*\.jar").hasMatch(file) |
| 1048 && _seleniumServer == null) { | 1063 && _seleniumServer == null) { |
| 1049 _seleniumServer = new Process.start('java', ['-jar', file]); | 1064 _seleniumServer = new Process.start('java', ['-jar', file]); |
| 1065 _seleniumServer.onError = (e) { |
| 1066 print("Error starting process:"); |
| 1067 print(" Command: java -jar $file"); |
| 1068 print(" Error: $e"); |
| 1069 }; |
| 1050 // Heads up: there seems to an obscure data race of some form in | 1070 // Heads up: there seems to an obscure data race of some form in |
| 1051 // the VM between launching the server process and launching the test | 1071 // the VM between launching the server process and launching the test |
| 1052 // tasks that disappears when you read IO (which is convenient, since | 1072 // tasks that disappears when you read IO (which is convenient, since |
| 1053 // that is our condition for knowing that the server is ready). | 1073 // that is our condition for knowing that the server is ready). |
| 1054 StringInputStream stdoutStringStream = | 1074 StringInputStream stdoutStringStream = |
| 1055 new StringInputStream(_seleniumServer.stdout); | 1075 new StringInputStream(_seleniumServer.stdout); |
| 1056 StringInputStream stderrStringStream = | 1076 StringInputStream stderrStringStream = |
| 1057 new StringInputStream(_seleniumServer.stderr); | 1077 new StringInputStream(_seleniumServer.stderr); |
| 1058 stdoutStringStream.onLine = | 1078 stdoutStringStream.onLine = |
| 1059 makeSeleniumServerHandler(stdoutStringStream); | 1079 makeSeleniumServerHandler(stdoutStringStream); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1136 // the developer doesn't waste his or her time trying to fix a bunch of | 1156 // the developer doesn't waste his or her time trying to fix a bunch of |
| 1137 // tests that appear to be broken but were actually just flakes that | 1157 // tests that appear to be broken but were actually just flakes that |
| 1138 // didn't get retried because there had already been one failure. | 1158 // didn't get retried because there had already been one failure. |
| 1139 bool allowRetry = _MAX_FAILED_NO_RETRY > _progress.numFailedTests; | 1159 bool allowRetry = _MAX_FAILED_NO_RETRY > _progress.numFailedTests; |
| 1140 new RunningProcess(test, allowRetry, this).start(); | 1160 new RunningProcess(test, allowRetry, this).start(); |
| 1141 } | 1161 } |
| 1142 _numProcesses++; | 1162 _numProcesses++; |
| 1143 } | 1163 } |
| 1144 } | 1164 } |
| 1145 } | 1165 } |
| OLD | NEW |