Verified Commit 3307cfb8 authored by Jess's avatar Jess
Browse files

Issue #3400485 by googletorp, nod_:...

Issue #3400485 by googletorp, nod_: LibraryDependencyResolver::getMinimalRepresentativeSubset() calculates dependencies incorrectly

(cherry picked from commit c0895d57)
parent 8b02a7cb
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -86,7 +86,7 @@ public function getMinimalRepresentativeSubset(array $libraries) {
    foreach ($libraries as $library) {
      $with_deps = $this->getLibrariesWithDependencies([$library]);
      // We don't need library itself listed in the dependencies.
      $all_dependencies += array_diff($with_deps, [$library]);
      $all_dependencies = array_unique(array_merge($all_dependencies, array_diff($with_deps, [$library])));
    }

    return array_values(array_diff($libraries, array_intersect($all_dependencies, $libraries)));
+4 −0
Original line number Diff line number Diff line
@@ -41,9 +41,11 @@ class LibraryDependencyResolverTest extends UnitTestCase {
    'no_deps_a' => ['js' => [], 'css' => []],
    'no_deps_b' => ['js' => [], 'css' => []],
    'no_deps_c' => ['js' => [], 'css' => []],
    'no_deps_d' => ['js' => [], 'css' => []],
    'deps_a' => ['js' => [], 'css' => [], 'dependencies' => ['test/no_deps_a']],
    'deps_b' => ['js' => [], 'css' => [], 'dependencies' => ['test/no_deps_a', 'test/no_deps_b']],
    'deps_c' => ['js' => [], 'css' => [], 'dependencies' => ['test/no_deps_b', 'test/no_deps_a']],
    'deps_d' => ['js' => [], 'css' => [], 'dependencies' => ['test/no_deps_d']],
    'nested_deps_a' => ['js' => [], 'css' => [], 'dependencies' => ['test/deps_a']],
    'nested_deps_b' => ['js' => [], 'css' => [], 'dependencies' => ['test/nested_deps_a']],
    'nested_deps_c' => ['js' => [], 'css' => [], 'dependencies' => ['test/nested_deps_b']],
@@ -139,6 +141,8 @@ public function providerTestGetMinimalRepresentativeSubset() {
      [['test/deps_b', 'test/deps_a'], ['test/deps_b', 'test/deps_a']],
      [['test/deps_b', 'test/deps_c'], ['test/deps_b', 'test/deps_c']],
      [['test/deps_c', 'test/deps_b'], ['test/deps_c', 'test/deps_b']],
      [['test/deps_a', 'test/deps_d', 'test/no_deps_a'], ['test/deps_a', 'test/deps_d']],
      [['test/deps_a', 'test/deps_d', 'test/no_deps_d'], ['test/deps_a', 'test/deps_d']],
      // Multi-level (indirect) dependencies.
      [['test/nested_deps_a'], ['test/nested_deps_a']],
      [['test/nested_deps_b'], ['test/nested_deps_b']],