Problem/Motivation
I have written some views tests for views_field_view, dynamic_entity_reference and views_details using ViewUnitTestBase. All the test are green locally but testbot is giving fatal for all the test runs
Fatal error: Call to a member function preview() on a non-object in /var/lib/drupaltestbot/sites/default/files/checkout/sites/default/modules/views_details/src/Tests/Plugin/StyleDetailsTest.php on line 49
FATAL Drupal\views_details\Tests\Plugin\StyleDetailsTest: test runner returned a non-zero error code (255).
I am trying to load a test veiw in the test.
$view = Views::getView('test_style_details');
on my local machine I can load the view just fine but not on the testbot. In D8 core all the class extending ViewUnitTestBase
loads views like this in tests but it is not possible for contrib.
See related issues for patches. These are the related test results.
https://qa.drupal.org/pifr/test/905193
https://qa.drupal.org/pifr/test/844468
https://qa.drupal.org/pifr/test/444653
Proposed resolution
*Unknown*
Remaining tasks
Fix the issue on test bot.
User interface changes
None
API changes
None
Comment | File | Size | Author |
---|---|---|---|
#20 | kerneltest-extensions-2372745-20.interdiff.txt | 1.38 KB | Arla |
#20 | kerneltest-extensions-2372745-20.patch | 1.5 KB | Arla |
#11 | 2372745-11.patch | 612 bytes | Arla |
Comments
Comment #1
jibranI have also discussed this issue with @damiankloip and @dawehner at Drupalcon Amsterdam.
Comment #2
jibranOk it not related to testbot I have moved my module to
sites/default/modules/
and I am able to produce the fail locally.drupal_get_path()
is returning an empty path for the modulessites/default/module/views_details
andsites/default/module/views_details/tests/views_details_test_config
inViewTestData::createTestViews()
Moving this to core issue queue.
Comment #3
BerdirI don't think this has anything to do with ViewsUnitTestBase and even less so with #1905334: Only load all modules when a hook gets invoked.
Apparently, *no* test modules inside tests folders in contrib modules are found on test bot, while it is working fine locally.
I've seen this in #2385503: Fix HEAD fails and also in search_api 8.x.
Try to create a web test with a dependency on your module, it will fail.
Comment #4
jibranDuring the boot phase it loads the module perfectly but when I am in setup method it doesn't load the module.
so how do you suggest I fix it. It is certainly not a problem in D7.
Comment #5
BerdirI have no idea how to fix it unfortunately, and yes, it is a D8 specific problem.
Comment #6
dawehnerSo does that mean we should move this to some testbot queue?
Comment #7
jibranNo it is D8 bug see #2
Comment #8
BerdirRight, I know about #2, but it works for us locally but it doesn't work on testbot.
Based on your description, it is the same for you.
To be able to fix it in core, we need to be able to reproduce it.
Comment #9
Berdir@dawehner just said that testbot still puts the module in sites/all/modules. Can you try to reproduce it if you do that as well locally?
Comment #10
ArlaIt seems the namespace-to-directory mapping for is incorrect when the module is in sites/default/modules (sites/all/modules seems to be fine). In #2385503: Fix HEAD fails we did
debug(\Drupal::service('container.namespaces'));
and saw paths like /var/lib/drupaltestbot/sites/default/files/checkout///src (where the triple slash should actually be the module path).Comment #11
Arla@Berdir found a few lines in WebTestBase:
Doing the same in KernelTestBase fixes it on my end.
Comment #12
jibranAll my views modules are broken right now. To test I have to fix those first please bear with me.
Comment #13
BerdirYou can't test this yourself on the testbot, we also can't write a test this in core I think, as we'd need a module in sites/default.
@Arla already verified that this works locally when you have a module with a kernel test in sites/default with this patch and not without
The only thing I can think of other than just committing it is trying to apply this patch for 8.x contrib tests to core automatically on the testbot, maybe jthorson can configure that somehow. Another way would be to configure testbot so that it puts modules in /modules on 8.x and not sites/default.
Comment #14
BerdirHuh.
Comment #15
dawehner@berdir
I guess this does not cause any kind of issues for other kernel tests so I really don't see a reason to not get it into core,
it helps contrib modules.
Comment #16
alexpottLet's add a comment to explain why this is needed.
Comment #17
BerdirIf we add a comment, we should add one to WebTestBase as well, that has the same line, also without comments AFAIK (or we would have copied them)
Comment #18
ArlaAgreed, the added line should have an explanation. There was actually a comment in WebTestBase, see the code quote in #11. I just wasn't sure that the exact same comment applies in KernelTestBase. But I guess it does?
Updating issue title.
Comment #19
BerdirOh. There's a german saying that goes like "Wer lesen kann ist klar im Vorteil" (He who can read has a clear advantage). True once more..
Yes, I think that is exactly the comment we want here.
Comment #20
ArlaOkay, except that the class reference in that comment was outdated with #2188661: Extension System, Part II: ExtensionDiscovery.
Comment #21
BerdirLooks good to me, RTBC when green.
Comment #22
alexpottBug fixes to test code are not frozen in beta. Committed 5a581dd and pushed to 8.0.x. Thanks!