file_scan_ignore_directories is ignored in kernel tests

Created on 5 January 2021, almost 4 years ago
Updated 27 January 2023, almost 2 years ago

Problem/Motivation

Background: I have symlinks in my test builds and because of those, I have to leverage file_scan_ignore_directories configuration to convince \Drupal\Core\Extension\ExtensionDiscovery::scanDirectory() and anything that leverages ExtensionDiscovery to ignore symlinked directories.

Problem: All possible test-specific overrides and additions from settings.testing.php are completely ignored by KernelTestBase - even though it is not mentioned in the CR - and it probably make sense because we need a highly isolated test environment is kernel tests. Although if settings.testing.php exists and file_scan_ignore_directories is set I think at least that configuration should be applied on the "mocked" Settings object.

History: It seems Simpletest's KernelTestBase included all testing specific overrides: https://api.drupal.org/api/drupal/core!modules!simpletest!src!KernelTest...

Steps to reproduce

Proposed resolution

Either include ALL testing-specific overrides in kernel tests too or just leverage the file_scan_ignore_directories specific overrides from it.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Needs work

Version

10.1

Component
PHPUnit 

Last updated about 12 hours ago

Created by

🇭🇺Hungary mxr576 Hungary

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • @mxr576 thanks for the patch.

    I tried it after I met some issues on a project where Drupal is a package in a pnpm monorepo. Kernel tests were failing because of hardlinks:

    RuntimeException: SplFileInfo::openFile(/Users/alex/work/silverback-mono/apps/silverback-drupal/web/modules/contrib/test_session/tests/Cypress/node_modules/@-drupal/test_session/tests/Cypress/node_modules/@-drupal/test_session/tests/Cypress/node_modules/@-drupal/test_session/tests/Cypress/node_modules/@-drupal/test_session/tests/Cypress/node_modules/@-drupal/test_session/tests/Cypress/node_modules/@-drupal/test_session/tests/Cypress/node_modules/@-drupal/test_session/tests/Cypress/node_modules/@-drupal/test_session/tests/Cypress/node_modules/@-drupal/test_session/tests/Cypress/node_modules/@-drupal/test_session/tests/Cypress/node_modules/@-drupal/test_session/tests/Cypress/node_modules/@-drupal/test_session/tests/Cypress/node_modules/@-drupal/test_session/tests/Cypress/node_modules/@-drupal/test_session/tests/Cypress/node_modules/@-drupal/test_session/tests/Cypress/node_modules/@-drupal/test_session/tests/Cypress/node_modules/@-drupal/test_session/tests/Cypress/node_modules/@-drupal/test_session/tests/Cypress/node_modules/@-drupal/test_session/test_session.info.yml): Failed to open stream: Invalid argument
    

    Looks beautiful, right? :D

    So I tried the patch and found the following:

    1. There is a typo: setting.testing.php instead of settings.testing.php

    2. file_scan_ignore_directories should be set before Database::addConnectionInfo('default', 'test-runner', $this->getDatabaseConnectionInfo()['default']);. Otherwise, the error persists.

    3. I solved the two above issues, but found that tests run crazy slow. Even if they pass. So it looks like something else still scans the blackhole :)

    In the end I found another Drupal-unrelated solution. But maybe my findings will help someone.

  • 🇭🇺Hungary mxr576 Hungary

    @Leksat, Hi, thanks for the details. I have fixed what I could easily :) 2nd point needs further investigation.

    How do we do monorepo with Drupal has also changed recently, so I am not sure if we are still using this patch. I need to check.

Production build 0.71.5 2024