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
- Tests of contributed modules for D8 using the PSR-0 namespace/directory structure are not found (and thus not executed) at all.
Details
- E.g., Link 8.x-1.x: http://qa.drupal.org/pifr/test/297448 review log says:
Command [php -l -f './sites/default/modules/link/lib/Drupal/link/Tests/LinkFieldCRUDTest.php' 2>&1] succeeded. ... Command [/usr/bin/php ./core/scripts/run-tests.sh --concurrency 8 --php /usr/bin/php --url 'http://drupaltestbot654-mysql/checkout' --file --clean 2>&1] succeeded. No Simpletest tests found. Skipping execution of run_tests.sh. Command [/usr/bin/php ./core/scripts/run-tests.sh --php /usr/bin/php --url 'http://drupaltestbot654-mysql/checkout' --file --list 2>&1] succeeded. Review complete. test_id=297448 result code=10 details=Array
- @dawehner apparently reported the identical bug to me some weeks ago (regarding Views for D8).
Comment | File | Size | Author |
---|---|---|---|
#13 | project_issue_file_review.module.13.patch | 2.32 KB | sun |
#11 | pifr.psr0_.11.patch | 4.94 KB | jthorson |
#3 | project_issue_file_review.psr0_.3.patch | 4.83 KB | sun |
#3 | interdiff.txt | 2.59 KB | sun |
#2 | project_issue_file_review.psr0_.2.patch | 5.69 KB | sun |
Comments
Comment #1
jthorson CreditAttribution: jthorson commentedThe current test detection algorithm is pretty crude ... IIRC, it looks for a ./tests directory off the root, and crawls through the module tree looking for any .test files.
Since the tests no longer have the extension .test, they are not picked up.
We'll need some new algorithm that can help us detect which .php files are tests and which aren't ... simply bringing in every file under every 'Tests' directory is probably not all that robust but could be a start.
Comment #2
sunI'm confident that this patch should do it.
That said, I'm also relatively sure that I have a typo somewhere (as usual)... ;) I don't have a real PIFR stack locally, just a checkout of project_issue_file_review.
Comment #3
sunIf we do not want to hard-code that many assumptions about extensions and their PSR-0 namespace directory paths, then we could also take a simpler route.
Essentially, checking for the minimal conditions only; i.e., the file extension must be .php and the file path must literally contain "/Tests/".
This has the potential of false-positives. But right now, I cannot think of any.
I'm suggesting this alternative approach, because it is possible that we're going to change the directory structure for extensions and PSR-0 files in the future. The chance for that to happen might be larger than the chance for a false-positive.
Thus, providing this as an alternative/simplified solution.
Comment #4
rfayI'm not actually sure that false positives do any damage. Could be wrong.
Comment #5
sunThat's possible, too. ;)
Can we apply this patch on a PIFR staging/test server or similar?
I'd love to resolve this issue ASAP, since it hinders a couple of core initiatives/efforts...
Comment #6
jthorson CreditAttribution: jthorson commentedDeployed on scratchtestbot, linked to qa.staging.devdrupal.org, and passed testbot confirmation.
I just now kicked off a 8.x branch test on qa.staging to see if it passes. Once that's complete, we should probably also kick off a branch test for a project containing PSR-0 tests, and see whether they're picked up.
I'm heading to bed before the core branch test completes, but anyone with access can attempt a contrib branch test on qa.staging if you want a result before I get back to it.
Comment #7
sunIf you need a contrib project with D8 code + tests: Link: http://qa.drupal.org/pifr/test/297448
Comment #8
jthorson CreditAttribution: jthorson commentedAppears to deliver as advertised ...
Now running it through the set below, to check for unexpected impacts.
Sanity checks complete:
- D8 core branch test
- D7 core branch test
- D6 core branch test
- D7 contrib branch test
- D6 contrib branch test
- D8 core patch test
Sanity checks todo:
- Non PSR-0 D8 contrib branch test
- D8 contrib patch test
- D7 core patch test
- D7 contrib patch test
- D6 core patch test
- D6 contrib patch test
Comment #9
jthorson CreditAttribution: jthorson commentedDuplicate of http://drupal.org/node/1642478 ... just need to determine which patch makes more sense.
Comment #10
sunThis is required nevertheless, but FWIW: #1683884: Update, simplify, and speedup run-tests.sh for PSR-0, and allow to run all tests of a module
Comment #11
jthorson CreditAttribution: jthorson commentedAs committed to 6.x-2.x (Commit ID 8424b54).
Comment #12
sunYay, you even filled in the documentation gaps :) Thank you!
That said, as soon as #1683884: Update, simplify, and speedup run-tests.sh for PSR-0, and allow to run all tests of a module lands for D8, we should be able to replace this entire code with a simple
That is, because it shouldn't be PIFR's job to figure this out in the first place ;)
Comment #13
sunFWIW, this would sorta be the follow-up patch for --module, but I'm not 100% sure yet whether it's safe to rely on the new option already.
Comment #14
aspilicious CreditAttribution: aspilicious commentedHmm there is still something going wrong...
Base test files that are abstract (but not rly defined as abstract) are added as real test files. That leads to fatals when searching for the getInfo() function.
http://qa.drupal.org/pifr/test/273938
Comment #15
jthorson CreditAttribution: jthorson commentedIf someone can define an algorithm for detecting what should or shouldn't be considered a 'real' test file, we can modify it ... for now, we could simply filter out any file with 'TestBase' in the name, but that feels more like 'workaround' than 'robust solution'.
Comment #16
sunMost probably we rather want to fix run-tests.sh instead.
Comment #17
aspilicious CreditAttribution: aspilicious commentedEverything without a getInfo() function is a base class. (I think)
Comment #18
sunI want to see this fixed in run-tests.sh + simpletest.module instead:
#1700682: run-tests.sh attempts to run abstract/base test classes