From 477ee2e3a152c9acac0ee2e5a106b294d54b6e74 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 20 Oct 2010 06:03:15 +0000 Subject: [PATCH] Tweaks to let Selenium tests run on Mac OS X; also make sure we quote the server exec path, as not everybody keeps their directory trees free of spaces! :) --- .../tests/selenium/SeleniumServerManager.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/maintenance/tests/selenium/SeleniumServerManager.php b/maintenance/tests/selenium/SeleniumServerManager.php index 5ef4c6649d..0596ea7845 100644 --- a/maintenance/tests/selenium/SeleniumServerManager.php +++ b/maintenance/tests/selenium/SeleniumServerManager.php @@ -82,7 +82,7 @@ class SeleniumServerManager { switch ( $this->OS ) { case "Linux": # case' CYGWIN_NT-5.1': -# case 'Darwin': + case 'Darwin': # case 'FreeBSD': # case 'HP-UX': # case 'IRIX64': @@ -113,7 +113,7 @@ class SeleniumServerManager { switch ( $this->OS ) { case "Linux": # case' CYGWIN_NT-5.1': -# case 'Darwin': + case 'Darwin': # case 'FreeBSD': # case 'HP-UX': # case 'IRIX64': @@ -140,8 +140,17 @@ class SeleniumServerManager { private function startServerOnUnix() { $output = array(); - $user = $_ENV['USER']; - exec("ps -U " . $user . " w | grep -i selenium-server", $output); + $user = $_ENV['USER']; + // @fixme this should be a little more generalized :) + if (PHP_OS == 'Darwin') { + // Mac OS X's ps barfs on the 'w' param, but doesn't need it. + $ps = "ps -U %s"; + } else { + // Good on Linux + $ps = "ps -U %s w"; + } + $psCommand = sprintf($ps, escapeshellarg($user)); + exec($psCommand . " | grep -i selenium-server", $output); // Start server. If there is already a server running, // return running. @@ -164,7 +173,7 @@ class SeleniumServerManager { $commandSuffix = ' > /dev/null 2>&1'. ' & echo $!'; $portText = ' -port ' . $this->SeleniumServerPort; $command = "java -jar " . - $this->SeleniumServerExecPath . + escapeshellarg($this->SeleniumServerExecPath) . $portText . $commandSuffix; exec($command ,$op); $pid = (int)$op[0]; -- 2.20.1