function WorkAllocator::process

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/TestTools/TestRunner/WorkAllocator.php \Drupal\TestTools\TestRunner\WorkAllocator::process()

Allocates tests to workers.

1 call to WorkAllocator::process()
WorkAllocator::__construct in core/tests/Drupal/TestTools/TestRunner/WorkAllocator.php

File

core/tests/Drupal/TestTools/TestRunner/WorkAllocator.php, line 80

Class

WorkAllocator
Allocates available tests to test workers.

Namespace

Drupal\TestTools\TestRunner

Code

private function process() : void {
  // Merge the tests from all groups into a unique list, since tests may
  // appear in more than one group, and weigh them.
  $tests = array_merge(...array_values($this->groupedTestClassInfoList));
  $slowTests = $this->groupedTestClassInfoList['#slow'] ?? [];
  foreach ($tests as $class => &$test) {
    $test['weight'] = $test['tests_count'] * (isset($slowTests[$class]) ? self::SLOW_TEST_WEIGHT : 1);
  }
  unset($test);
  // Sort all tests.
  $this->sortTestsByTypeAndWeight($tests);
  $this->sortedList = $tests;
  $this->assignTestsSequence($this->sortedList, 'sorted_sequence');
  // If the tests are not being run in parallel, the sorted list is enough.
  if ($this->totalBins <= 1) {
    $this->allocatedList = $this->sortedList;
    $this->assignTestsSequence($this->allocatedList, 'worker_sequence');
    return;
  }
  $binnedTests = $this->placeTestsIntoBins($this->sortedList);
  $this->allocatedList = $binnedTests[$this->binIndex - 1];
  $this->assignTestsSequence($this->allocatedList, 'worker_sequence');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.