jenkins-bot has submitted this change and it was merged.

Change subject: ResourceLoader: Test that all module dependencies are 
satisfiable
......................................................................


ResourceLoader: Test that all module dependencies are satisfiable

Whenever module A depends on module B, module B must exist.

Whenever module A depends on module B, the possible targets of A must
be a subset of targets of module B.

Bug: 64513
Change-Id: I9de291d20d08df2813eb55be9a1f7e5efd907d6f
---
M tests/phpunit/structure/ResourcesTest.php
1 file changed, 50 insertions(+), 1 deletion(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/phpunit/structure/ResourcesTest.php 
b/tests/phpunit/structure/ResourcesTest.php
index d7742a6..fbf70e2 100644
--- a/tests/phpunit/structure/ResourcesTest.php
+++ b/tests/phpunit/structure/ResourcesTest.php
@@ -37,7 +37,11 @@
                );
        }
 
-       public function testDependencies() {
+       /**
+        * Verify that nothing explicitly depends on the 'jquery' and 
'mediawiki' modules.
+        * They are always loaded, depending on them is unsupported and leads 
to unexpected behaviour.
+        */
+       public function testIllegalDependencies() {
                $data = self::getAllModules();
                $illegalDeps = array( 'jquery', 'mediawiki' );
 
@@ -53,6 +57,51 @@
        }
 
        /**
+        * Verify that all modules specified as dependencies of other modules 
actually exist.
+        */
+       public function testMissingDependencies() {
+               $data = self::getAllModules();
+               $validDeps = array_keys( $data['modules'] );
+
+               foreach ( $data['modules'] as $moduleName => $module ) {
+                       foreach ( $module->getDependencies() as $dep ) {
+                               $this->assertContains(
+                                       $dep,
+                                       $validDeps,
+                                       "The module '$dep' required by 
'$moduleName' must exist"
+                               );
+                       }
+               }
+       }
+
+       /**
+        * Verify that all dependencies of all modules are always satisfiable 
with the 'targets' defined
+        * for the involved modules.
+        *
+        * Example: A depends on B. A has targets: mobile, desktop. B has 
targets: desktop. Therefore the
+        * dependency is sometimes unsatisfiable: it's impossible to load 
module A on mobile.
+        */
+       public function testUnsatisfiableDependencies() {
+               $data = self::getAllModules();
+               $validDeps = array_keys( $data['modules'] );
+
+               foreach ( $data['modules'] as $moduleName => $module ) {
+                       $moduleTargets = $module->getTargets();
+                       foreach ( $module->getDependencies() as $dep ) {
+                               $targets = $data['modules'][$dep]->getTargets();
+                               foreach ( $moduleTargets as $moduleTarget ) {
+                                       $this->assertContains(
+                                               $moduleTarget,
+                                               $targets,
+                                               "The module '$moduleName' must 
not have target '$moduleTarget' "
+                                                       . "because its 
dependency '$dep' does not have it"
+                                       );
+                               }
+                       }
+               }
+       }
+
+       /**
         * Get all registered modules from ResouceLoader.
         */
        protected static function getAllModules() {

-- 
To view, visit https://gerrit.wikimedia.org/r/130024
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I9de291d20d08df2813eb55be9a1f7e5efd907d6f
Gerrit-PatchSet: 9
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <matma....@gmail.com>
Gerrit-Reviewer: Anomie <bjor...@wikimedia.org>
Gerrit-Reviewer: Aude <aude.w...@gmail.com>
Gerrit-Reviewer: Bartosz Dziewoński <matma....@gmail.com>
Gerrit-Reviewer: Hashar <has...@free.fr>
Gerrit-Reviewer: Hoo man <h...@online.de>
Gerrit-Reviewer: Jdlrobson <jrob...@wikimedia.org>
Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org>
Gerrit-Reviewer: Krinkle <krinklem...@gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: Ori.livneh <o...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to