Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The annotation component has 0 explicit testing.
Proposed resolution
Add tests.
Remaining tasks
Review and commit patch.
Beta phase evaluation
Issue category | Task because it provides additional testing |
---|---|
Issue priority | Normal missing tests |
Unfrozen changes | Unfrozen because it only changes tests |
Disruption | 0 Disruption |
Comment | File | Size | Author |
---|---|---|---|
#35 | interdiff.txt | 3.4 KB | Mile23 |
#35 | 2435607_35.patch | 13.92 KB | Mile23 |
#32 | 2435607.interdiff.txt | 2.54 KB | neclimdul |
#32 | 2435607.patch | 15.48 KB | neclimdul |
#27 | interdiff.txt | 7.1 KB | Mile23 |
Comments
Comment #2
markdorisonPatch no longer applies cleanly.
Comment #3
neclimdulThanks! Re-roll and a couple cleanups since some coding standards have changed since this was rolled last year.
Couple notes:
1) I think there is actually some coverage now but its in kernel tests. This is IMHO better.
2) There is a new feature since original roll to provide additional annotation namespaces and that test coverage is missing from this coverage.
3) Cache handling is not tested in this testing.
Comment #5
dawehnerThat classname looks so weird, how is "com/example" a valid namespace?
Comment #6
neclimdulThis so old there are 8.0 beta eval's in the summary still... I assume I did that for a reason but i'm going to have to do some digging to answer your question at this point.
Comment #7
dawehnerLet's set it to needs work until then :)
Comment #8
neclimdulSo PHP allows it as documented here. http://php.net/manual/en/language.namespaces.faq.php#language.namespaces...
I think I was asserting that we didn't break it because we where working with namespaces as strings.
Its actually working here.
Comment #9
dawehnerDo you mind leaving a comment about that? It still confused me.
Comment #10
neclimdulum.. that would be because it doesn't make sense. I guess it just shows that annotations doesn't actually care about the namespace it just parses files? That's probably not something that needs to be tested...
So cleaned that up and added some tests for custom plugin annotations which seem to have been missing. Only thing not tested now I think it the FileCache stuff.
Comment #12
neclimdulI don't even know. that failure doesn't even show up in the test run logs.
Comment #14
Mile23Kinda goes without saying... Needs a reroll. :-)
Also we need tests so we can proceed with #2631202: Doctrine no longer supports SimpleAnnotationReader, incorporate a solution into core
Comment #15
markdorisonRe-rolled.
Comment #16
Mile23Some weird formatting. If we can fit a function on a line we should.
Generally looks like it does a good job of exercising all the classes.
Comment #17
markdorisonFixed issue detailed in #16 and updated the rest of the patch to conform to Drupal coding standards.
Comment #18
Mile23Cool, thanks. RTBC now assuming the tests will pass....
Comment #19
larowlannit: I think we need these blank lines
nit: on => of?
These can be fixed on commit
Comment #20
markdorisonFixed issues detailed in #19.
Comment #21
Mile23#20 fixes #19.
Comment #22
larowlanFrom #10
Only thing not tested now I think it the FileCache stuff.
I can't see any interdiffs since then that add that?
Comment #23
larowlanComment #24
Mile23This component has a dependency on drupal/core-file-cache, which is incorrect in its composer.json despite #2876725: Fix trivial core component composer bugs before 8.4.0 and #2867960: Merge Component composer.json files to account for them during build
We should exercise and test the behavior of the file cache as you can see in http://cgit.drupalcode.org/drupal/tree/core/lib/Drupal/Component/Annotat...
So: The test should create an AnnotatedClassDiscovery, use it to discover, check the cache for the same information we got back, change the cache, perform the same query, get back the different cached result.
Agreed? :-)
Comment #26
borisson_That sounds like a good solution for testing the filecache.
Comment #27
Mile23So I see a bunch of fails locally that look like this:
That's the test listener doing it's job so yay test listener.
Fixed. I had to move some
FileCacheFactory
management toAnnotatedClassDiscoveryTest
.Added file cache test. It's a separate test class because it has a different
setUp()
thanAnnotatedClassDiscoveryTest
, in that we want to use caching. :-)Comment #28
neclimdulWhy is "\Drupal\Tests\UnitTestCase" considered Core? I know I've had this discussion before when writing a lot of component tests early on and it is clearly not or it would be in "\Drupal\Tests\Core\"
Comment #29
Mile23UnitTestCase
uses\Drupal
and other core-related stuff. Component tests should be runnable independent of core. See: https://github.com/paul-m/drupal_component_testerIt's true that
UnitTestCase
might be better placed under theCore
namespace.Check it out:
BrowserTestBase
is under\Drupal\Tests\
, too, and it doesn't even inherit fromUnitTestCase
. Happy to review a re-shuffling issue if you file it.Comment #30
neclimdulThanks. I've opened #2913630: Move UnitTestCase to Core namespace, deprecate old to start that.
I'd RTBC but the cache test is failing locally and I'm trying to sort out why... Filecache is frustrating.
Comment #31
Mile23I'm not seeing any fails locally...
Comment #32
neclimdulProcess isolation bug in in UnitTestCase. Not directly tied to this patch but exposed by you actually testing the FileCache system.
Breakdown: If run in isolation like testbot everything works.
AnnotatedClassDiscoveryCachedTest::setUp
does not touch filecache global config and cache works as expected. But if run as a full test suite using the phpunit runner (and no process isolation) any core test that uses UnitTestCase before the cached annotation test causes the filecache to be disabled globally and never re-enabled. That causes the AnnotatedClassDiscoveryCachedTest test to break when it gets a Null cache implementation. Unfortunately phpunit's global change detection isn't catching this because its hidden in a static class.I updated the UnitTestCase to clean up after itself. We could possibly also force the configuration we want as part of the cached annotation test but we should definitely fix UnitTestCase to avoid it breaking subtly in the future.
If you agree with the changes I made, I think the patch is RTBC.
Comment #33
Mile23Oh yeah, of course.
We could set @runTestsInSeparateProcess for those classes.
Comment #34
neclimdulwe could but tearDown should reset any state changes so the UnitTest change is correct imho.
Comment #35
Mile23Nevermind...
@runTestsInSeparateProcesses
not really a good idea, actually. :-)UnitTestCase::setUp()
always sets the file cache configuration and prefix, so it's in a known state before the tests run. Other than that, the only way to make sure state doesn't bleed is to run all tests that change the file cache settings in isolated processes, and not usesetUp()
to manage it, which is a lot more effort and takes longer. (setUp()
is run before the separate process is created, so it will still change the static and possibly leak to other tests.)I don't like the idea of the test being responsible for resetting static state at
tearDown()
, because the 'old' settings could just be the leaked state we don't want.So being consistent with
UnitTestCase
, we set the config of the file cache explicitly insetUp()
in both classes.I couldn't find any similar issues in the file cache component.
Also:
FileCacheFactory::setConfiguration()
docs: Completely not useful. :-)Also II: Statics are evil and will bring forth the ire of the Ancient Ones who will devour your soul before you can invoke the names of the Gang of Four.
Comment #36
neclimdulI don't agree but that's fine because in reality its totally unrelated to this issue so lets discuss in a follow up. :)
#2914242: Reset Filecache State in UnitTestCase
Comment #37
Mile23:-)
Comment #38
larowlanAdding review credit for @dawehner
Comment #39
larowlanCommitted as 2d25dc4 and pushed to 8.5.x.
Comment #41
Mile23Hmm. Never did link this issue.