-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix issues with phpt and EXTENSIONS block on windows (BUG 75042) #2673
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
* Commands are not properly escaped for windows * Specifying "-n" to check loaded modules causes "Module already loaded" warning * Extensions to be loaded need the "php_" prefix on Windows Bug: https://bugs.php.net/bug.php?id=75042
run-tests.php
Outdated
@@ -1575,15 +1575,16 @@ function run_test($php, $file, $env) | |||
|
|||
// Additional required extensions | |||
if (array_key_exists('EXTENSIONS', $section_text)) { | |||
$ext_dir=`$php -r 'echo ini_get("extension_dir");'`; | |||
$ext_dir=`$php -r "echo ini_get('extension_dir');"`; |
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.
Are you sure this doesn't hurt the non windows side? Some shells could extrapolate double quotes and consequently complain about parentheses. IMO it would be safer to isolate the call by platform.
Thanks.
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 mainly do development on Ubuntu, and this should work on that platform, since there's no variable expansion in the argument. I can't speak for any other platform. Initially, I tried to use escapeshellarg (which in theory would be the safest cross-platform solution), but according to the documentation:
On Windows, escapeshellarg() instead replaces percent signs, exclamation marks (delayed variable substitution) and double quotes with spaces and adds double quotes around the string.
Which doesn't work at all because the code then becomes: echo ini_get(extension_dir);
and echo implode( , , get_loaded_extensions());
I will refactor it to a branch if you'd prefer.
@jbboehr you told in the ticket a repro is possible. Could you add a test for that please? Thanks. |
@weltling It's a little tricky because it requires one extension to be built shared. I'll see if I can figure out a way to do this without causing tests to fail if the extension isn't built shared. |
@jbboehr there are several exts that are always built shared for Windows in the core, for instance ext/openssl. In general, the test can be adapted later, if the standard build changes. But a test is essential we see there are no regressions. Thanks. |
with the EXTENSIONS phpt block
@weltling I have added three tests:
If you have any advice on how to proceed with (1), it would be much appreciated, however I believe just tests (2) and (3) should be sufficient to test the functionality of the |
Waiting on php/php-src#2673
@jbboehr the tests 2. and 3. are fine. Furthermore - SPL is never shared, so that's reliable. With the number 1 - i see a complication now. Namely, there are different constellations of shared/static in the standard build on Windows, based on specifics. It looks to me, that the way running With the part about the evaluation order - so this likely needs to be fixed as well. If some item in EXTENSIONS is not available, the test should skip as it is missing a required prerequisite to run. Thanks. |
@weltling My latest commit attempts to pass in the same options to those two shell commands that are passed to the php files for the |
* Windows fixes * Add appveyor configuration * Remove EXTENSIONS block in one test - waiting on php/php-src#2673 See also: https://stackoverflow.com/questions/14347038/dos-batch-why-are-my-set-commands-resulting-in-nothing-getting-stored/14347131#14347131
@jbboehr yeah, that should work in most case, if run-tests.php is invoked within the makefile. Otherwise it'll need some extra config anyway. I need to test this part on Linux yet, should come to it next days. What about the second part about skip if dynamic dependents are not available? Should be at least evaluated. Thanks. |
@weltling tests 2 and 3 should be running on linux. I think it's fine for the skipping to be provided by the // Additional required extensions
if (array_key_exists('EXTENSIONS', $section_text)) {
$ext_params = array();
settings2array($ini_overwrites, $ext_params);
settings2params($ext_params);
$ext_dir=`$php $pass_options $ext_params -d display_errors=0 -r "echo ini_get('extension_dir');"`;
$extensions = preg_split("/[\n\r]+/", trim($section_text['EXTENSIONS']));
$loaded = explode(",", `$php $pass_options $ext_params -d display_errors=0 -r "echo implode(',', get_loaded_extensions());"`);
$ext_prefix = substr(PHP_OS, 0, 3) === "WIN" ? "php_" : "";
foreach ($extensions as $req_ext) {
$req_ext_file = $ext_dir . DIRECTORY_SEPARATOR . $ext_prefix . $req_ext . '.' . PHP_SHLIB_SUFFIX;
if (!file_exists($req_ext_file)) {
$message = "ext/$req_ext required";
show_result('SKIP', $tested, $tested_file, "reason: $message", $temp_filenames);
junit_mark_test_as('SKIP', $shortname, $tested, null, $message);
return 'SKIPPED';
}
if (!in_array($req_ext, $loaded)) {
if ($req_ext == 'opcache') {
$ini_settings['zend_extension'][] = $req_ext_file;
} else {
$ini_settings['extension'][] = $req_ext_file;
}
}
}
} |
@jbboehr thinking a bit more about it, i'd go with you saying SKIPIF section is already does the job and is enough. While it would be a nice piece, it'd introduce a redundant handling which is not necessary good. With that, lets wait for possibly more comments and i still should come to the Linux test. Thanks. |
@weltling The resolution is simple enough for 7.0. Someone changed https://github.com/php/php-src/compare/PHP-7.0...jbboehr:run-tests-windows-EXTENSIONS-7.0?expand=1 |
documented behaviour of loading extensions from shared modules was broken some time ago, this patch reintroduces that feature whilst retaining other changes which allow the skip cache to work
Hello and sorry to necro a 4 year old patch, but isn't this an undocumented (and I would suspect undesirable) behaviour change in the intended purpose of the According to this patch, So it seems the behaviour, when using make-tests.php on your own module, has changed -- BEFORE:
AFTER:
The "before" behaviour is essential when building an extension. For example I am currently writing a test where The reason I suggest that this behaviour change is undesirable is it conflicts with the existing documentation - Here is where Funnily enough, there is another unintended side effect of this patch, which is that it enables you to specify the current extension as being required. That is, Addressing both of these considerations, I've submitted a PR #6910 to revert the change to |
Specifying "-n" to check loaded modules causes "Module already loaded"warning
Bug: https://bugs.php.net/bug.php?id=75042