Skip to content

List skipped extensions in run-tests.php #8363

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

Closed
wants to merge 13 commits into from
95 changes: 50 additions & 45 deletions run-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
+----------------------------------------------------------------------+
*/

/* $Id$ */

/* Temporary variables while this file is being refactored. */
/** @var ?JUnit */
$junit = null;
Expand Down Expand Up @@ -735,9 +733,9 @@ function main(): void
} else {
// Compile a list of all test files (*.phpt).
$test_files = [];
$exts_tested = count($exts_to_test);
$exts_skipped = 0;
$ignored_by_ext = 0;
$exts_tested = $exts_to_test;
$exts_skipped = [];
$ignored_by_ext = [];
sort($exts_to_test);
$test_dirs = [];
$optionals = ['Zend', 'tests', 'ext', 'sapi'];
Expand All @@ -748,11 +746,6 @@ function main(): void
}
}

// Convert extension names to lowercase
foreach ($exts_to_test as $key => $val) {
$exts_to_test[$key] = strtolower($val);
}

foreach ($test_dirs as $dir) {
find_files(TEST_PHP_SRCDIR . "/{$dir}", $dir == 'ext');
}
Expand Down Expand Up @@ -880,20 +873,19 @@ function write_information(): void
// load list of enabled and loadable extensions
save_text($info_file, <<<'PHP'
<?php
echo str_replace("Zend OPcache", "opcache", implode(",", get_loaded_extensions()));
$ext_dir = ini_get("extension_dir");
$exts = get_loaded_extensions();
$ext_dir = ini_get('extension_dir');
foreach (scandir($ext_dir) as $file) {
if (!preg_match('/^(?:php_)?([_a-zA-Z0-9]+)\.(?:so|dll)$/', $file, $matches)) {
continue;
}
$ext = $matches[1];
if (!extension_loaded($ext) && @dl($file)) {
echo ",", $ext;
if (preg_match('/^(?:php_)?([_a-zA-Z0-9]+)\.(?:so|dll)$/', $file, $matches)) {
if (!extension_loaded($matches[1]) && @dl($matches[1])) {
$exts[] = $matches[1];
}
}
}
?>
PHP);
$exts_to_test = explode(',', shell_exec("$php $pass_options $info_params $no_file_cache \"$info_file\""));
echo implode(',', $exts);
PHP);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably "detend" this line:

Suggested change
PHP);
PHP);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why? with the new change, the code has (as I would expect) no indentation

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sorry, what do you mean?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The closing PHP tag should match the indentation of the opening 'PHP'.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? The indentation is determined solely by the ending PHP tag.

You meant to remove 1 indentation more for whole nowdoc?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry, you're right. The indentation is fine as is.

