When running simpletest 2.x tests on a site that doesn't have a files folder set to sites/default/files the test results warns me that the simpletest directory's cannot created or deleted with "rm".

It seems like simpletest does not check the sites file_directory_path variable and use it's own paths. I think it's incorrect behaviour to use sites/default/files path by default if there is a different path defined. Also don't forget private download mode. Sites upgraded from D5 or earlier mostly have it's files path in [base_path]/files directory. Simpletest needs to care about this.

It also seems not to prefix this wrong path with [base_path] if drupal is installed in a subdirectory, but I haven't verified this - I can only say from the warning shown in UI what showed me sites/....

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mtolmacs’s picture

Subscribe

boombatower’s picture

Status: Active » Postponed (maintainer needs more info)

The code cannot and should not care about d5...it is setup to test d6 as backported from d7. Otherwise I'm not sure what your talking about simpletest uses file_directory_path() . $db_prefix; for each test that is run...that is then deleted... I'm a at a total loss as your are coming up with all these bugs that no one else has and d7 core developers have approved...I not sure what you are looking for me to do. If you have functionality changes please move this issue to core where it can then be backported.

hass’s picture

Status: Postponed (maintainer needs more info) » Needs review
FileSize
1.29 KB

One reason could be that you don't try to understand that there are bugs. It doesn't matter much what have been approved for D7 as this code doesn't care about an upgrade path very much or not at all until we reach a BETA1 level and extensive upgrade tests. Keep this every time in mind, please. A D5 and D6 simpletest version *must* care about an upgrade path as this is not DEV. Approved - also don't meen bugfree. Aside simpletest is only installed on ~150 sites and may not be used very often on this very few sites - therefore don't expect many reports and much less from upgraded Drupal versions!

I think I know - how this bug occurs:

Pre-requirements:
0. You need to install simpletest on a D6 version that was upgraded from D5.
1. This D5 version have had 'file_directory_path', 's:5:"files";' configured and don't have a directory "sites/default/files" on disk.

Run a test:
1. The module creates the "simpletest" prefixed tables and the variables tables don't have a entry of 'file_directory_path'.
2. Then file_directory_path() http://api.drupal.org/api/function/file_directory_path/6 is called and variable_get('file_directory_path', conf_path() .'/files') defaults to "sites/default/files". because the path is not yet configured in "admin/settings/file-system".
3. Therefore "sites/default/files" doesn't exists if you access it and throws an exception.

How to fix in simpletests setUp():
1. Simpletest must call $this->original_file_directory_path = variable_get('file_directory_path', conf_path() .'/files') on the main installation (not simpletest prefixed tables) and buffer the value.
2. Then switch to the simpletest prefixed tables
3. Install the tables
4. Save the buffered 'file_directory_path' value with variable_set('file_directory_path', $this->original_file_directory_path) into the simpletest prefixed variable table.
5. Run the tests.

The mysql dump proves this bug:

