-- Drupal and Web Development

Notice: this post was last updated 3 years 51 weeks ago so it might be outdated. Please be cautious before implementing any of suggestions herein.

Running Drupal simpletests from the command line and the "Could not upload file" problem

I am using Simpletests for my site which check for file upload functionality. The problem is that uploading files requires sites/*/files to be owned by the web user (www in my case). When running simpletests, files are uploaded to a temporary directory sites/*/files/simpletest/*, which also needs to be owned by the web user (www).

When running your tests via the command line (in my case with the user jenkins), your command-line user needs to be able to write to sites/*/files/simpletest.

My solution has been to use the visudo file to allows jenkins to run drush under the www user (on a test environment), and then run my tests in the command but under www.

sudo -u _www drush test-run 'mysite deploy' -y

To avoid permissions problems, sites/*/files/simpletest must also be owned by www, but jenkins needs to be in a group that has write access to that directory.

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h3>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.