Behat Cache on Shared Host with Multiple Developers

Behat Cache on Shared Host with Multiple Developers

by Travis Noll -
Number of replies: 1

version 2016092300.00


As we integrate local customizations to our fork of the moodle/moodle/master branch, we're trying to test with the included version of behat.  We have a shared development server so when I went to run the tests I got an error like this:


  [Behat\Testwork\Call\Exception\CallErrorException]                                                                                                                            

  Warning: file_put_contents(/tmp/behat_gherkin_cache/412/d211f7e894af945272bcde0dc32523c0.feature.cache): failed to open stream: Permission denied in /home/tjn/prj/moodle/git/docs/vendor/behat/gherkin/src/Behat/Gherkin/Cache/FileCache.php line 88 



I found that /tmp/behat_gherkin_cache was created automatically, owned by another developer and not writable by me.

This seems configured by this snippit of code:

                    ->defaultValue(

                        is_writable(sys_get_temp_dir())

                            ? sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'behat_gherkin_cache'

                            : null

in vendor/behat/behat/src/Behat/Behat/Gherkin/ServiceContainer/GherkinExtension.php


I don't see another way to configure this directory to avoid collisions with multiple developers on the same host. -- Am I missing something?  Thanks, --Travis


Average of ratings: -
In reply to Travis Noll

Re: Behat Cache on Shared Host with Multiple Developers

by Rajesh Taneja -

Hello Travis,

You can set the following in your config.php to get this working

$CFG->behat_config = array(
'default' => array(
'testers' => array (
'rerun_cache' => '/PATH_TO_SAVE/my_rerun_cache',
),
'gherkin' => array (
'cache' => '/PATH_TO_SAVE/my_gherkin_cache',
),
),
);

I have added option for rerun_cache as well, as this is where failed tests are saved.