/*!40000 ALTER TABLE `simpletest155897variable` DISABLE KEYS */;
INSERT INTO `simpletest155897variable` (`name`,`value`) VALUES 
 ('clean_url','s:1:\"0\";'),
 ('comment_page','i:0;'),
 ('css_js_query_string','s:20:\"ZwK6OEgskPXJL5oBytS9\";'),
 ('drupal_private_key','s:64:\"bf0d466f5843ece1940e36814a8c94005a8977e53b5938b3b9fea85bf988fe11\";'),
 ('file_directory_path','s:36:\"sites/default/files/simpletest155897\";'),
 ('filter_html_1','i:1;'),
 ('install_profile','s:7:\"default\";'),
 ('install_task','s:16:\"profile-finished\";'),
 ('menu_masks','a:17:{i:0;i:62;i:1;i:61;i:2;i:59;i:3;i:31;i:4;i:30;i:5;i:29;i:6;i:24;i:7;i:21;i:8;i:15;i:9;i:14;i:10;i:11;i:11;i:7;i:12;i:6;i:13;i:5;i:14;i:3;i:15;i:2;i:16;i:1;}'),
 ('node_options_forum','a:1:{i:0;s:6:\"status\";}'),
 ('node_options_page','a:1:{i:0;s:6:\"status\";}'),
 ('theme_default','s:7:\"garland\";'),
 ('theme_settings','a:18:{s:11:\"toggle_logo\";i:1;s:11:\"toggle_name\";i:0;s:13:\"toggle_slogan\";i:0;s:14:\"toggle_mission\";i:0;s:24:\"toggle_node_user_picture\";i:0;s:27:\"toggle_comment_user_picture\";i:0;s:13:\"toggle_search\";i:1;s:14:\"toggle_favicon\";i:1;s:20:\"toggle_primary_links\";i:1;s:22:\"toggle_secondary_links\";i:1;s:21:\"toggle_node_info_page\";b:0;s:22:\"toggle_node_info_story\";i:0;s:12:\"default_logo\";i:1;s:9:\"logo_path\";s:35:\"sites/all/themes/yaml/img/title.gif\";s:11:\"logo_upload\";s:0:\"\";s:15:\"default_favicon\";i:1;s:12:\"favicon_path\";s:0:\"\";s:14:\"favicon_upload\";s:0:\"\";}');

Patch attached.

EDIT: Updated patch that uses $this->original_file_directory.

boombatower’s picture

I'll look at the patch in more detail, but that doesn't make a whole lot of sense as file_directory_path() should be correct.

Secondly SimpleTest is intended to test vanilla Drupal install, stores no data, and shouldn't be used on production sites...at least not the 2.x version. Therefore updating makes no sense.

I don't fully undderstand the file path issue as file_directory_path() should be correct.

Lastly no where did I say this code was bugless or try to imply that. Much of what you are making issues about are not bugs, but more special cases that could be viewed either way.

I'm happy to help, but I don't see a major reason for deviating from the D7 codebase as that is the major goal of 2.x and will make apply backport in the future much more difficult.

hass’s picture

The stage where file_directory_path() get called today is too late, that's all. It doesn't care about path's that have been changed by hand (or upgraded installations).

Why should simpletest only run on test systems?

If we add tests to modules and release them together, people are free to use them. If users have issues - I will for sure ask them at very first to run the tests on their site to make sure their server config may not the issue and see if the tests are working or failing.

Doesn't matter to me if this is production or not. In D7 simpletest is a core module and people simply can check it - they also don't know that this module is only for development purposes and can break their site. Aside if this may really the case - I hope simpletest will be removed form core and stay in contrib to make sure people are not destroying their site or don't run it on normal production sites. It would be the very first time that a module have been added to core, but is not for production use. But I haven't followed the discussion...

boombatower’s picture

The reason was to unify behind one testing framework...and to get full test coverage of core (or very close).

boombatower’s picture

