| 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 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1146 | 1146 |
| 1147 Future processFuture = Process.start(cmd, arg); | 1147 Future processFuture = Process.start(cmd, arg); |
| 1148 processFuture.then((Process p) { | 1148 processFuture.then((Process p) { |
| 1149 // Drain stderr to not leak resources. | 1149 // Drain stderr to not leak resources. |
| 1150 p.stderr.onData = p.stderr.read; | 1150 p.stderr.onData = p.stderr.read; |
| 1151 final StringInputStream stdoutStringStream = | 1151 final StringInputStream stdoutStringStream = |
| 1152 new StringInputStream(p.stdout); | 1152 new StringInputStream(p.stdout); |
| 1153 stdoutStringStream.onLine = () { | 1153 stdoutStringStream.onLine = () { |
| 1154 var line = stdoutStringStream.readLine(); | 1154 var line = stdoutStringStream.readLine(); |
| 1155 while (null != line) { | 1155 while (null != line) { |
| 1156 var regexp = new RegExp(r".*selenium-server-standalone.*"); | 1156 var regexp = const RegExp(r".*selenium-server-standalone.*"); |
| 1157 if (regexp.hasMatch(line)) { | 1157 if (regexp.hasMatch(line)) { |
| 1158 _seleniumAlreadyRunning = true; | 1158 _seleniumAlreadyRunning = true; |
| 1159 resumeTesting(); | 1159 resumeTesting(); |
| 1160 } | 1160 } |
| 1161 line = stdoutStringStream.readLine(); | 1161 line = stdoutStringStream.readLine(); |
| 1162 } | 1162 } |
| 1163 if (!_isSeleniumAvailable) { | 1163 if (!_isSeleniumAvailable) { |
| 1164 _startSeleniumServer(); | 1164 _startSeleniumServer(); |
| 1165 } | 1165 } |
| 1166 }; | 1166 }; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1189 /** | 1189 /** |
| 1190 * Monitor the output of the Selenium server, to know when we are ready to | 1190 * Monitor the output of the Selenium server, to know when we are ready to |
| 1191 * begin running tests. | 1191 * begin running tests. |
| 1192 * source: Output(Stream) from the Java server. | 1192 * source: Output(Stream) from the Java server. |
| 1193 */ | 1193 */ |
| 1194 VoidFunction makeSeleniumServerHandler(StringInputStream source) { | 1194 VoidFunction makeSeleniumServerHandler(StringInputStream source) { |
| 1195 void handler() { | 1195 void handler() { |
| 1196 if (source.closed) return; // TODO(whesse): Remove when bug is fixed. | 1196 if (source.closed) return; // TODO(whesse): Remove when bug is fixed. |
| 1197 var line = source.readLine(); | 1197 var line = source.readLine(); |
| 1198 while (null != line) { | 1198 while (null != line) { |
| 1199 if (new RegExp(r".*Started.*Server.*").hasMatch(line) || | 1199 if (const RegExp(r".*Started.*Server.*").hasMatch(line) || |
| 1200 new RegExp(r"Exception.*Selenium is already running.*").hasMatch( | 1200 const RegExp(r"Exception.*Selenium is already running.*").hasMatch( |
| 1201 line)) { | 1201 line)) { |
| 1202 resumeTesting(); | 1202 resumeTesting(); |
| 1203 } | 1203 } |
| 1204 line = source.readLine(); | 1204 line = source.readLine(); |
| 1205 } | 1205 } |
| 1206 } | 1206 } |
| 1207 return handler; | 1207 return handler; |
| 1208 } | 1208 } |
| 1209 | 1209 |
| 1210 /** | 1210 /** |
| 1211 * For browser tests using Safari or Opera, we need to use the Selenium 1.0 | 1211 * For browser tests using Safari or Opera, we need to use the Selenium 1.0 |
| 1212 * Java server. | 1212 * Java server. |
| 1213 */ | 1213 */ |
| 1214 void _startSeleniumServer() { | 1214 void _startSeleniumServer() { |
| 1215 // Get the absolute path to the Selenium jar. | 1215 // Get the absolute path to the Selenium jar. |
| 1216 String filePath = TestUtils.testScriptPath; | 1216 String filePath = TestUtils.testScriptPath; |
| 1217 String pathSep = Platform.pathSeparator; | 1217 String pathSep = Platform.pathSeparator; |
| 1218 int index = filePath.lastIndexOf(pathSep); | 1218 int index = filePath.lastIndexOf(pathSep); |
| 1219 filePath = '${filePath.substring(0, index)}${pathSep}testing${pathSep}'; | 1219 filePath = '${filePath.substring(0, index)}${pathSep}testing${pathSep}'; |
| 1220 var lister = new Directory(filePath).list(); | 1220 var lister = new Directory(filePath).list(); |
| 1221 lister.onFile = (String file) { | 1221 lister.onFile = (String file) { |
| 1222 if (new RegExp(r"selenium-server-standalone-.*\.jar").hasMatch(file) | 1222 if (const RegExp(r"selenium-server-standalone-.*\.jar").hasMatch(file) |
| 1223 && _seleniumServer == null) { | 1223 && _seleniumServer == null) { |
| 1224 Future processFuture = Process.start('java', ['-jar', file]); | 1224 Future processFuture = Process.start('java', ['-jar', file]); |
| 1225 processFuture.then((Process server) { | 1225 processFuture.then((Process server) { |
| 1226 _seleniumServer = server; | 1226 _seleniumServer = server; |
| 1227 // Heads up: there seems to an obscure data race of some form in | 1227 // Heads up: there seems to an obscure data race of some form in |
| 1228 // the VM between launching the server process and launching the test | 1228 // the VM between launching the server process and launching the test |
| 1229 // tasks that disappears when you read IO (which is convenient, since | 1229 // tasks that disappears when you read IO (which is convenient, since |
| 1230 // that is our condition for knowing that the server is ready). | 1230 // that is our condition for knowing that the server is ready). |
| 1231 StringInputStream stdoutStringStream = | 1231 StringInputStream stdoutStringStream = |
| 1232 new StringInputStream(_seleniumServer.stdout); | 1232 new StringInputStream(_seleniumServer.stdout); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1330 // the developer doesn't waste his or her time trying to fix a bunch of | 1330 // the developer doesn't waste his or her time trying to fix a bunch of |
| 1331 // tests that appear to be broken but were actually just flakes that | 1331 // tests that appear to be broken but were actually just flakes that |
| 1332 // didn't get retried because there had already been one failure. | 1332 // didn't get retried because there had already been one failure. |
| 1333 bool allowRetry = _MAX_FAILED_NO_RETRY > _progress.numFailedTests; | 1333 bool allowRetry = _MAX_FAILED_NO_RETRY > _progress.numFailedTests; |
| 1334 new RunningProcess(test, allowRetry, this).start(); | 1334 new RunningProcess(test, allowRetry, this).start(); |
| 1335 } | 1335 } |
| 1336 _numProcesses++; | 1336 _numProcesses++; |
| 1337 } | 1337 } |
| 1338 } | 1338 } |
| 1339 } | 1339 } |
| OLD | NEW |