Index: tools/testing/dart/test_runner.dart |
=================================================================== |
--- tools/testing/dart/test_runner.dart (revision 4729) |
+++ tools/testing/dart/test_runner.dart (working copy) |
@@ -332,7 +332,8 @@ |
} |
} |
- Function makeReadHandler(StringInputStream source, List<String> destination) { |
+ Function makeReadHandler(StringInputStream source, |
+ List<String> destination) { |
return () { |
if (source.closed) return; // TODO(whesse): Remove when bug is fixed. |
var line = source.readLine(); |
@@ -576,6 +577,13 @@ |
* used. |
*/ |
String browserUsed; |
+ /** |
+ * Process running the selenium server .jar (only used for Safari and Opera |
+ * tests.) |
+ */ |
+ Process seleniumServer; |
+ /** True if we are in the process of starting the server. */ |
+ bool startingServer; |
ProcessQueue(int this._maxProcesses, |
String progress, |
@@ -593,6 +601,8 @@ |
_testCache = new Map<String, List<TestInformation>>() { |
if (!_enqueueMoreWork(this)) _progress.allDone(); |
browserUsed = ''; |
+ seleniumServer = null; |
+ startingServer = false; |
Siggi Cherem (dart-lang)
2012/02/29 02:12:08
you should be able to initialize both inline in th
Emily Fortuna
2012/03/01 23:55:13
Done.
|
} |
/** |
@@ -668,6 +678,9 @@ |
void _cleanupAndMarkDone() { |
if (browserUsed != '') { |
killZombieBrowsers(); |
+ if (seleniumServer != null) { |
+ seleniumServer.kill(); |
+ } |
} else { |
_progress.allDone(); |
} |
@@ -710,12 +723,67 @@ |
void _runTest(TestCase test) { |
if (test.configuration['component'] == 'webdriver') { |
browserUsed = test.configuration['browser']; |
+ if (new Platform().operatingSystem() == 'macos' && browserUsed == 'safari' |
+ && seleniumServer == null && startingServer == false) { |
Siggi Cherem (dart-lang)
2012/02/29 02:12:08
style nit: I'd move these last two conditions into
Jennifer Messerly
2012/02/29 08:51:21
+1
Emily Fortuna
2012/03/01 23:55:13
Done.
|
+ startingServer = true; |
+ _startSeleniumServer(); |
+ } |
} |
_progress.testAdded(); |
_tests.add(test); |
_tryRunTest(); |
} |
+ /** |
+ * For browser tests using Safari or Opera, we need to use the Selenium 1.0 |
+ * Java server. |
+ */ |
+ void _startSeleniumServer() { |
+ // Get the absolute path to the Selenium jar. |
+ String filePath = new Options().script; |
+ String pathSep = new Platform().pathSeparator(); |
+ int index = filePath.lastIndexOf(pathSep); |
+ filePath = filePath.substring(0, index) + '${pathSep}testing${pathSep}'; |
+ String command = 'ls'; |
+ List<String> args = [filePath]; |
+ // Right now the Selenium server is only used on the mac, but it will be |
+ // used on Windows when we are testing Opera. |
+ if (new Platform().operatingSystem() == 'windows') { |
+ command = 'dir'; |
+ args.add('/B'); |
+ } |
+ Process process = new Process.start(command, args); |
+ StringInputStream stdoutStringStream = |
+ new StringInputStream(process.stdout); |
+ stdoutStringStream.lineHandler = () { |
+ String seleniumJar = stdoutStringStream.readLine(); |
+ // Loop through the files in the directory to find the jar. We can't do |
+ // this a more elegant way right now because |
+ // 'ls selenium-standalone-server*' doesn't work without a shell. |
+ // TODO(efortuna): Clean this up when the IO API provides more. |
Siggi Cherem (dart-lang)
2012/02/29 02:12:08
instead of reading the output of dir/ls to find th
|
+ while (seleniumJar != null) { |
+ if (seleniumJar.startsWith('selenium-server-standalone-') && |
+ seleniumJar.endsWith('.jar')) { |
+ var seleniumProcess = new Process.start('java', ['-jar', |
Siggi Cherem (dart-lang)
2012/02/29 02:12:08
does this process print anything when it's ready?
|
+ '${filePath}${seleniumJar}']); |
+ // The Selenium server takes a little while to start and be ready to |
+ // receive connections, so we wait before running our tests (~8 sec). |
+ new Timer((Timer t) { |
+ seleniumServer = seleniumProcess; |
+ for (int i = 0; i < _maxProcesses; i++) { |
+ // Attempt to run all the processes that have been waiting for |
+ // the server to start up. If we just call this once we end up |
+ // with a single-threaded run. |
+ _tryRunTest(); |
+ } |
+ }, 8000); |
+ return; |
+ } |
+ seleniumJar = stderrStringStream.readLine(); |
Siggi Cherem (dart-lang)
2012/02/29 02:12:08
should this be stdoutStringStream? (of course this
|
+ } |
+ }; |
+ } |
+ |
void _terminateBatchRunners() { |
for (var runners in _batchProcesses.getValues()) { |
for (var runner in runners) { |
@@ -746,6 +814,11 @@ |
_checkDone(); |
if (_numProcesses < _maxProcesses && !_tests.isEmpty()) { |
TestCase test = _tests.removeFirst(); |
+ if (test.configuration['component'] == 'webdriver' |
+ && seleniumServer == null) { |
Siggi Cherem (dart-lang)
2012/02/29 02:12:08
should this also check for safari & mac? maybe int
Jennifer Messerly
2012/02/29 08:51:21
also: we have a decent number of "test.configurati
Emily Fortuna
2012/03/01 23:55:13
Done.
Emily Fortuna
2012/03/01 23:55:13
Done.
|
+ _tests.addFirst(test); |
+ return; |
+ } |
if (_verbose) print(test.commands.last().commandLine); |
if (_listTests) { |
final String tab = '\t'; |