Skip to content

Fix runner for JsTestDriver based tests on OS X #5045

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 2, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 24 additions & 16 deletions dev/tests/js/JsTestDriver/run_js_tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
} else {
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$browser = 'C:\Program Files (x86)\Mozilla Firefox\firefox.exe';
} elseif (PHP_OS === 'Darwin') {
$browser = '/Applications/Firefox.app/Contents/MacOS/firefox';
} else {
$browser = exec('which firefox');
}
Expand Down Expand Up @@ -139,29 +141,35 @@
kill -9 $LSOF
fi

DISPLAY_NUM=99
ps -ef | egrep "[X]vfb.*:$DISPLAY_NUM"
if [ $? -eq 0 ] ; then
pkill Xvfb
# Skip Xvfb setup for OS X since there browsers do not support headless display that way
if [ "$(uname)" != "Darwin" ]; then
DISPLAY_NUM=99
ps -ef | egrep "[X]vfb.*:$DISPLAY_NUM"
if [ $? -eq 0 ] ; then
pkill Xvfb
fi

XVFB=`which Xvfb`
if [ "$?" -eq 1 ];
then
echo "Xvfb not found."
exit 1
fi

$XVFB :$DISPLAY_NUM -nolisten inet6 -ac &
PID_XVFB="$!" # take the process ID
export DISPLAY=:$DISPLAY_NUM # set display to use that of the Xvfb
fi

XVFB=`which Xvfb`
if [ "$?" -eq 1 ];
then
echo "Xvfb not found."
exit 1
fi

$XVFB :$DISPLAY_NUM -nolisten inet6 -ac &
PID_XVFB="$!" # take the process ID
export DISPLAY=:$DISPLAY_NUM # set display to use that of the Xvfb

USER=`whoami`
SUDO=`which sudo`

# run the tests
$SUDO -u $USER ' . $command . '

kill -9 $PID_XVFB # shut down Xvfb (firefox will shut down cleanly by JsTestDriver)
if [ "$(uname)" != "Darwin" ]; then
kill -9 $PID_XVFB # shut down Xvfb (firefox will shut down cleanly by JsTestDriver)
fi
echo "Done."';

fwrite($fh, $shellCommand . PHP_EOL);
Expand Down