Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow running generate_testsuites.php from a different dir #11155

Merged
merged 1 commit into from
Feb 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 8 additions & 15 deletions bin/ci/generate_testsuites.php
Original file line number Diff line number Diff line change
@@ -2,46 +2,39 @@

declare(strict_types=1);

if (count($argv) < 2) {
$number_of_chunks = count($argv) === 2 ? (int) $argv[1] : 0;
if ($number_of_chunks <= 0) {
fwrite(STDERR, 'Usage: ' . $argv[0] . ' <number_of_chunks>' . PHP_EOL);
exit(1);
}

$number_of_chunks = (int) $argv[1];
if ($number_of_chunks === 0) {
fwrite(STDERR, 'Usage: ' . $argv[0] . ' <number_of_chunks>' . PHP_EOL);
exit(1);
}
$root = dirname(__DIR__, 2) . DIRECTORY_SEPARATOR;

// find tests -name '*Test.php'
$files = iterator_to_array(
new RegexIterator(
new RecursiveIteratorIterator(
new RecursiveDirectoryIterator(
'tests',
$root . 'tests',
FilesystemIterator::CURRENT_AS_PATHNAME|FilesystemIterator::SKIP_DOTS,
),
RecursiveIteratorIterator::LEAVES_ONLY,
),
'/.*Test.php$/',
'/Test\\.php$/',
),
);

mt_srand(4); // chosen by fair dice roll.
// guaranteed to be random.
// -- xkcd:221

$order = array_map(
fn(): int => mt_rand(),
$files,
);
$order = array_map(fn(): int => mt_rand(), $files,);
array_multisort($order, $files);

$chunks = array_chunk($files, (int) ceil(count($files) / $number_of_chunks));

$phpunit_config = new DOMDocument('1.0', 'UTF-8');
$phpunit_config->preserveWhiteSpace = false;
$phpunit_config->load('phpunit.xml.dist');
$phpunit_config->load($root . 'phpunit.xml.dist');
$suites_container = $phpunit_config->getElementsByTagName('testsuites')->item(0);

while ($suites_container->firstChild) {
@@ -58,4 +51,4 @@
}

$phpunit_config->formatOutput = true;
$phpunit_config->save('phpunit.xml');
$phpunit_config->save($root . 'phpunit.xml');

Unchanged files with check annotations Beta

/** @var int<0, max> */
public const SHORTCODE = 0;
public ?string $dupe_key = null;

Check failure on line 20 in src/Psalm/Issue/CodeIssue.php

GitHub Actions / Check backward compatibility

Type of property Psalm\Issue\CodeIssue#$dupe_key changed from having no type to string|null

Check failure on line 20 in src/Psalm/Issue/CodeIssue.php

GitHub Actions / Check backward compatibility

Type of property Psalm\Issue\CodeIssue#$dupe_key changed from having no type to string|null

Check failure on line 20 in src/Psalm/Issue/CodeIssue.php

GitHub Actions / Check backward compatibility

Type of property Psalm\Issue\CodeIssue#$dupe_key changed from having no type to string|null
public function __construct(
public readonly string $message,

Check failure on line 23 in src/Psalm/Issue/CodeIssue.php

GitHub Actions / Check backward compatibility

Type of property Psalm\Issue\CodeIssue#$message changed from having no type to string

Check failure on line 23 in src/Psalm/Issue/CodeIssue.php

GitHub Actions / Check backward compatibility

Type of property Psalm\Issue\CodeIssue#$message changed from having no type to string

Check failure on line 23 in src/Psalm/Issue/CodeIssue.php

GitHub Actions / Check backward compatibility

Type of property Psalm\Issue\CodeIssue#$message changed from having no type to string
public readonly CodeLocation $code_location,

Check failure on line 24 in src/Psalm/Issue/CodeIssue.php

GitHub Actions / Check backward compatibility

Type of property Psalm\Issue\CodeIssue#$code_location changed from having no type to Psalm\CodeLocation

Check failure on line 24 in src/Psalm/Issue/CodeIssue.php

GitHub Actions / Check backward compatibility

Type of property Psalm\Issue\CodeIssue#$code_location changed from having no type to Psalm\CodeLocation

Check failure on line 24 in src/Psalm/Issue/CodeIssue.php

GitHub Actions / Check backward compatibility

Type of property Psalm\Issue\CodeIssue#$code_location changed from having no type to Psalm\CodeLocation
) {
}
public function __construct(
string $message,
CodeLocation $code_location,
public string $property_id,

Check failure on line 14 in src/Psalm/Issue/PropertyIssue.php

GitHub Actions / Check backward compatibility

Type of property Psalm\Issue\PropertyIssue#$property_id changed from having no type to string
) {
parent::__construct($message, $code_location);
}