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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jibran’s picture

Issue summary: View changes

I have also discussed this issue with @damiankloip and @dawehner at Drupalcon Amsterdam.

jibran’s picture

Project: Drupal.org Testbots » Drupal core
Version: » 8.0.x-dev
Component: unexplained test failure » extension system

Ok 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 modules sites/default/module/views_details and sites/default/module/views_details/tests/views_details_test_config in ViewTestData::createTestViews()
Moving this to core issue queue.

Berdir’s picture

I 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.

jibran’s picture

During the boot phase it loads the module perfectly but when I am in setup method it doesn't load the module.

Try to create a web test with a dependency on your module, it will fail.

so how do you suggest I fix it. It is certainly not a problem in D7.

Berdir’s picture

I have no idea how to fix it unfortunately, and yes, it is a D8 specific problem.

dawehner’s picture

So does that mean we should move this to some testbot queue?

jibran’s picture

No it is D8 bug see #2

Berdir’s picture

Right, 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.

Berdir’s picture

@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?

Arla’s picture

It 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).

Arla’s picture

Status: Active » Needs review
FileSize
612 bytes

@Berdir found a few lines in WebTestBase:

    // Save the original site directory path, so that extensions in the
    // site-specific directory can still be discovered in the test site
    // environment.
    // @see \Drupal\Core\SystemListing::scan()
    $settings['settings']['test_parent_site'] = (object) array(
      'value' => $this->originalSite,
      'required' => TRUE,
    );

Doing the same in KernelTestBase fixes it on my end.

jibran’s picture

All my views modules are broken right now. To test I have to fix those first please bear with me.

Berdir’s picture

Assigned: Unassigned » Jeff Burnz

You 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.

Berdir’s picture

Assigned: Jeff Burnz » Unassigned

Huh.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

@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.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Let's add a comment to explain why this is needed.

Berdir’s picture

If 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)

Arla’s picture

Title: Contrib can't load test views in ViewUnitTestBase » KernelTestBase ignores extensions in site-specific directories

Agreed, 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.

Berdir’s picture

Oh. 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.

Arla’s picture

Status: Needs work » Needs review
FileSize
1.5 KB
1.38 KB

Okay, except that the class reference in that comment was outdated with #2188661: Extension System, Part II: ExtensionDiscovery.

Berdir’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me, RTBC when green.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Bug fixes to test code are not frozen in beta. Committed 5a581dd and pushed to 8.0.x. Thanks!

  • alexpott committed 5a581dd on 8.0.x
    Issue #2372745 by Arla: KernelTestBase ignores extensions in site-...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.