Closed (won't fix)
Project:
Project Issue File Review
Version:
6.x-3.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
23 May 2014 at 18:50 UTC
Updated:
25 Oct 2015 at 00:20 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
tim.plunkettThis is the relevant hunk:
http://cgit.drupalcode.org/project_issue_file_review/tree/review/simplet...
Comment #2
tim.plunkettIs this too hacky?
Also why don't we check for ending in Test.php?
That would help with other helper modules that are located in /tests/.
Comment #3
sunFWIW, PSR-4 PHPUnit tests can be uniquely identified, because they are contained in a
/tests/src/directory.It would make more sense to me to add that as an explicit condition...
That said, that entire code in PIFR predates the introduction of PHPUnit tests. — I'm surprised that PIFR runs any PHPUnit tests at all. That's pure coincidence.
IMO, we should stop trying to manually discover tests of a particular module in PIFR. Instead, this logic MUST be delivered by run-tests.sh itself. Testbots SHOULD just pass
--module page_manager(or alternatively, a file path to an extension).#1683884: Update, simplify, and speedup run-tests.sh for PSR-0, and allow to run all tests of a module did introduce some basic code for doing that already, but to my knowledge, it doesn't work correctly yet + PIFR doesn't use it yet.
The new test discovery code from #697760: Replace getInfo() in tests with native phpDoc + annotations (following PHPUnit) will certainly help with that, too.
Ultimately, PIFR shouldn't try to assume anything about the tests to run. Core should control the test suite.
Comment #4
tim.plunkettI can verify that
--module page_managerwith run-tests.sh works great, that was what I meant in the OP.+1 to just using that and not doing the discovery internally.
Comment #5
sunGlad to hear that it still works (- even though that code is not actively used nor tested in any way ;))
However, after learning about the filtering options supported by PHPUnit, I'm no longer sure whether adding the
--moduleoption in its current form was "right."--moduleobviously means it only works for modules.run-tests.sh --extension <path>That is, because
run-tests.shhas to perform anExtensionDiscoveryeither way, in order to register all available namespaces (because extensions are not necessarily installed/enabled).That discovery process merges the results of all extension types into a single list of available extensions either way already. (hard-coding the assumption that all extension names must be unique, regardless of type)
Therefore, a single
--extensionparameter could either point to an extension name or to its pathname. The former would be equal to the current--modulebehavior, the latter would be more in line with PHPUnit.How to move forward here:
--moduleto--extensionin Drupal core first.Comment #6
donquixote commented@sun (#3)
I agree with this approach, but don't know how much work this is going to be.
So I want to comment on Tim's patch in #2, which seems more promising for a quick solution. This could be temporary, but it would unblock #2247287: Drop automatic PSR-0 support for modules.
The correct discovery procedure for D8 would be to first look for modules (identified by modulename.info.yml), and then look for tests/src/ folders within these modules. Very similar to what the switch-psr4.sh script does. And probably any other discovery code we have in D8.
Important thing: We still need to support tests/Drupal/.. with PSR-0 for Drupal 7!
Maybe we could have dedicated methods for different Drupal versions, based on the *.info or *.info.yml files being discovered.
Not sure if this is really the correct approach, so I am posting some pseudocode before a patch.
Comment #7
drummComment #8
sunLarger changes (including the plan to replace this manual scan with native run-tests.sh functionality) should be handled separately.
Attached patch is same as @tim.plunkett's — just using
stripos()+ adjusting docs accordingly.Would be good to get this committed and deployed before DrupalCon.
Comment #9
tim.plunkettDuh! Way better :)
I have no means to test this, but it looks sane to me.
Comment #12
jthorson commentedThis should be live on all testbots within 30 minutes.
Comment #13
tim.plunkettI can confirm this works, https://qa.drupal.org/pifr/test/792378 now has all of the tests. Thanks!
Comment #14
donquixote commentedThis looks like it could lead to false positives.
It will assume that e.g. tests/modules/foo/src/Foo.php is seen as a test class, when in fact it is just a regular class within a test module.
What about this instead:
Comment #15
tim.plunkettWas this only deployed on some bots?
I've seen it work on the 24XX bots, but 1883 in particular is not working.
Comment #16
tim.plunkett2448 picks up phpunit, 1883 does not.
Guess it just needs deployment again?
Comment #17
jthorson commentedLooks like puppet wasn't pulling changes as intended ... should be working now.
Thanks for the report!
Comment #18
jthorson commentedNeeds review for followup in #14.
Comment #19
yesct commentedadding "infrastructure blocker for Drupal 8.0.0" tag, since this blocks the drupal 8 core issue: #2267715: [meta] Drupal.org (websites/infra) blockers to a Drupal 8 RC1, so that the infrastructure blockers to d8 release (in issue queues outside of the core queue) is accurate. Remove the blocker tag when this issue is fixed, and update 2267715.
Comment #20
MixologicI can give some definite examples of false positives. There have been about 49 tests that just bail out for the d7-3.x views module since this was implemented.
The issue that Im seeing is that there is a file under the views tests directory - /tests/templates/views-view--frontpage.tpl.php, which I believe is confusing the test runner because a. It is not a test. an b. run-tests.sh is looking for two dashes in a row to indicate an argument name, and doesnt know what to do with frontpage.tpl.php as an argument.
https://www.drupal.org/node/2456043 was the issue that brought a user to #drupal-infrastructure
https://qa.drupal.org/pifr/test/1005698 are the test results
https://www.drupal.org/node/2458143 issue filed about this bug.
https://www.drupal.org/node/2159347#comment-9486479 is another example where a d8 backport to d7 cant really be tested.
I think one of two things need to happen here. In the short term, can anybody who is savvy with views testing explain the /tests/templates/views-view--frontpage.tpl.php and if it needs to be there? I tried removing it and submitting a patch, and the testbots picked it up and ran it fine with five failures (https://qa.drupal.org/pifr/test/1005713)
Do we need to patch the regex in run-tests.sh?
Comment #21
dagmarSo, according the comments, of
findTestFilesin pifr_simpletest.client.inc there is no distintion for D7 and D8, so currently for D7 wach file with .php extension will be considered a test file.This file is there because views needs to test the template system inclussion. We could fix the inclusing by moving the template inside a
vendordirectory if this patch is not accepted.I'm including the
git diff -wouput on the 2273481-no-spaces.do-not-test.patch file to make easy to understand the code provided here.Comment #22
donquixote commentedImo it should use the same rigid logic as core test discovery. Why should we be overly permissive here?
Comment #23
dagmar@donquixote That code you mention came from #1674290: PSR-0 tests in contrib modules are not found
@sun explained his reasons here: https://www.drupal.org/node/1674290#comment-6207792
Comment #24
njbarrett commentedSeems like a simple solution to fix a big problem.
RTBC +1
Comment #25
njbarrett commentedComment #26
dawehnerdagmar++
So good to see you fixing actual problems out there!
Comment #27
MixologicRe #21 -
The code was expanded to support psr0/4 testing namespaces for d8 (https://www.drupal.org/node/1543796), but it also unintentionally added that support to d7. Im concerned that there may be examples of d7 modules that are using psr0/4 namespacing for their tests, and if we apply this patch it will disable testing for those modules.
Can we be sure there are no examples in contrib where somebody has added psr0/4 tests to D7 modules? I could probably create a working checkout of everything in the git repos to do a search, but that would take a fair amount of time for me to get to.
An alternate workaround to get this working in views, specifically, is to disable that one test that relies on that template file, or, alternately, put that template file in a 'test-assets' directory or something that isn't subordinate to a /Tests/ directory. (http://cgit.drupalcode.org/project_issue_file_review/tree/review/simplet...)
Comment #28
damienmckennaFYI in #2450447: Drupal QA is broken for Views 7.x-3.x dagmar posted a patch to move the test template file into a different subdirectory, I guess some guidance is needed to pick which direction should be taken.
Comment #29
damienmckennaAlso, I asked on twitter about D7 modules using PSR0/4 tests and was told that OpenLayers, VarDumper and Service Container do.
Comment #30
damienmckennaOne more: Commerce Discount: #2481201: Update and fix the tests!
Comment #31
damienmckennaAnother: Commerce Reports (per Matt Glaman)
Comment #32
MixologicPIFT/PIFR no longer need to fix this as it is now fixed in drupalci.
Drupalci will both find simpletest tests with the extension of .test, as well as any test files that end in .php that are found by the simpletest module itself.
When doing discovery of tests in drupalci, it explicitly excludes .tpl.php and .api.php files from files it thinks may be tests.
Additionally, the test discovery process for drupalci no longer uses the --file argument, so the -- in the filenames is no longer a problem.
yay.