Implementing additional tests for ctools:
- New function ctools_reset_page_tokens() to reset the page token store (drupal_static()).
- Unit test coverage of the Object Cache plugins simple.inc and export_ui.inc, and the function ctools_cache_find_plugin, mostly checking the plugins are well-formed.
- Unit test coverage of the page_token functionality.
- ctools_set_page_token()
- ctools_set_variable_token()
- ctools_set_callback_token()
- ctools_page_token_processing()
Improving function documentation for:
- ctools_set_page_token()
- ctools_set_variable_token()
- ctools_set_callback_token()
Comment | File | Size | Author |
---|---|---|---|
#64 | 2827100-64.patch | 884 bytes | TR |
#62 | 2827100-62-partial-revert.patch | 6.95 KB | joelpittet |
#52 | ctools-n2827100-52.interdiff.txt | 415 bytes | DamienMcKenna |
#52 | ctools-n2827100-52.patch | 51.14 KB | DamienMcKenna |
Comments
Comment #2
rivimeyAdded new function ctools_reset_page_tokens() for use by test suite, and modify ctools_set_page_token() to use drupal_static to enable ctools_reset_page_tokens(). Otherwise tests accumulate changes rather than resetting them for each test.
Comment #3
rivimeyThis patch includes changes to ctools.info that are included in 2808985 so it should be applied afterwards.
Comment #4
rivimeyAdding a token processing test in CtoolsPageTokens
Comment #5
rivimeyComment #6
rivimeyAdded new tests for callback tokens and clarify docs for that.
Improve tests for CSS handling, especially check the negative cases.
Comment #7
rivimeyLast one for now; test the uuid functionality.
Comment #8
rivimeySome code-coverage info from the code_coverage module and xdebug. However, note there's a lot of code that is only ever parsed, so files with 100% coverage are likely to be more like 0% :(
For the record, current ctools 7.x-1.x has reported Total coverage of 75% (vs 77% from this patch)
Comment #9
DamienMcKennaI question the test coverage data in comment #8, but I'm happy to see the test coverage itself improve. Great work, rivimey!
Comment #10
rivimeyUploaded base (ctools 7.x-1.x) and to most recent patch (as page-css-uuid) both as simple csv files. Easier to manipulate than table html!
Comment #11
rivimeyDamienMcKenna, the coverage data appears to only be present for functions that were called at least once. If a function was never, ever called, there is no data for it, and it 'disappears' from the coverage data as well, being considered no more than a comment.
An example: this is from the colorized output from the stylizer code. Some functions were called by php at some point, but there is no test for them, so the lines are red. The other functions appear in light grey, indicating not included (I think). A tested line would be black.
Many of the plugins are all grey and their coverage is indicated as 100% :(
Comment #12
rivimeyMarking needs review: there is plenty more to do on this, but I think this patch is big enough!
Comment #13
rivimeyComment #14
rivimeyComment #15
DamienMcKennaRerolled.
Comment #17
DamienMcKennaSome minor tidying up.
Comment #19
DamienMcKennaDarnit, the patch isn't applying anymore via testbot, even though it applies perfectly locally.
Comment #20
DamienMcKennaFixed a typo in math_expression.test.
Comment #22
DamienMcKennaMinor fixes to object_cache.test, object_cache_unit.test and uuid.test.
Comment #24
DamienMcKennaTwo PHP 5.3 -compatibility fixes.
Comment #25
DamienMcKennaThe following error is being logged by the testbot:
Why would it fail to enable the CTools module, which is where that function exists?
Comment #27
DamienMcKennaThe exception thrown by uuid.test is:
Given it's wrapped around an if(!defined()) I'm not sure how this is possible. Argh.
Comment #28
DamienMcKennaThe UUID handling had to be split up into two classes, otherwise it was failing when the UUID module was loaded.
Comment #30
DamienMcKennaNot sure what's going on, the tests run correctly locally.
Comment #32
DamienMcKennaDarnitall :-\ Not sure what's going on :(
Comment #33
DamienMcKennaSome minor tweaks, shouldn't make any difference.
Comment #35
DamienMcKennaTrying to disable the UUID tests for later.
Comment #37
DamienMcKennaAdditional minor tweaks.
Comment #39
DamienMcKennaThat "Call to undefined function ctools_include() in object_cache_unit.test on line 97" error is continuing to cause it to fail, not sure what is causing that.
Comment #40
DamienMcKennaRunning the tests locally, here's where it's failing:
This is because Export UI doesn't have a 'cache clear" method.
This patch updates export_ui.inc with a @todo comment, and disables the assertions that were failing but clarifies the @todo to say that the API problem should be fixed.
Comment #42
DamienMcKenna... what?
So it's still failing on "Call to undefined function ctools_include()" for the first line of testFindSimpleCachePlugin(), which makes no sense as ctools.module should be loaded by that point.
As for "FATAL CtoolsUUIDWithUUID: test runner returned a non-zero error code (255)." I have no idea.
Comment #43
rivimeyI included the tests of export_ui and decided (based on the api comments by merlinofchaos) that the lack of 'clear' method was a code failure, not a test failure, so I left it in place.
It is likely this scenario (i.e. test finds a bug) will happen again: did I do the wrong thing?
Comment #44
DamienMcKennaAdding ctools as a dependency on each getInfo() definition.
Comment #45
DamienMcKennaOk, talking in IRC the problem with object_cache_unit.test is that it uses DrupalUnitTestCase(), which can't install modules thus ctools_include() is never made available.
Comment #47
rivimeyMain points:
- in object_cache_unit.test: now extends DrupalWebTestCase
- in uuid_with_uuid.test changed CtoolsUUIDWithUUID: now defines uuid as a dependency.
Also got carried away a bit; did some more docblock changes too.
Note that in the docblocks I decided not to add 'array' hints to the functions, in case that causes problems with actual code. We can leave it for another time :-)
Comment #48
rivimeyComment #49
DamienMcKennaGreat improvements!
We're not ready to add any dependencies on 'uuid' yet, so lets leave that for later.
Comment #50
DamienMcKennaBumping to 1.13.
Comment #51
rivimey@DamienMcKenna, The patch in #49 has additional space at the end of one of the lines in math_expression.test causing git apply to complain, which got me looking at that file, and the result is I've updated the file as a whole. Now thinking that work would be better off as a new Issue rather than tacked onto this one -- do you agree?
The extra space is on line 922 **of the patch file** for function testBuildInFunctions(), approx line 67 in the php.
Edit: Created as #2830393: Improve test coverage and function docs: math_expression
Comment #52
DamienMcKennaFixed the comment on the testBuildInFunctions() method, which is where the whitespace error came from.
Comment #53
DamienMcKennaRTBC in my book ;)
Comment #54
rivimeyComment #56
japerryLooks good to me. Committed.
Comment #57
DamienMcKennaThanks for finally committing this, japerry. BTW the commit authorship should have gone to rivimey - would you mind reverting & recommitting it with that corrected?
Comment #59
joelpittetConsidering the disabled tests and the dependency on uuid which causes a chain in breaking 5.3 compatibility. I'm considering reverting this patch in parts (mostly the @todo parts).
#2942581: ctools.test breaks Feeds tests on PHP 5.3 because of short array syntax
#2783113: Using trait without PHP 5.4 requirement breaks Drupal CI of all modules that require UUID
Snuck in @todos
Comment #60
joelpittetComment #61
joelpittetComment #62
joelpittetHere's what I propose we revert.
Comment #64
TR CreditAttribution: TR commentedI think it should be sufficient to just comment out the test cases and the test_dependency in ctools.info - locally at least run-tests.sh won't discover the tests if this is done. I'm not sure exactly if that's also true with the testbot.
One way to find out would be to commit this attached patch, THEN try to test CTools against PHP 5.3 and see if it works. If not, revert the patch.
(I'm testing against 5.4 here because patches are applied AFTER the dependencies are calculated, so PHP 5.3 tests will fail even if the patch is correct - that's what happened in #62. The 5.4 test will simply ensure the patch applies, nothing else.)
Comment #65
joelpittetThe tests aren't finished or working, I'd rather remove them. I don't want to leave @todo in production code, that can stay in the issue queue.
Comment #68
joelpittet#62 was committed