Problem/Motivation

There are multiple tests that install/uninstall all core modules.
This list should exclude contrib, hidden, testing, and experimental modules.
So far each test has manually performed this filter, and each has forgotten experimental modules in the initial version.
Then I've written a new experimental module and broken this test, and fixed each.

Proposed resolution

Provide a helper method for this!

Remaining tasks

N/A

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Comments

tim.plunkett created an issue. See original summary.

tim.plunkett’s picture

Status: Active » Needs review
Issue tags: +blocker
StatusFileSize
new4.69 KB

This blocks the Layout initiative, since it will provide a field type plugin, causing FieldDefinitionIntegrityTest to fail.

dawehner’s picture

+++ b/core/tests/Drupal/KernelTests/KernelTestBase.php
@@ -1084,6 +1084,24 @@ protected function isTestInIsolation() {
   /**
+   * Gets all core modules.
+   *
+   * Excludes contrib, hidden, experimental, already enabled modules, and
+   * modules in the Testing package.
+   *
+   * @return \Drupal\Core\Extension\Extension[]
+   *   Array of all core modules and their data.
+   */
+  protected function getCoreModules() {
+    return array_filter(system_rebuild_module_data(), function ($module) {
+      if ($module->origin !== 'core' || !empty($module->info['hidden']) || $module->status == TRUE || $module->info['package'] == 'Testing' || $module->info['package'] == 'Core (Experimental)') {
+        return FALSE;
+      }
+      return TRUE;
+    });
+  }

Is this something we could provide on the level of a trait so BrowserTestBase can use it as well?

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

borisson_’s picture

Status: Needs review » Needs work

A trait would be a good idea. I agree, setting to needs work based on #3

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

tim.plunkett’s picture

Status: Needs work » Needs review
StatusFileSize
new12.09 KB
new13.17 KB

Addressed #3
Interdiff not super helpful, as it's on top of a reroll.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

Setting this to rtbc. I have one minor nitpick but that is not nearly enough to set this back to nw.

+++ b/core/tests/Drupal/Tests/Traits/Core/ModuleTrait.php
@@ -0,0 +1,37 @@
+      $return = $module->origin === 'core'
+        && empty($module->info['hidden'])
+        && $module->status == FALSE
+        && $module->info['package'] !== 'Testing'
+        && $module->info['package'] !== 'Core (Experimental)';
+      return $return;

This doesn't have to go in an intermediary variable and it could be returned without it.

wim leers’s picture

Issue tags: +Blocks-Layouts

Looks great!

tim.plunkett’s picture

Issue summary: View changes
StatusFileSize
new12.01 KB
new1.04 KB

Okay #9 was bugging me, good point. Leaving RTBC

alexpott’s picture

Status: Reviewed & tested by the community » Needs review
Related issues: +#2656994: Experimental modules should have their own version numbers

Hmm... I wrote a comment on this yesterday and dug out an issue but somehow it got lost.

I think there is a big difference between a beta stability experimental module and an alpha. Beta ones need to pass these tests - alphas we could exclude them. So for me we should be doing #2656994: Experimental modules should have their own version numbers first.

tim.plunkett’s picture

We have 7 implementations here. 4 do not care about experimental and 3 do.
I'd *really* like to not get this blocked on that other issue that has sat untouched for almost 3 years.
Should we add two methods? One with a boolean flag?

alexpott’s picture

@tim.plunkett I think adding a boolean to include them and then preserving the status quo is a good way to go. We can then expand this argument to accept a string representing an experimental module stability in #2656994: Experimental modules should have their own version numbers.

That way we get the DRY and improved module selection now (ie. making it easier to exclude non-core modules) and incrementally improve this when possible.

+++ b/core/tests/Drupal/Tests/Traits/Core/ModuleTrait.php
@@ -0,0 +1,33 @@
+    return array_filter(system_rebuild_module_data(), function (Extension $module) {

system_rebuild_module_data() is deprecated.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mile23’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

During the bootstrap process, core/test/bootstrap.php finds extensions so it can discover their tests: https://git.drupalcode.org/project/drupal/blob/8.8.x/core/tests/bootstra...

So you can call drupal_phpunit_contrib_extension_directory_roots() in some circumstances. But it would be better to have a helper class that knows how to do this and isn't ever going to be the system under test. That could then be used by tests, and also replace the code in bootstrap.php.

+++ b/core/tests/Drupal/Tests/Traits/Core/ModuleTrait.php
@@ -0,0 +1,33 @@
+    return array_filter(system_rebuild_module_data(), function (Extension $module) {

system_rebuild_module_data() is the system under test, and it also is replaced by a service so for instance under unit tests it won't be available. #2926068: Deprecate system_rebuild_module_data() and remove usages in core

vacho’s picture

Issue tags: -Needs reroll
StatusFileSize
new12.01 KB

By now only patch reroll

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

rpsu’s picture

rpsu’s picture

This would most likely need to skip also deprecated core modules. How they should be identified, currently there is no means for it (apart just listing them as in #3062281: Deprecate block_place module for removal in Drupal 9 in trait Drupal\Tests\DeprecatedModulesTestTrait.

Would it make sense to add an optional key to .info.yml files (deprecated: TRUE as the first thing from the top of my head)?

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.