-
Notifications
You must be signed in to change notification settings - Fork 7.8k
run-tests: use the EXTENSIONS section for skipping #6787
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
Conversation
tests/run-test/extensions-nonexistent.phpt failed |
0320ad5
to
596f96d
Compare
Ignores be damned... |
I would like to see something more abstract, not only for extensions, like:
etc. |
Yep, I have plans for --PLATFORM-- after that :) |
Windows:
The CI results on azure look completely broken, but not sure if that's due to this PR or you just hit a bad master revision. |
--FILE-- | ||
<?php | ||
var_dump(extension_loaded('openssl')); | ||
?> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?>
terminators in test files should be kept, to make tests directly runnable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, though there are a lot of existing tests missing these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, last year I added thousands of such terminators, but it was still not comprehensive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can make run-tests warn on such tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
run-tests is also used by extensions, so warnings are problematic. Maybe add this to tidy.php instead.
Currently, most skip checks are just for making sure an extension is available. Even with recent addition of skip caching, this makes tests needlessly slow: * Checks for the same extension in its tests can have small differences impacting cacheability. * Even identical skip checks in two tests can still be executed twice if they're run by different workers. To remedy this, I'm repurposing the existing --EXTENSIONS-- section of .phpt files to specify wjich extensions are required for current test to run. Current behavior: 1) If the extension is already visible to PHP, all is good 2) If it isn't, assume it's present as a shared module and attempt to add it via a command line parameter 3) If that works, all is good 4) If it doesn't, PHP fails with a cryptic error message trying to execute the test itself After this commit: 1) and 2) are kept unchanged 3) Check if shared extension file from 2) is actually present 4) Skip the test if it isn't Other benefits include clear skip reasons (vs. sometimes none in many current skip checks) and moving test information from code to metadata, opening more opportunities for search and analysis. Since --EXTENSIONS-- is barely ever used, this change poses no risk of hidden failures. As a demonstration of the new approach, this commit migrates one extension to it. If merged, I will migrate other extensions in subsequent PRs.
For rationale, see php#6787 Extensions migrated in this part: * bcmath * bz2 * calendar * com_dotnet * ctype
Just seen this; very nice! That may also give the opportunity to improve the performance of the tests on Windows, by only loading the required extenstions in advance. The |
For rationale, see php#6787 Make extension checks lowercase, add a special case for opcache that has internal name not matching .so filename. Extensions migrated in part 2: * dom * exif * fileinfo * ffi
For rationale, see #6787 Make extension checks lowercase, add a special case for opcache that has internal name not matching .so filename. Extensions migrated in part 2: * dom * exif * fileinfo * ffi
For rationale, see php#6787 Extensions migrated in part 3: * ftp * gmp * iconv * opcache
For rationale, see php#6787 Extensions migrated in part 3: * ftp * gmp * iconv * opcache * shmop
For rationale, see php#6787 Extensions migrated in part 3: * ftp * gmp * iconv * opcache * shmop
For rationale, see php#6787 Extensions migrated in part 3: * ftp * gmp * iconv * opcache * shmop
For rationale, see #6787 Extensions migrated in part 3: * ftp * gmp * iconv * opcache * shmop
For rationale, see php#6787 Make extension checks lowercase, add a special case for opcache that has internal name not matching .so filename. Extensions migrated in part 2: * dom * exif * fileinfo * ffi
For rationale, see php#6787 Extensions migrated in part 3: * ftp * gmp * iconv * opcache * shmop
For rationale, see php#6787 Extensions migrated in part 4: * simplexml * skeleton * soap * spl * sqlite3 * sysvmsg * sysvsem * tidy
For rationale, see php#6787 Extensions migrated in part 4: * simplexml * skeleton * soap * spl * sqlite3 * sysvmsg * sysvsem * tidy - also removed a check for an ancient dependency version
For rationale, see #6787 Extensions migrated in part 4: * simplexml * skeleton * soap * spl * sqlite3 * sysvmsg * sysvsem * tidy - also removed a check for an ancient dependency version
@MaxSem Can we document this at http://qa.php.net/write-test.php? |
I just realized that this may not work as expected when all tests are supposed to be run, due to: Lines 863 to 865 in 048cb9b
Unless we want to change run-tests.php, the test runner itself would have to be run with all (relevant) extensions loaded. PS: no, it's not the test runner itself, but rather the TEST_PHP_EXECUTABLE, what defeats the purpose of this PR (only for all tests; testing individual extension tests suites works fine). |
@cmb69 We should probably adjust that to include both loaded and loadable extensions. Should be fairly simple? |
@nikic, we could do something like: run-tests.php | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/run-tests.php b/run-tests.php
index 3c7189b24d..e767598e67 100755
--- a/run-tests.php
+++ b/run-tests.php
@@ -861,8 +861,21 @@ More .INIs : " , (function_exists(\'php_ini_scanned_files\') ? str_replace("\n"
@unlink($info_file);
// load list of enabled extensions
- save_text($info_file,
- '<?php echo str_replace("Zend OPcache", "opcache", implode(",", get_loaded_extensions())); ?>');
+ save_text($info_file, <<<'PHP'
+ <?php
+ echo str_replace("Zend OPcache", "opcache", implode(",", 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;
+ }
+ }
+ ?>
+ PHP);
$exts_to_test = explode(',', `$php $pass_options $info_params $no_file_cache "$info_file"`);
// check for extensions that need special handling and regenerate
$info_params_ex = [ But for AppVeyor this would mean that tests would be run for snmp,pdo_firebird,ldap,imap,ftp, although these tests would always be skipped. Might still be a performance improvement in the long run. I'll submit a PR ASAP. |
PR php#6787 changed the behavior of the `--EXTENSIONS--` section, so that not yet loaded extensions are dynamically loaded if possible. However, when no tests are specified for the runner, only tests for already loaded extensions are run, what defeats the purpose of the improvement of the `--EXTENSIONS--` behavior. We cater to that by detecting loadable extensions, and also run their tests.
PR #6787 changed the behavior of the `--EXTENSIONS--` section, so that not yet loaded extensions are dynamically loaded if possible. However, when no tests are specified for the runner, only tests for already loaded extensions are run, what defeats the purpose of the improvement of the `--EXTENSIONS--` behavior. We cater to that by detecting loadable extensions, and also run their tests.
🎆 #7325 🎆 |
This is only properly supported as of PHP 8.1.0[1], and may cause spurious test failures for older versions[2]. [1] <#6787> [2] <https://ci.appveyor.com/project/php/php-src/builds/42044075/job/tk4138s43p1953hx>
Currently, most skip checks are just for making sure an extension is
available. Even with recent addition of skip caching, this makes tests
needlessly slow:
impacting cacheability.
they're run by different workers.
To remedy this, I'm repurposing the existing --EXTENSIONS-- section of
.phpt files to specify wjich extensions are required for current test to
run. Current behavior:
it via a command line parameter
execute the test itself
After this commit:
Other benefits include clear skip reasons (vs. sometimes none in many
current skip checks) and moving test information from code to metadata,
opening more opportunities for search and analysis.
Since --EXTENSIONS-- is barely ever used, this change poses no risk of
hidden failures.
As a demonstration of the new approach, this commit migrates one
extension to it. If merged, I will migrate other extensions in
subsequent PRs.