Status: Needs review » Closed (won't fix)

6.x-2.x != same module, just same name.

Please uninstall and re-install module...then wala.

hass’s picture

Status: Closed (won't fix) » Needs review

I think you have not understood the bug. Uninstall of the simpletest module cannot fix this issue. Core has been installed long time ago with a D5 standard files directory and was then upgraded to D6. You MUST care about variable table SETTINGS. In such a case the files directory is typically in files (but could also be in a different place!!!) and NOT in sites/default/files what the buggy simpletest module as it's ignoring the sites settings.

boombatower’s picture

Title: Exception: directory sites/default/files does not exist » SimpleTest: $this->originalFileDirectory should be set before installation to ensure non-standard directories are picked up
Project: SimpleTest » Drupal core
Version: 6.x-2.5 » 7.x-dev
Component: Code » simpletest.module
Status: Needs review » Needs work

So sounds like this isn't necessarily related to upgrade...this would happen if you changed files directory at all?

Sorry, for not getting this sooner, but you made a number of update related issue to allow 5 -> 6 transition of schema when SimpleTest stores no data...which I felt was rather useless...since SimpleTest is a developer tool and stores no data. This on the other hand is a general issue and should be fixed in Drupal 7 core.

We should still use file_directory_path() instead of: variable_get('file_directory_path', conf_path() .'/files');

Read the api documentation http://api.drupal.org/api/function/file_directory_path

function file_directory_path() {
  return variable_get('file_directory_path', conf_path() .'/files');
}
hass’s picture

Yeah, this is not an upgrade issue of the module themself. Simpletest ignores a customized "files" directory setting of core. Thank you for the hint, this seems to require a re-role.

dale42’s picture

#374193 - Temporary File Directory Not Created if parent 'files' directory moved a duplicate report of this issue.

Per boombatower's request, referencing here and marking other issue as duplicate.

hass’s picture

Patches attached for simpletest D6 and D7. Re-Test

The last submitted patch failed testing.

dwightaspinwall’s picture

Project: Drupal core » SimpleTest
Version: 7.x-dev » 6.x-2.6
Component: simpletest.module » Code

It looks like I'm running into this bug too. We have a Drupal 6 install which has been upgraded from Drupal 5. Running any test throws errors as follows:

scandir(sites/edge1.humancapitalinstitute.org/files/simpletest123176) [function.scandir]: failed to open dir: No such file or directory	Warning	simpletest.module	566	simpletest_clean_temporary_directory()	
scandir() [function.scandir]: (errno 22): Unknown error: 0	Warning	simpletest.module	566	simpletest_clean_temporary_directory()	
Invalid argument supplied for foreach()	Warning	simpletest.module	567	simpletest_clean_temporary_directory()	
rmdir(sites/edge1.humancapitalinstitute.org/files/simpletest123176) [function.rmdir]: No such file or directory	Warning	simpletest.module	578	simpletest_clean_temporary_directory()

Tried uninstalling / reinstalling SimpleTest. Doesn't help.

I'm not sure I understand the issue here. Lots of modules are able to discern the files directory. Why not SimpleTest? Thanks for your efforts on this.

hass’s picture

Project: SimpleTest » Drupal core
Version: 6.x-2.6 » 7.x-dev
Component: Code » simpletest.module

Yeah, this looks like this bug.

hass’s picture

Damien Tournoud’s picture

Let's try again.

Damien Tournoud’s picture

Status: Needs review » Reviewed & tested by the community

This has my stamp of approval.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

webchick’s picture

Oops. Dries beat me to this while I was trying to replicate the problem. :D

hass’s picture

Project: Drupal core » SimpleTest
Version: 7.x-dev » 6.x-2.x-dev
Component: simpletest.module » Code
Status: Fixed » Reviewed & tested by the community

THX, now needs to be committed to D6.

boombatower’s picture

Status: Reviewed & tested by the community » Fixed

I would prefer that issues are just marked as fixed...and left in core...I make periodic backport of D7 which I have found to be much more accurate and time effective then back-porting each patch.

I have committed this change, but please leave further changes in core issue queue.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

hass’s picture

Status: Closed (fixed) » Reviewed & tested by the community

This BUG is still there in 6.x-2.8 and therefore UNFIXED.

hass’s picture

Version: 6.x-2.x-dev » 6.x-2.8
Dave Reid’s picture

Are you sure? Are you using the 6.x-2.x-dev where this was fixed? See http://drupal.org/cvs?commit=202698

hass’s picture

2.8

boombatower’s picture

Status: Reviewed & tested by the community » Fixed

Sounds like you just need to use dev release. Please re-open if still encountered.

hass’s picture

Status: Fixed » Closed (fixed)

Ok, verified - issue is fixed. Closing case.

Dave Reid’s picture

Le sigh... "Are you sure? Are you using the 6.x-2.x-dev where this was fixed?" For heaven's sake the issue version was set to 6.x-2.x-dev when it was 'fixed.' So that's the version you should have used to get the fix instead of re-opening the closed issue.

hass’s picture

Version: 6.x-2.8 » 6.x-2.x-dev

I used 2.8 for testing first and now upgraded to DEV to verify the fix. I wasn't aware that this fix gone in after the 2.8 date as simpletest releases are normally rolled after a backport and the source of the backport have had the fix.