Make sure TestSitePath exist before creating .htkey

Created on 21 April 2014, over 10 years ago
Updated 2 October 2023, 12 months ago

After building a custom install profile (example), I attempted to create a test for the profile, similar to StandardTest.

The test failed due to Drupal's inability to write the file to the desired folder in drupal_generate_test_ua() (sample output below). I've been unable to determine why this predictably happens with my install profile, but not with the Minimal profile (for example).

There is nothing that leads me to believe this has to do with environmental factors, but colleagues have had trouble reproducing, so I'm providing as much detail as possible here.

Environment details

  • OSX 10.9.2
  • Clean install of latest Acquia DevDesktop 2 Beta (2014-04-10).
  • Drush 7.x

Steps to reproduce

1. Clone Drupal 8.x: git clone --branch 8.x http://git.drupal.org/project/drupal.git

2. Clone the test profile: In the /profiles folder, git clone --branch spelunky-profile git@github.com:jrbeeman/spelunky.git

3. Setup this code base as a site in DevDesktop: See Getting started and some Drupal 8-related notes.

4. Install the site, enable Testing, and run the simple install profile test:

drush si -v spelunky;
drush en simpletest;
drush test-run -v "Drupal\spelunky\Tests\SpelunkyTest";

You should be presented with a list of errors, all resulting from this first one:

Test drupal_generate_test_ua() failed: file_put_contents(/Users/jbeeman/Sites/spelunky/sites/simpletest/271652/.htkey): failed to open stream: Permission     [error]
denied<pre class="backtrace">file_put_contents('/Users/jbeeman/Sites/spelunky/sites/simpletest/271652/.htkey',
'd3otdkJNnBNi3wRj9FKKdEk1lPFEym6jyWs2_SCM4hMsOrWmpxe-IKjDlRAO8uzXVYgzavWORQ')
drupal_generate_test_ua('simpletest271652')
📌 Task
Status

Needs work

Version

11.0 🔥

Component
PHPUnit 

Last updated 22 minutes ago

Created by

🇺🇸United States jrbeeman Arizona, USA

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States smustgrave

    This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.

    MR should be updated for 10.1

    Also IS should be updated as it references acquia dev desktop which support stopped in June 2021.

  • 🇺🇸United States dpagini

    I've actually recently run into this issue, and I have some more details that affected me here I wanted to share...

    The fix here still solves my problem, and I can explain why as well.

    So I ran into this issue with the following scenario...
    * I am installing a site that uses a custom cron job to make a call out to an RSS feed, download the file, and store it locally for processing by the feeds module.
    * Drupal core runs through the INSTALL steps... but the install_configure_form step actually hardens the simpletest site directory, and sets the folder to 555 (not writeable).
    * Drupal core at the end of the installation then triggers a cron. My job calls out to the internet. Drupal core has a custom testing middleware that intercepts that calls, and tries to add testing headers to the call, and ultimately calls drupal_generate_test_ua(), which tries to write the .htkey file to a hardened sites directory, and that fails... so my first cron run fails silently.

    I actually came across this b/c by enabling the "locale" module, the call to drupal_generate_test_ua() was made earlier in the stack, before the hardening, and the .htkey file gets placed successfully, and there is no more failure.

Production build 0.71.5 2024