summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMax Semenik <maxsem.wiki@gmail.com>2021-03-18 14:53:14 +0300
committerNikita Popov <nikita.ppv@gmail.com>2021-03-22 09:53:38 +0100
commit6c9a05667b72c6420eb21269ffaffbd93178923c (patch)
tree36579c85463a21ccf92e22cd166267d5c5eb44ac /tests
parenta3e1082e0abac7ce6a664064bc1855061f365159 (diff)
downloadphp-git-6c9a05667b72c6420eb21269ffaffbd93178923c.tar.gz
run-tests: use the EXTENSIONS section for skipping
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. Closes GH-6787.
Diffstat (limited to 'tests')
-rw-r--r--tests/run-test/bug75042-2.phpt10
-rw-r--r--tests/run-test/bug75042-3.phpt13
-rw-r--r--tests/run-test/extensions-shared.phpt (renamed from tests/run-test/bug75042.phpt)7
-rw-r--r--tests/run-test/extensions-static.phpt9
4 files changed, 13 insertions, 26 deletions
diff --git a/tests/run-test/bug75042-2.phpt b/tests/run-test/bug75042-2.phpt
deleted file mode 100644
index 2c5718a9a0..0000000000
--- a/tests/run-test/bug75042-2.phpt
+++ /dev/null
@@ -1,10 +0,0 @@
---TEST--
-phpt EXTENSIONS directive with static module
---EXTENSIONS--
-SPL
---FILE--
-<?php
-var_dump(extension_loaded('spl'));
-?>
---EXPECT--
-bool(true)
diff --git a/tests/run-test/bug75042-3.phpt b/tests/run-test/bug75042-3.phpt
deleted file mode 100644
index 5a30143be9..0000000000
--- a/tests/run-test/bug75042-3.phpt
+++ /dev/null
@@ -1,13 +0,0 @@
---TEST--
-phpt EXTENSIONS directive with nonexistent shared module
---INI--
-error_log=
-display_startup_errors=1
-display_errors=1
---EXTENSIONS--
-nonexistentsharedmodule
---FILE--
-<?php
-?>
---EXPECTF--
-Warning: PHP Startup: Unable to load dynamic library '%snonexistentsharedmodule.%s' %A
diff --git a/tests/run-test/bug75042.phpt b/tests/run-test/extensions-shared.phpt
index a7979d6b5e..e8d9b52aa9 100644
--- a/tests/run-test/bug75042.phpt
+++ b/tests/run-test/extensions-shared.phpt
@@ -1,5 +1,7 @@
--TEST--
-phpt EXTENSIONS directive with shared module
+phpt EXTENSIONS directive - shared module
+--EXTENSIONS--
+openssl
--SKIPIF--
<?php
$php = getenv('TEST_PHP_EXECUTABLE');
@@ -8,8 +10,7 @@ if (false !== stripos(`$php -n -m`, 'openssl')) {
}
$ext_module = ini_get('extension_dir') . DIRECTORY_SEPARATOR . (substr(PHP_OS, 0, 3) === "WIN" ? "php_openssl." : "openssl.") . PHP_SHLIB_SUFFIX;
if( !file_exists($ext_module) ) die('skip openssl shared extension not found');
---EXTENSIONS--
-openssl
+
--FILE--
<?php
var_dump(extension_loaded('openssl'));
diff --git a/tests/run-test/extensions-static.phpt b/tests/run-test/extensions-static.phpt
new file mode 100644
index 0000000000..19e883e0ba
--- /dev/null
+++ b/tests/run-test/extensions-static.phpt
@@ -0,0 +1,9 @@
+--TEST--
+phpt EXTENSIONS directive - static extension is present
+--EXTENSIONS--
+standard
+--FILE--
+<?php
+var_dump(extension_loaded('standard'));
+--EXPECT--
+bool(true)