Detect cache out of sync with code on test list select
mattyoung - August 16, 2009 - 18:19
| Project: | SimpleTest |
| Version: | 7.x-2.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | boombatower |
| Status: | closed |
Description
If the user is able to select a test but is not found in the cache, this is certainly because the test case class name has changed.
Suggestion:
1. Print out a message instructing the user to clear the cache and try again or
2. Go ahead a clear the cache a come back to the list page, show a warning message "Code appears to be out of sync with cache. The cache has been cleared, select the test to run again."

#1
#2
The last submitted patch failed testing.
#3
#4
Passed first time...test slave fritsed second time
Result received from slave #29 (Passed: 12114 passes, 0 fails, 0 exceptions).#5
#6
Do we need to cache the test list at all? This is development only code, and not having new tests show up there is a pain.
#7
I see the point, and the answer has to be no we don't have to. The reason it was added was due to the fact that it had to read the entire filesystem anytime it wanted to load the test list page. Since it piggy backs off the registry now it knows where the test files are, but it still has to load all the test files in order to generate the page.
That said, it gets slow reading all the files whenever you want to generate that page and is unnecessary and is not really scalable, especially when we think about contrib (now that mentioned it should clear cache when new modules installed).
Three options then:
1) Remove it
2) Have it compare its list against the registry always (should be less expensive then loading all files), and rebuilding if change
3) Leave the way it is
I am leaning towards #2.
#8
I like #2.
Another option would be renaming the cleanup button / help text so it clears the simpletest cache too just for convenience.
#9
The last submitted patch failed testing.
#10
HEAD is broken.
#11
#12
In simpletest_clean_environment() there already is:
<?php// Detect test classes that have been added, renamed or deleted.
registry_rebuild();
cache_clear_all('simpletest', 'cache');
?>
Committed solution above as it makes a nice message popup when running tests that do not exist, instead of crashing. It also appends message to clean environment description.
#13
fix title typo
#14
Automatically closed -- issue fixed for 2 weeks with no activity.