Unverified Commit 3cf29653 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3487826 by catch: package_manager kernel tests are slow

(cherry picked from commit fa75872d)
parent 42402ecb
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -182,7 +182,7 @@ variables:

'⚙️️ PHPUnit Kernel':
  <<: [ *with-composer, *run-tests, *default-job-settings ]
  parallel: 4
  parallel: 5
  variables:
    TESTSUITE: PHPUnit-Kernel
    KUBERNETES_CPU_REQUEST: "8"
+2 −1
Original line number Diff line number Diff line
@@ -14,12 +14,13 @@ final class ActiveFixtureManipulator extends FixtureManipulator {
  /**
   * {@inheritdoc}
   */
  public function commitChanges(?string $dir = NULL): void {
  public function commitChanges(?string $dir = NULL, bool $validate_composer = FALSE): self {
    if ($dir) {
      throw new \UnexpectedValueException("$dir cannot be specific for a ActiveFixtureManipulator instance");
    }
    $dir = \Drupal::service(PathLocator::class)->getProjectRoot();
    parent::doCommitChanges($dir);
    return $this;
  }

}
+25 −7
Original line number Diff line number Diff line
@@ -303,8 +303,10 @@ public function setCorePackageVersion(string $version): self {
   *
   * @param array $additional_config
   *   The configuration to add.
   * @param bool $update_lock
   *   Whether to run composer update --lock. Defaults to FALSE.
   */
  public function addConfig(array $additional_config): self {
  public function addConfig(array $additional_config, bool $update_lock = FALSE): self {
    if (empty($additional_config)) {
      throw new \InvalidArgumentException('No config to add.');
    }
@@ -330,17 +332,23 @@ public function addConfig(array $additional_config): self {
      $command[] = $value;
      $this->runComposerCommand($command);
    }
    if ($update_lock) {
      $this->runComposerCommand(['update', '--lock']);
    }

    return $this;
  }

  /**
   * Commits the changes to the directory.
   *
   * @param string $dir
   *   The directory to commit the changes to.
   */
  public function commitChanges(string $dir): void {
  public function commitChanges(string $dir): self {
    $this->doCommitChanges($dir);
    $this->committed = TRUE;
    return $this;
  }

  /**
@@ -367,7 +375,11 @@ final protected function doCommitChanges(string $dir): void {
    }
    $this->committed = TRUE;
    $this->committingChanges = FALSE;
    $this->validateComposer();
  }

  public function updateLock(): self {
    $this->runComposerCommand(['update', '--lock']);
    return $this;
  }

  /**
@@ -623,8 +635,12 @@ private function addRepository(array $package): string {

  /**
   * Sets up the path repos at absolute paths.
   *
   * @param bool $composer_refresh
   *   Whether to run composer update --lock && composer install. Defaults to
   *   FALSE.
   */
  public function setUpRepos(): void {
  public function setUpRepos($composer_refresh = FALSE): void {
    $fs = new SymfonyFileSystem();
    $path_repo_base = \Drupal::state()->get(self::PATH_REPO_STATE_KEY);
    if (empty($path_repo_base)) {
@@ -638,8 +654,10 @@ public function setUpRepos(): void {
    // repos at the absolute path.
    $composer_json = file_get_contents($this->dir . '/packages.json');
    assert(file_put_contents($this->dir . '/packages.json', str_replace('../path_repos/', "$path_repo_base/", $composer_json)) !== FALSE);
    if ($composer_refresh) {
      $this->runComposerCommand(['update', '--lock']);
      $this->runComposerCommand(['install']);
    }
  }

}
+1 −1
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ public function begin(PathInterface $activeDir, PathInterface $stagingDir, ?Path
  /**
   * {@inheritdoc}
   */
  public function commitChanges(string $dir): void {
  public function commitChanges(string $dir, bool $validate_composer = FALSE): self {
    throw new \BadMethodCallException('::commitChanges() should not be called directly in StageFixtureManipulator().');
  }

+2 −2
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ public function testPreCreate(): void {
        "drupal/dummy_scaffolding",
        "drupal/dummy_scaffolding_2",
      ],
    ])->commitChanges();
    ])->commitChanges()->updateLock();

    $result = ValidationResult::createError(
      [
@@ -47,7 +47,7 @@ public function testPreApply(): void {
        'extra.drupal-scaffold.allowed-packages' => [
          "drupal/dummy_scaffolding",
        ],
      ]);
      ], TRUE);

    $result = ValidationResult::createError(
      [
Loading