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
*TestBase
classes are attempted to be executed as a test case class.
Related issues
Comment | File | Size | Author |
---|---|---|---|
#52 | run-tests-1700682-52.patch | 566 bytes | xjm |
#41 | drupal8.run-tests-base.41.patch | 15.03 KB | sun |
#37 | drupal-1700682-37.patch | 15.02 KB | tim.plunkett |
#27 | drupal-1700682-27.patch | 14.47 KB | tim.plunkett |
#25 | drupal-1700682-25.patch | 15.08 KB | tim.plunkett |
Comments
Comment #1
sunAttached patch should fix the issue.
Comment #2
aspilicious CreditAttribution: aspilicious commentedDon't know the internals of the $test_classes array but my feeling says this should be good to go.
Comment #3
sunLet's make that more solid.
Comment #4
sun@sun shouldn't listen to metal while hacking. ;)
Comment #5
sunHm. This bug impacts existing, regular projects:
http://qa.drupal.org/pifr/test/305443
Comment #6
sunI redact that statement. The test failure is caused by advanced usage of PSR-0 classes in that contrib module.
Comment #7
sunIt is unfortunate that we have to load all test classes in order to check whether they have a ::getInfo() method, but I do not see another way around this.
In other words, I think this patch is RTBC.
Comment #8
aspilicious CreditAttribution: aspilicious commentedI think this is rtbc to.
Comment #9
catchWhat about reflection? Not sure it matters though, run-tests.sh is definitely not the bottleneck in running tests.
Comment #10
sunSure, Reflection works, too. :)
Comment #11
aspilicious CreditAttribution: aspilicious commented? This still needs to load every test. Catch wanted to use reflection when building the list.
Comment #12
sunThere is no other location where the list of classes to run is built. Actually, when passing definite arguments (and not the --all parameter), then there is no predefined list involved at all. That is, because we recently optimized run-tests.sh script for the new class loader: #1683884: Update, simplify, and speedup run-tests.sh for PSR-0, and allow to run all tests of a module
The idea of using Reflection is that PHP might have the class information pre-cached natively (or potentially, that's only possible when APC is enabled [on the command line though?]).
Anyway, as @catch already mentioned, that's the very least of test performance issues we should care for...
Comment #13
aspilicious CreditAttribution: aspilicious commentedOk lets commit #10 so views D8 tests can run again
Comment #14
chx CreditAttribution: chx commentedNote: if we commit #10 then soon-ish #1698108: Update Drupal's dependencies we can use the tokenizer code I wrote for Doctrine to replace the ReflectionClass with a tokenizer-based approach so that you do not need to include all the classes (yet you need to read them, yes). It was meant for annotations but seems useful here as well. See an example here on how this is done.
Comment #15
tim.plunkettTestbot cannot instantiate an abstract class, because they are abstract. PHP will not allow it. The problems we had in Views were solved by properly making base classes abstract.
I think this should be closed, but leaving open for discussion.
Comment #16
sun@tim.plunkett: This code does not attempt to instantiate an abstract class. In fact, it is the essential fix to make the test runner not attempt to do that.
Comment #17
aspilicious CreditAttribution: aspilicious commentedsun when you make the base classes abstract the test runner won't attempt to do it.
Comment #18
tim.plunkettI think checking for getInfo is incorrect. This makes more sense to me.
Comment #19
tim.plunkettHowever, I don't think this is actually legitimate, core and contrib are full of abstract classes that aren't blowing up on testbot.
Comment #20
xjmComment #21
xjmSorry for double post. :)
Comment #22
xjmI should note that I'm particularly concerned about automatically skipping any
getInfo()
-less class -- I think this would mean (as Tim has stated) that a broken test without agetInfo()
method would silently never be run, which is a concern, as no one will typically scan through all 450 core tests classes to ensure one has run. However, I'm going to actually get some manual testing with this issue to see what's happening.Comment #23
xjmThrew together a sandbox. Haven't actually tested with it yet.
http://drupal.org/sandbox/xjm/1705218
Base classes should be abstract. Tim mentioned yesterday that 25 in core currently are not, and that #1674290: PSR-0 tests in contrib modules are not found was caused by a views bug.
Comment #24
sunA missing getInfo() is (sadly) "catched" on various other levels of the callstack, so I'm fine with this compromise.
The original idea and intention was that run-tests.sh is and should be a detached test runner script that does not rely on the gazillions of weird functions and checks of simpletest.module in the first place.
Since that is a never-ending battle and my plan is to replace the testing framework entirely for D8 anyway, I'm happy to go with this patch as a(nother) stop-gap fix.
Comment #25
tim.plunkettSorry, which patch are you RTBCing? I'd much rather just do this.
Comment #27
tim.plunkettFixed my regex, I accidentally marked NodeAccessBaseTableTest as abstract :)
Comment #31
tim.plunkettCall to undefined function Drupal\system\Tests\Upgrade\language_negotiation_include()
I think I've seen that before, can't remember where.
Comment #32
aspilicious CreditAttribution: aspilicious commentedCore is broken cause of a missing contact.settings.yml file. And missing config files lead to this error in upgrade tests.
Comment #33
catch#27: drupal-1700682-27.patch queued for re-testing.
Comment #34
sunThis is getting a bit exasperating. Correcting all those tests throughout core is nice, but can you explain how that fixes the topic of this issue?
Comment #35
tim.plunkettIf the classes are abstract, run-tests.sh will happily ignore them. Because PHP won't let it do anything but ignore it.
The only error run-tests.sh has ever given on this topic is when a non-abstract class with a missing getInfo is run.
Those errors should continue to cause fatals, because that is an invalid test class.
Comment #36
sunWhich code makes run-tests.sh ignore them?
Comment #37
tim.plunkettCompromise. Combines #18 and #27, without the duplicated hunk in run-tests.sh.
Comment #38
sunFine with me.
Comment #39
Dries CreditAttribution: Dries commentedThis looks good but the patch no longer applies. Asking for a re-roll:
Not sure why this is 'major'. Should probably be 'normal', unless explained otherwise.
Comment #40
tim.plunkettConflicted with #1380958: Replace $modules list for WebTestBase::setUp() with ::$modules class properties. It will also conflict with the list of patches in #1711070: Convert tests to use ::$modules property instead of parent::setUp($modules), so if it's okay with sun, I'm going to postpone this.
Comment #41
sunRe-rolled against HEAD. There shouldn't be many conflicts either way. We definitely need to fix the test runner script.
Comment #42
tim.plunkettYeah, and those other issues have to all be rerolled it turns out for doc blocks, proceed!
Comment #43
Dries CreditAttribution: Dries commentedCommitted to 8.x. Thanks!
Comment #44
sunComment #45
Eric_A CreditAttribution: Eric_A commentedIt appears this killed d.o. contrib testing. Would that be a --file option issue or a PIFR issue?
On a side note: for the --file option the abstract classes were already being excluded by regex.
Comment #46
sunhuh?
Can you clarify where this test is located? http://drupal.org/project/chessboard_filter yields a 404.
Comment #47
Eric_A CreditAttribution: Eric_A commentedThe test is here: http://qa.drupal.org/pifr/test/310618 (Chessboard Filter is a module in the Chessboard project: drupal.org/project/chessboard)
But how about a reasoning like this: my test class cannot be auto-loaded here unless the namespace is registered and that won't happen until the module is enabled. The module will not be enabled until the test class object is alive.
So the code block that deals with the --file option needs to call simpletest_classloader_register() just like simpletest_test_get_all() does.
EDIT: Though it does not make much sense to register disabled modules namespaces when you're not going to run all tests but just the ones from the explicitely passed (PSR-0) files.
Comment #48
sunThat's an excellent analysis, @Eric_A.
The root cause for that is actually not this issue/patch, but much rather #1683884: Update, simplify, and speedup run-tests.sh for PSR-0, and allow to run all tests of a module
Essentially, this patch here unintentionally revealed that some PSR-0 test classes may not be loadable, and run-tests.sh (unintentally) throws an appropriate error now.
Comment #49
xjmThis same error shows up in the log for Views on QA:
Comment #50
xjmI confirmed checking out the commit before the one in this issue allows views tests to be run again. It is not possible to run any views tests with this patch.
Can we revert this commit until we sort the issue out?
Comment #51
xjmActually, rather than reverting it, let's just revert the change to
run-tests.sh
. The rest is legit.Comment #52
xjmAnd next time let's please test the script manually before committing changes to it. :)
Comment #54
tim.plunkettI did test this manually, and it worked fine.
I think this might be a PHP version issue?
I'm using 5.3.13, can someone test with 5.3.3?
Comment #55
xjmI have 5.3.6 and get the same error as on the bot. Checking the bot's php version in #1635240-4: Disregard -- patch testing issue ☢.
Comment #56
xjmSo I don't think this is actually related to the PHP version; just to what modules are enabled in the parent environment. The classes are not detected when (in our case) views and ctools are disabled.
Comment #57
xjmEarlier fail was a bot goof.
Comment #58
xjmSteps to test manually:
run-tests.sh
command to run a test from the module, e.g.:You should get an error like:
Comment #59
sunSee #1683884-9: Update, simplify, and speedup run-tests.sh for PSR-0, and allow to run all tests of a module for the proper (quick) fix.
Comment #60
xjmCan we clarify what, exactly, the purpose of the hunk that the patch in #52 reverts is? Steps to test manually?
Comment #61
jthorson CreditAttribution: jthorson commentedVerified via scratchtestbot that #52 does get the tests running for Views and Ctools, but Chessboard still failed with "Class not found" errors. Core passed during my manual tests as well.
Still, re-enabling testing for 'some' modules is slightly better than the current 'no' modules; so would agree with rolling back the patch in #52 for now,
with the caveat that this issue remain open until i) a new patch is provided which addresses the root issue for both core and contrib, or ii) the issues with the Chessboard failures can be explained and attributed to an unrelated issue.Edit: Chessboard is running and passing, so must have been an issue with my testing environment. Also, based on http://qa.drupal.org/pifr/test/312233, it appears that the abstract classes are being ignored properly ... so retracting the caveats above.
Comment #62
webchickThanks a lot for all of the hard work on the testing. I've committed and pushed #52 to 8.x in order to re-enable contributed module testing. Marking needs work.
I'd also love to know the answer to xjm's queries in #60, since reading through this issue was pretty confusing and I'm still not completely sure what's being fixed here. And, assuming this is fixing a legit bug, it seems like the kind of thing we ought to add test coverage for, if we can.
Comment #63
xjmSo:
http://qa.drupal.org/pifr/test/312233
The module includes the following classes:
As you can see in the results, it attempts to run non-abstract, broken "base" classes
NonAbstractWithMethodTestBase
andNonAbstractTestBase
, as well as all the child classes; however, it does not attempt to runAbstractWithMethodTestBase
norAbstractTestBase
. This is with #52 already applied.So, making base classes abstract (as they should be anyway) resolves the issue as far as I can tell. It did in views.
Comment #64
xjmOops, xpost (though as mentioned in IRC, I'm not sure that this is testable programmatically).
Comment #65
xjmComment #66
John_B CreditAttribution: John_B commentedNote on above syntax examples: for me, back slashes are stripped from class names specified with flag --class unless the class name is enclosed in quotation marks.
Comment #67
sunThis was seemingly fixed a long time ago already. If there's anything that needs a follow-up, let's create a separate issue.