$extensionsNames = explode(',', shell_exec("$php $pass_options $info_params $no_file_cache \"$info_file\""));
$exts_to_test = array_unique(remap_loaded_extensions_names($extensionsNames));
// check for extensions that need special handling and regenerate
$info_params_ex = [
'session' => ['session.auto_start=0'],
Expand Down Expand Up @@ -1051,9 +1043,9 @@ function find_files(string $dir, bool $is_ext_dir = false, bool $ignore = false)

while (($name = readdir($o)) !== false) {
if (is_dir("{$dir}/{$name}") && !in_array($name, ['.', '..', '.svn'])) {
$skip_ext = ($is_ext_dir && !in_array(strtolower($name), $exts_to_test));
$skip_ext = ($is_ext_dir && !in_array($name, $exts_to_test));
if ($skip_ext) {
$exts_skipped++;
$exts_skipped[] = $name;
}
find_files("{$dir}/{$name}", false, $ignore || $skip_ext);
}
Expand All @@ -1068,10 +1060,10 @@ function find_files(string $dir, bool $is_ext_dir = false, bool $ignore = false)
// (but not those starting with a dot, which are hidden on
// many platforms)
if (substr($name, -5) == '.phpt' && substr($name, 0, 1) !== '.') {
$testfile = realpath("{$dir}/{$name}");
if ($ignore) {
$ignored_by_ext++;
$ignored_by_ext[] = $testfile;
} else {
$testfile = realpath("{$dir}/{$name}");
$test_files[] = $testfile;
}
}
Expand Down Expand Up @@ -2026,7 +2018,7 @@ function run_test(string $php, $file, array $env): string
$ext_prefix = IS_WINDOWS ? "php_" : "";
$missing = [];
foreach ($extensions as $req_ext) {
if (!in_array(strtolower($req_ext), $loaded)) {
if (!in_array($req_ext, $loaded, true)) {
if ($req_ext == 'opcache' || $req_ext == 'xdebug') {
$ext_file = $ext_dir . DIRECTORY_SEPARATOR . $ext_prefix . $req_ext . '.' . PHP_SHLIB_SUFFIX;
$ini_settings['zend_extension'][] = $ext_file;
Expand Down Expand Up @@ -2785,6 +2777,22 @@ function run_test(string $php, $file, array $env): string
return $restype[0] . 'ED';
}

/**
* Map "Zend OPcache" to "opcache" and convert all ext names to lowercase.
*/
function remap_loaded_extensions_names(array $names): array
{
$exts = [];
foreach ($names as $name) {
if ($name === 'Core') {
continue;
}
$exts[] = ['Zend OPcache' => 'opcache'][$name] ?? strtolower($name);
}

return $exts;
}

/**
* @return bool|int
*/
Expand Down Expand Up @@ -3042,7 +3050,7 @@ function compute_summary(): void
global $n_total, $test_results, $ignored_by_ext, $sum_results, $percent_results;

$n_total = count($test_results);
$n_total += $ignored_by_ext;
$n_total += count($ignored_by_ext);
$sum_results = [
'PASSED' => 0,
'WARNED' => 0,
Expand All @@ -3058,7 +3066,7 @@ function compute_summary(): void
$sum_results[$v]++;
}

$sum_results['SKIPPED'] += $ignored_by_ext;
$sum_results['SKIPPED'] += count($ignored_by_ext);
$percent_results = [];

foreach ($sum_results as $v => $n) {
Expand Down Expand Up @@ -3090,43 +3098,43 @@ function get_summary(bool $show_ext_summary): string
=====================================================================
TEST RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped : ' . sprintf('%4d', $exts_skipped) . '
Exts tested : ' . sprintf('%4d', $exts_tested) . '
Exts skipped : ' . sprintf('%5d', count($exts_skipped)) . ($exts_skipped ? ' (' . implode(', ', $exts_skipped) . ')' : '') . '
Exts tested : ' . sprintf('%5d', count($exts_tested)) . '
---------------------------------------------------------------------
';
}

$summary .= '
Number of tests : ' . sprintf('%4d', $n_total) . ' ' . sprintf('%8d', $x_total);
Number of tests : ' . sprintf('%5d', $n_total) . ' ' . sprintf('%8d', $x_total);

if ($sum_results['BORKED']) {
$summary .= '
Tests borked : ' . sprintf('%4d (%5.1f%%)', $sum_results['BORKED'], $percent_results['BORKED']) . ' --------';
Tests borked : ' . sprintf('%5d (%5.1f%%)', $sum_results['BORKED'], $percent_results['BORKED']) . ' --------';
}

$summary .= '
Tests skipped : ' . sprintf('%4d (%5.1f%%)', $sum_results['SKIPPED'], $percent_results['SKIPPED']) . ' --------
Tests warned : ' . sprintf('%4d (%5.1f%%)', $sum_results['WARNED'], $percent_results['WARNED']) . ' ' . sprintf('(%5.1f%%)', $x_warned) . '
Tests failed : ' . sprintf('%4d (%5.1f%%)', $sum_results['FAILED'], $percent_results['FAILED']) . ' ' . sprintf('(%5.1f%%)', $x_failed);
Tests skipped : ' . sprintf('%5d (%5.1f%%)', $sum_results['SKIPPED'], $percent_results['SKIPPED']) . ' --------
Tests warned : ' . sprintf('%5d (%5.1f%%)', $sum_results['WARNED'], $percent_results['WARNED']) . ' ' . sprintf('(%5.1f%%)', $x_warned) . '
Tests failed : ' . sprintf('%5d (%5.1f%%)', $sum_results['FAILED'], $percent_results['FAILED']) . ' ' . sprintf('(%5.1f%%)', $x_failed);

if ($sum_results['XFAILED']) {
$summary .= '
Expected fail : ' . sprintf('%4d (%5.1f%%)', $sum_results['XFAILED'], $percent_results['XFAILED']) . ' ' . sprintf('(%5.1f%%)', $x_xfailed);
Expected fail : ' . sprintf('%5d (%5.1f%%)', $sum_results['XFAILED'], $percent_results['XFAILED']) . ' ' . sprintf('(%5.1f%%)', $x_xfailed);
}

if ($valgrind) {
$summary .= '
Tests leaked : ' . sprintf('%4d (%5.1f%%)', $sum_results['LEAKED'], $percent_results['LEAKED']) . ' ' . sprintf('(%5.1f%%)', $x_leaked);
Tests leaked : ' . sprintf('%5d (%5.1f%%)', $sum_results['LEAKED'], $percent_results['LEAKED']) . ' ' . sprintf('(%5.1f%%)', $x_leaked);
if ($sum_results['XLEAKED']) {
$summary .= '
Expected leak : ' . sprintf('%4d (%5.1f%%)', $sum_results['XLEAKED'], $percent_results['XLEAKED']) . ' ' . sprintf('(%5.1f%%)', $x_xleaked);
Expected leak : ' . sprintf('%5d (%5.1f%%)', $sum_results['XLEAKED'], $percent_results['XLEAKED']) . ' ' . sprintf('(%5.1f%%)', $x_xleaked);
}
}

$summary .= '
Tests passed : ' . sprintf('%4d (%5.1f%%)', $sum_results['PASSED'], $percent_results['PASSED']) . ' ' . sprintf('(%5.1f%%)', $x_passed) . '
Tests passed : ' . sprintf('%5d (%5.1f%%)', $sum_results['PASSED'], $percent_results['PASSED']) . ' ' . sprintf('(%5.1f%%)', $x_passed) . '
---------------------------------------------------------------------
Time taken : ' . sprintf('%4d seconds', $end_time - $start_time) . '
Time taken : ' . sprintf('%5d seconds', $end_time - $start_time) . '
=====================================================================
';
$failed_test_summary = '';
Expand Down Expand Up @@ -3682,11 +3690,8 @@ public function getExtensions(string $php): array
}

$extDir = shell_exec("$php -d display_errors=0 -r \"echo ini_get('extension_dir');\"");
$extensions = explode(",", shell_exec("$php -d display_errors=0 -r \"echo implode(',', get_loaded_extensions());\""));
$extensions = array_map('strtolower', $extensions);
if (in_array('zend opcache', $extensions)) {
$extensions[] = 'opcache';
}
$extensionsNames = explode(",", shell_exec("$php -d display_errors=0 -r \"echo implode(',', get_loaded_extensions());\""));
$extensions = remap_loaded_extensions_names($extensionsNames);

$result = [$extDir, $extensions];
$this->extensions[$php] = $result;
Expand Down