This is part of my continued clean-up of SimpleTest and its API.
One area that really needs some attention is simpletest_get_all_tests() and the related uses. The getInfo() method is called way to often and should be called centrally.
Also I am looking into having the registry auto-load tests and provide SimpleTest with a list.
| Comment | File | Size | Author |
|---|---|---|---|
| #28 | registry.docs_.patch | 1.55 KB | Anonymous (not verified) |
| #22 | 449198-simpletest-test-loading.patch | 28.8 KB | boombatower |
| #20 | 449198-simpletest-test-loading.patch | 28.16 KB | boombatower |
| #15 | 449198-simpletest-test-loading.patch | 28.09 KB | boombatower |
| #13 | 449198-graph-exception.png | 14.37 KB | boombatower |
Comments
Comment #1
chx commentedWell, you can add .test files to .info and then you can fetch that information
select * from registry where type='class' and filename like '%.test';to find candidates and then run amethod_exists($object->name, 'getInfo')to find whether they contain the necessary method.Comment #2
boombatower commentedThe
simpletest_get_all_tests()function is called 7 time and in each case it is used to auto-load classes or get the getInfo() information as you would expect.It might almost make sense to just cache the getInfo() since registry will take care of auto-loading...then we have no need to even load all the test files 90% of the time.
Created separate issue, but may end up merging: #449200: SimpleTest: Cache test information.
Comment #3
boombatower commentedIt takes 4 lines to cache, so I am just going to include it in this patch I'll mark other as duplicate.
This is extremely rough code since it only contains an updated
simpletest_test_get_all()(also renamed) and does not change the code where called. I think it is best to wait for #445950: SimpleTest interface separation and cleanup since it will change how much of the calling code works.Comment #4
boombatower commentedOther issue committed. I will begin work on this again.
Comment #5
boombatower commentedSeems to run well and should be faster since everything is cached and we no longer have to load all test files every time we want information on one or all.
Removes 4 calls to
simpletest_test_get_all()and lazy-loads test files instead of loading them all whenever it needs one! The code was looping over the same stuff numerous times in the same request...it no longer does that.This patch does not the addition of test files to all the .info files. I'll get that next.
Comment #6
boombatower commentedThis should be full version of patch.
Comment #7
boombatower commentedThese are the tests that are missing:
Not sure why since for instance aggregator tests are not in list, but there is an entry in the .info file. Also registry does not even have a record for aggregator.test. Looks like might be related to registry.
Comment #8
boombatower commentedHmm....slip of the brain....this was the issue over at hook_test()....it only picks up enabled modules. Hmm
That means there are two options:
Continue to use registry, but only display enabled modules and come up with something special (or enable all modules) for t.d.o.
I would really like to lazy load the tests...much better for performance and cleaner to implement.
Comment #10
boombatower commentedComment #11
boombatower commentedIncluded necessary registry changes and new tests in test folder: batch and error.
Comment #13
boombatower commentedGet a single exception in the graph test.
If I change the class to DrupalWebTestCase instead of DrupalUnitTestCase it works fine.
There are 7 other test cases that use the DrupalUnitTestCase and still pass.
Comment #14
boombatower commentedThe following change fixed it, as one would expect. I am not entirely sure why this only manifests itself with the patch.
Comment #15
boombatower commentedAll inclusive patch.
Comment #16
dries commentedI think caching is fine, but only if it is worth the trouble. Benchmark results can tell us that. If there are no significant improvements, it's probably not worth it?
Other than that, this looks like a fine clean-up to me.
Comment #17
boombatower commentedThere are a two reasons for caching:
1) Avoid loading all the .test files and calling all the getInfo() methods in the 100+ test cases every page load and during test running with the patch API (so 100+ times on t.d.o).
2) Avoid having to perform sorting and grouping of array every page load. (there are several patches which will add a bit more information to the array)
I have not done a benchmark, but I would bet it is worth it. Anyone want to run a benchmark, otherwise I can spend some time and learn how.
Comment #18
JamesAn commentedSubscribing (#481498: Update simpletest module to use drupal_static() is postponed on account of this issue.)
Comment #19
chx commentedI am in love with the patch. It's hard not to when you are removing so much and let the registry do the work which it already does anyways. Two small problems:
Parse .info file only for all modules <= Huh??
if (preg_match('/.*?\.test/', $file)) { <= substr($file, 0, -5) works. I am aware of the powers of preg but that's overkill here (also if you were to use preg, you would need simple /\.test$/ here)
Comment #20
boombatower commentedSeems from #19 that would be a solid review, thus marking as RTBC. thx
Changed comment in question to:
and condition in question should be:
Comment #21
dries commented- "necessary alterations" -- it would be good to describe what these alternations are.
-
File provided by disabled modules-- should be "Files".-
an array of the related module name and weight-- should be "modules".- The section on
+ * @param $filesseems to need some work -- it doesn't read well.-
contains an property-- should be "a property".-
where is looks-- should be "where it looks".- Etc.
The documentation needs some more TLC and a good scrub!
Comment #22
boombatower commented"an array of the related module name and weight" refers to (per documentation):
which is the related module and weight.
Updated for #429132: Remove unecessary module_rebuild_cache() call from _registry_rebuild().
Added additional documentation in several places and clarified others.
All other changes made.
Comment #23
dries commentedCommitted to CVS HEAD. Thanks.
Comment #24
catchclean HEAD, enable simpletest module:
Comment #26
tstoecklerconfirming exact same errors on a fresh install.
Comment #27
boombatower commentedThis code just revealed a bug introduced by other patch: http://drupal.org/node/147000#comment-1675232. Already talked with Berdir in IRC.
Comment #28
Anonymous (not verified) commenteddocs only update.
i went in looking to change the comment about installed modules, as the registry is now full of files and resources for uninstalled modules. i also found we had some outdated caching comments at the top of the file, so they can go as well.
Comment #29
dries commentedCommitted to CVS HEAD. Thanks.