Skip to content

Commit

Permalink
Prompting for re-generation of behat local.yml.
Browse files Browse the repository at this point in the history
  • Loading branch information
grasmash committed Oct 17, 2016
1 parent c999e9c commit 9079b5a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 28 deletions.
27 changes: 0 additions & 27 deletions phing/tasks/setup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,6 @@
</filterchain>
</copy>

<property file="${repo.root}/tests/behat/local.yml" prefix="behatConfig"/>
<if>
<or>
<not><available file="${behatConfig.local.extensions.Drupal\DrupalExtension.drupal.drupal_root}"/></not>
<not><available file="${behatConfig.local.suites.default.paths.features}"/></not>
<not><available file="${behatConfig.local.suites.default.paths.bootstrap}"/></not>
</or>
<then>
<!--@todo Prompt to re-generate local.yml.-->
<echo></echo>
<echo level="error">One or more values in tests/behat/local.yml reference file paths that do not exist on this system.</echo>
<echo level="error">This is typically related to using a virtual machine.</echo>
<echo level="error"></echo>
<echo level="error">Try one of the following solution:</echo>
<echo level="error">1) Execute the tests on the correct system.</echo>
<echo level="error">2) Correct the value(s).</echo>
<echo level="error">3) Remove tests/behat/local.yml so that it can be regenerated automatically from example.local.yml.</echo>
<echo level="error"></echo>
<echo level="error">Values are:</echo>
<echo level="error">drupal_root: ${behatConfig.local.extensions.Drupal\DrupalExtension.drupal.drupal_root}"</echo>
<echo level="error">features: ${behatConfig.local.suites.default.paths.features}"</echo>
<echo level="error">bootstrap: ${behatConfig.local.suites.default.paths.bootstrap}</echo>
<echo level="error"></echo>
<fail>Your Behat configuration is invalid.</fail>
</then>
</if>

</target>

<!-- This is run when a project is cloned to a new environment. -->
Expand Down
41 changes: 40 additions & 1 deletion phing/tasks/tests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,51 @@

<!-- 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="setup:behat, 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" 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"/>
</target>

<target name="test:behat:check" description="Checks Behat configuration" hidden="true" depends="setup:behat">
<property file="${repo.root}/tests/behat/local.yml" prefix="behatConfig"/>
<if>
<or>
<not><available file="${behatConfig.local.extensions.Drupal\DrupalExtension.drupal.drupal_root}"/></not>
<not><available file="${behatConfig.local.suites.default.paths.features}"/></not>
<not><available file="${behatConfig.local.suites.default.paths.bootstrap}"/></not>
</or>
<then>
<echo></echo>
<echo level="warning">One or more values in tests/behat/local.yml reference file paths that do not exist on this system.</echo>
<echo level="warning">This is typically related to using a virtual machine.</echo>
<echo level="warning"></echo>
<echo level="warning">Try one of the following solution:</echo>
<echo level="warning">1) Execute the tests on the correct system.</echo>
<echo level="warning">2) Correct the value(s).</echo>
<echo level="warning">3) Remove tests/behat/local.yml so that it can be regenerated automatically from example.local.yml.</echo>
<echo level="warning"></echo>
<echo level="warning">Values are:</echo>
<echo level="warning">drupal_root: ${behatConfig.local.extensions.Drupal\DrupalExtension.drupal.drupal_root}"</echo>
<echo level="warning">features: ${behatConfig.local.suites.default.paths.features}"</echo>
<echo level="warning">bootstrap: ${behatConfig.local.suites.default.paths.bootstrap}</echo>
<echo level="warning"></echo>

<propertyprompt promptText="Do you want to re-generate Behat configuration? [y/n]" propertyName="behat.regenerate" defaultValue="y"/>
<if>
<equals arg1="${behat.regenerate}" arg2="y" casesensitive="false"/>
<then>
<delete file="${repo.root}/tests/behat/local.yml"/>
<phingcall target="setup:behat"/>
</then>
<else>
<fail>Cannot execute behat tests because Behat configuration is invalid.</fail>
</else>
</if>
</then>
</if>
</target>

<target name="tests:behat:execute" description="Executes behat tests against specific path." hidden="true">
<!-- Check to see if any behat tests exist in this directory. If not,
behat will throw fatal error. -->
Expand Down

0 comments on commit 9079b5a

Please sign in to comment.