Closed (won't fix)
Project:
X Autoload
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
24 Aug 2012 at 17:52 UTC
Updated:
24 Dec 2013 at 16:02 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
donquixote commentedSo this should be part of X Autoload? Cool! I'm curious for your patch.
(xautoload has its own tests in .test, as far as i remember. but this is going to stay this way, because tests should still work if xautoload does not)
Comment #2
berdirWell, I tried ;)
The attached patch does expose test classes to Simpletest, you can select and start them through the UI.
However, running them doesn't work, not exactly sure why. There are also a bunch of other problems, notably that we'd have to register the autoloader for disabled modules (you can run tests of disabled modules, important for testbot). And speaking of testbot, that one would of course have to have xautoload enabled on the test environment.
So, this is probably not going to fly any time soon, but here's the patch in case someone wants to play with it.
Comment #3
donquixote commentedDo the classes fail to load?
Technically this should be possible, e.g. with a custom plugin/handler. Of course this is more work.
Comment #4
berdirI just had a messed up installation (pro tip: simpletest and redis cache don't like each other), I guess it should actually work.
Will do another try later...
Comment #5
donquixote commentedIt is hook_simpletest_alter(), not simplenews
Comment #6
donquixote commented#2 works for me.
New patch with an example unit test case.
Comment #7
donquixote commentedThis is good enough to commit to the -dev version.
(esp, seems to be regression-free)
http://drupalcode.org/project/xautoload.git/commitdiff/ca4b5fb309faccbed...
http://drupalcode.org/project/xautoload.git/commitdiff/a4840161a1d800ece...
Further improvements (code style, documentation, bugfixes) can be done as follow-up.
(by reopening this issue)
Thanks Berdir for proposing this!
Comment #8
donquixote commentedThat's the next thing we need to do.
I am confident we can fix this!
Comment #9
donquixote commentedFixed!
Step 1:
Let simpletest register a handler to load test classes of disabled modules.
http://drupalcode.org/project/xautoload.git/commitdiff/56c39148bfe7653e7...
Step 2:
Add an example module to demonstrate the loading of test classes in disabled modules.
http://drupalcode.org/project/xautoload.git/commit/ed83d29667e9058c915b4...
Comment #10
donquixote commented@Berdir,
any other problems?
Comment #11
donquixote commentedNext step:
From #1693398-14: Allow PSR-0 test classes to be used in D7 (followups)
Comment #12
berdirYay for pushing this forward, would be nice if we could support PSR-0 tests on the testbot.
It's still being discussed in core what exactly should be registered, currently all but that is causing problems with plugins curently. But we should probably follow what core does.
Once this is working fine, we can talk with rfay/jthorson if they're interested to deploy this module on the testbot. I think they have the possibility to do something like this.
Comment #13
donquixote commentedJust found in D8 there is
core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php
This means that yes, we should also scan subfolders of ../Tests/ !
So far I thought that's not supposed to happen.
Easy change, I guess.
Comment #14
xanoPolite bump. How close is the 7.x-2.x to full support?
Comment #15
donquixote commentedxautoload simpletest support is working ok for local test runs.
Known issues:
You could patch D7 core to fix this: #1693398-20: Allow PSR-0 test classes to be used in D7 (followups)
But if you are sane, you already use drush, and don't need those shell scripts.
The problem: Testbot does not enable xautoload for finding those tests, and thus all the hook_simpletest_alter() does not help for automated module testing on drupal.org.
See #1693398: Allow PSR-0 test classes to be used in D7 (followups). I tried to bring xautoload into the discussion, but people were not convinced.
I personally think we should patch the testbot rather than Drupal core. So the testbot should install/enable xautoload (or any contrib module) to find the PSR-0 tests.
Unfortunately, I have no idea how the testbot works, and have no time to study it.
http://drupalcode.org/project/project_issue_file_review.git/tree/refs/he...
This thing looks big. I would not know where to start.
Comment #16
donquixote commentedBtw, to circumvent all of this testbot crazyness, we could do the following:
A drush command to create a file modulename.generated.test
This file would contain stuff like
So you could work on the tests in PSR-0, and
Drupaltestbot would still detect them in the traditional way.Comment #17
xanoIf a module Foo specifies X Autoload as one of its dependencies, then installing Foo during a test should also automatically install X Autoload.This doesn't work this way for disabled modules.Also, pifr_simpletest.client.inc contains
pifr_client_review_pifr_simpletest::findTestFiles(), which can scan for D7 and D8 style test classes. I haven't looked at it into great detail, but it looks like this works regardless of the core version a module is compatible with.Comment #18
donquixote commented#17
Interesting, thanks for exploring!
Can you play with this and confirm that it gets as far as to find those tests?
Btw, I am totally confused why all pifr branches are labeled 6.x-*, while the instructions tell me to install it on a D7 site..
Comment #19
berdir#17: No, that does not help.
We need this module to be enabled in the parent site, so that it is triggered and the files are added to the registry and available for testing.
The dependency should allow it to be relatively simple. PIFR just needs to check if the module exists and if yes, enable it.
Comment #20
donquixote commentedYou mean the D7 core autoload registry?
If the test classes are already in the registry, we don't need any xautoload or classloader anymore.
(xautoload or classloader may still be enabled at a later stage during the test, but that's a different story)
Would it be an option to let PIFR alter the D7 core autoload registry?
(and I still don't understand if PIFR is to run on a D6 or a D7 site..)
Comment #21
berdirRight now, PIFR still runs on 6.x which means this is not possible anyway right now.
The port to 7.x is ongoing
Comment #22
xanoYou mean the findTestFiles() method? If so, why? I read the other issue, but I may be missing something.
Comment #23
donquixote commentedI would assume that findTestFiles() already does what we want, that is, finding those tests. Independent of the Drupal version.
It would be great if someone can confirm that :)
But then it fails at making those test classes autoload, because at the time this would need to happen, xautoload is not enabled.
Comment #24
donquixote commentedBerdir,
#1693398-29: Allow PSR-0 test classes to be used in D7 (followups)
I am now in favor of doing this all in core, with a custom PSR-0 loader only for test classes.
I'd like to get some feedback over there :)
It is generally difficult for a module to have tests about itself, if the testing module depends on it. So this is good news for xautoload.
Comment #25
donquixote commentedThe core issue now has a patch which is green and awesome and wants to be reviewed.
#1693398-91: Allow PSR-0 test classes to be used in D7 (followups)
Comment #25.0
donquixote commentedIt is simpletest, not simplenews :)
Comment #26
donquixote commentedThis is now implemented in D7 core, so the simpletest integration can be removed in the upcoming xautoload-7.x-4.x
Comment #27
donquixote commentedThis qualifies as wontfix since #1693398: Allow PSR-0 test classes to be used in D7 (followups).
hook_simpletest_alter() is still in xautoload 7.x-3.x, but has been removed in 7.x-4.x.