Skip to content

Commit

Permalink
Fixes acquia#787: Re-introduce PhantomJS along side Selenium.
Browse files Browse the repository at this point in the history
  • Loading branch information
grasmash committed Dec 21, 2016
1 parent f6f94dc commit b733d8b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
2 changes: 2 additions & 0 deletions phing/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ behat:
server-url: http://127.0.0.1:8888
# If true, Selenium standalone server will be launched with Behat.
launch-selenium: true
# If true, PhantomJS GhostDriver will be launched with Behat.
launch-phantom: true
# An array of paths with behat tests that should be executed.
paths:
# - ${docroot}/modules
Expand Down
30 changes: 29 additions & 1 deletion phing/tasks/tests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

<!-- If you experience 'Maximum function nesting level' errors in your PHP
error log, set 'xdebug.max_nesting_level=1000' in php.ini. -->
<target name="tests:behat" depends="test:behat:check, tests:run-server, tests:selenium:launch" description="Executes Behat all behat tests in behat.paths.">
<target name="tests:behat" depends="test:behat:check, tests:run-server, tests:selenium:launch, tests:phantomjs:launch" description="Executes Behat all behat tests in behat.paths.">
<mkdir dir="${reports.localDir}/behat"/>
<foreach list="${behat.paths}" target="tests:behat:execute" param="behat.path"/>
<phingcall target="tests:selenium:kill"/>
<phingcall target="tests:phantomjs:kill"/>
</target>

<target name="test:behat:check" description="Checks Behat configuration" hidden="true" depends="setup:behat">
Expand Down Expand Up @@ -89,6 +90,7 @@
<not><equals arg1="${behatPass}" arg2="0"/></not>
<then>
<phingcall target="tests:selenium:kill"/>
<phingcall target="tests:phantomjs:kill"/>
<fail message="One or more Behat tests failed." />
</then>
<else>
Expand Down Expand Up @@ -148,6 +150,32 @@
<exec command="pgrep selenium | xargs kill" logoutput="false" level="${blt.exec_level}" passthru="false" checkreturn="false" />
</target>

<target name="tests:phantomjs:launch"
description="Launches a GhostDriver."
hidden="true">

<if>
<equals arg1="${behat.launch-phantom}" arg2="true"/>
<then>
<echo message="Launching PhantomJS GhostDriver." />
<exec command="${composer.bin}/phantomjs --webdriver=4444"
passthru="true"
spawn="true"
checkreturn="true"
level="${blt.exec_level}"/>
<echo message="Waiting 10 seconds for PhantomJS (http://127.0.0.1:4444) to become available."/>
<waitfor maxwait="10" maxwaitunit="second" checkevery="1" checkeveryunit="second">
<http url="http://127.0.0.1:4444"/>
</waitfor>
</then>
</if>
</target>

<target name="tests:phantomjs:kill"
description="Launches a GhostDriver." hidden="true">
<exec command="pgrep phantomjs | xargs kill" logoutput="true" level="${blt.exec_level}" passthru="true" />
</target>

<!-- Execute PHPUnit tests. -->
<target name="tests:phpunit" description="Executes PHPUnit tests against custom code.">
<delete dir="${reports.localDir}/phpunit" quiet="true"/>
Expand Down
9 changes: 8 additions & 1 deletion template/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"drupal/drupal-extension": "^3.2",
"drupal-composer/drupal-scaffold": "^2.1.0",
"jarnaiz/behat-junit-formatter": "^1.3.2",
"se/selenium-server-standalone": "^2.53"
"se/selenium-server-standalone": "^2.53",
"jakoch/phantomjs-installer": "^2.1.1-p07"
},
"autoload-dev": {
"psr-4": {
Expand Down Expand Up @@ -80,6 +81,12 @@
"rm -rf vendor composer.lock",
"@composer clearcache",
"@composer install"
],
"post-install-cmd": [
"PhantomInstaller\\Installer::installPhantomJS"
],
"post-update-cmd": [
"PhantomInstaller\\Installer::installPhantomJS"
]
},
"minimum-stability": "dev",
Expand Down

0 comments on commit b733d8b

Please sign in to comment.