Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions Zend/tests/bug74093.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ Bug #74093 (Maximum execution time of n+2 seconds exceed not written in error_lo
--FLAKY--
--SKIPIF--
<?php
if (!getenv('RUN_RESOURCE_HEAVY_TESTS')) die('skip resource-heavy test');
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
if (PHP_ZTS) die("skip only for no-zts build");
if (substr(PHP_OS, 0, 3) == 'WIN') die("skip not for Windows");
skipif(!getenv('RUN_RESOURCE_HEAVY_TESTS'), 'resource-heavy test');
skipif(getenv('SKIP_SLOW_TESTS'), 'slow test');
skipif(PHP_ZTS, 'only for no-zts build');
skipif(PHP_OS_FAMILY === 'Windows', 'not for Windows');
?>
--INI--
memory_limit=1G
Expand Down
4 changes: 2 additions & 2 deletions Zend/tests/new_oom.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Test OOM on new of each class
--SKIPIF--
<?php
if (getenv("USE_ZEND_ALLOC") === "0") die("skip requires zmm");
if (getenv("SKIP_SLOW_TESTS")) die('skip slow test');
skipif(getenv('USE_ZEND_ALLOC') === '0', 'requires zmm');
skipif(getenv('SKIP_SLOW_TESTS'), 'slow test');
?>
--FILE--
<?php
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/tests/file/windows_acls/bug44859.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ bug #44859 (incorrect result with NTFS ACL permissions, is_writable)
--SKIPIF--
<?php
include_once __DIR__ . '/common.inc';
skipif();
skip_unless_acl_testable();
?>
--FILE--
<?php
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/tests/file/windows_acls/bug44859_2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ bug #44859 (incorrect result with NTFS ACL permissions, is_readable)
--SKIPIF--
<?php
include_once __DIR__ . '/common.inc';
skipif();
skip_unless_acl_testable();
?>
--FILE--
<?php
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/tests/file/windows_acls/bug44859_3.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ bug #44859 (incorrect result with NTFS ACL permissions, is_executable)
--SKIPIF--
<?php
include_once __DIR__ . '/common.inc';
skipif();
skip_unless_acl_testable();
?>
--FILE--
<?php
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/tests/file/windows_acls/bug44859_4.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Venkat Raman Don
--SKIPIF--
<?php
include_once __DIR__ . '/common.inc';
skipif();
skip_unless_acl_testable();
?>
--FILE--
<?php
Expand Down
17 changes: 5 additions & 12 deletions ext/standard/tests/file/windows_acls/common.inc
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,11 @@ define('PHPT_ACL_FULL', 1 << 5);
define('PHPT_ACL_GRANT', 1);
define('PHPT_ACL_DENY', 2);

function skipif() {
if(substr(PHP_OS, 0, 3) != 'WIN' ) {
die('skip windows only test');
}
if(stripos(php_uname(), 'XP') !== FALSE) {
die('skip windows 2003 or newer only test');
}
if (getenv('GITHUB_ACTIONS')) {
// bug44859_4.phpt test fails on the 1st run
// other ACL tests cannot be run twice
die('skip failing on Github Actions');
}
function skip_unless_acl_testable() {
skipif(substr(PHP_OS, 0, 3) != 'WIN', 'windows only test');
skipif(stripos(php_uname(), 'XP') !== FALSE, 'windows 2003 or newer only test');
// bug44859_4.phpt fails on the 1st run; other ACL tests cannot be run twice
skipif(getenv('GITHUB_ACTIONS'), 'failing on Github Actions');
}

function get_username(){
Expand Down
2 changes: 1 addition & 1 deletion ext/xml/tests/bug26614.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ xml
--SKIPIF--
<?php
require __DIR__ . '/libxml_expat_skipif.inc';
skipif(want_expat: true);
skipif(!xml_uses_expat(), 'test is for Expat');
?>
--FILE--
<?php
Expand Down
4 changes: 2 additions & 2 deletions ext/xml/tests/bug26614_libxml_gte2_11.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ xml
--SKIPIF--
<?php
require __DIR__ . '/libxml_expat_skipif.inc';
skipif(want_expat: false);
if (LIBXML_VERSION < 21100) die('skip libxml2 test variant for version >= 2.11');
skipif(xml_uses_expat(), 'test is for libxml');
skipif(LIBXML_VERSION < 21100, 'libxml2 test variant for version >= 2.11');
?>
--FILE--
<?php
Expand Down
4 changes: 2 additions & 2 deletions ext/xml/tests/bug26614_libxml_pre2_11.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ xml
--SKIPIF--
<?php
require __DIR__ . '/libxml_expat_skipif.inc';
skipif(want_expat: false);
if (LIBXML_VERSION >= 21100) die('skip libxml2 test variant for version < 2.11');
skipif(xml_uses_expat(), 'test is for libxml');
skipif(LIBXML_VERSION >= 21100, 'libxml2 test variant for version < 2.11');
?>
--FILE--
<?php
Expand Down
8 changes: 4 additions & 4 deletions ext/xml/tests/bug81481.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ xml
memory_limit=-1
--SKIPIF--
<?php
if (!getenv('RUN_RESOURCE_HEAVY_TESTS')) die('skip resource-heavy test');
skipif(!getenv('RUN_RESOURCE_HEAVY_TESTS'), 'resource-heavy test');
require __DIR__ . '/libxml_expat_skipif.inc';
skipif(want_expat: false);
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
if (PHP_INT_SIZE != 8) die("skip 64-bit only");
skipif(xml_uses_expat(), 'test is for libxml');
skipif(getenv('SKIP_SLOW_TESTS'), 'slow test');
skipif(PHP_INT_SIZE != 8, '64-bit only');
?>
--FILE--
<?php
Expand Down
2 changes: 1 addition & 1 deletion ext/xml/tests/gh14834.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ xml
--SKIPIF--
<?php
require __DIR__ . '/libxml_expat_skipif.inc';
skipif(want_expat: false);
skipif(xml_uses_expat(), 'test is for libxml');
?>
--FILE--
<?php
Expand Down
2 changes: 1 addition & 1 deletion ext/xml/tests/gh20439_2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ xml
--SKIPIF--
<?php
require __DIR__ . '/libxml_expat_skipif.inc';
skipif(want_expat: false);
skipif(xml_uses_expat(), 'test is for libxml');
?>
--FILE--
<?php
Expand Down
7 changes: 2 additions & 5 deletions ext/xml/tests/libxml_expat_skipif.inc
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?php
function skipif(bool $want_expat) {
function xml_uses_expat(): bool {
ob_start();
echo phpinfo(INFO_MODULES);
$output = ob_get_clean();
if ($want_expat !== str_contains($output, 'EXPAT')) {
die('skip test is for ' . ($want_expat ? 'Expat' : 'libxml'));
}
return str_contains(ob_get_clean(), 'EXPAT');
}
2 changes: 1 addition & 1 deletion ext/xml/tests/xml_error_string_basic_expat.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ xml
--SKIPIF--
<?php
require __DIR__ . '/libxml_expat_skipif.inc';
skipif(want_expat: true);
skipif(!xml_uses_expat(), 'test is for Expat');
?>
--FILE--
<?php
Expand Down
2 changes: 1 addition & 1 deletion ext/xml/tests/xml_error_string_basic_libxml.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ xml
--SKIPIF--
<?php
require __DIR__ . '/libxml_expat_skipif.inc';
skipif(want_expat: false);
skipif(xml_uses_expat(), 'test is for libxml');
?>
--FILE--
<?php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ xml
--SKIPIF--
<?php
require __DIR__ . '/libxml_expat_skipif.inc';
skipif(want_expat: true);
skipif(!xml_uses_expat(), 'test is for Expat');
?>
--FILE--
<?php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ xml
--SKIPIF--
<?php
require __DIR__ . '/libxml_expat_skipif.inc';
skipif(want_expat: false);
skipif(xml_uses_expat(), 'test is for libxml');
?>
--FILE--
<?php
Expand Down
28 changes: 27 additions & 1 deletion run-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ function main(): void
}

define('TEST_PHP_SRCDIR', getcwd());
define('SKIPIF_HELPERS_FILE', write_skipif_helpers());

check_proc_open_function_exists();

Expand Down Expand Up @@ -1248,6 +1249,30 @@ function test_sort($a, $b): int
return $tb - $ta;
}

// Functions available to every SKIPIF section via auto_prepend_file.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think phpdbg SAPI doesn't excute auto_prepend_file?

--TEST--
SKIPIF helper in phpdbg
--SKIPIF--
<?php skipif(true, 'helper works'); ?>
--PHPDBG--
r
q
--FILE--
<?php echo "ok\n"; ?>
--EXPECT--
ok

This doesn't work.

function write_skipif_helpers(): string
{
$code = <<<'PHP'
<?php
function skipif($condition, string $reason): void
{
if ($condition) {
echo "skip $reason";
exit;
}
}

PHP;

$file = tempnam(sys_get_temp_dir(), 'run-tests-skipif-');
if ($file === false || file_put_contents($file, $code) === false) {
error('Unable to write SKIPIF helpers file.');
}
// Workers are killed with SIGTERM, so only the parent can clean up.
register_shutdown_function(static fn () => @unlink($file));
return $file;
}

//
// Write the given text to a temporary file.
//
Expand Down Expand Up @@ -1636,6 +1661,7 @@ function run_all_tests_parallel(array $test_files, array $env, ?string $redir_te
"constants" => [
"INIT_DIR" => INIT_DIR,
"TEST_PHP_SRCDIR" => TEST_PHP_SRCDIR,
"SKIPIF_HELPERS_FILE" => SKIPIF_HELPERS_FILE,
]
])) . "\n";

Expand Down Expand Up @@ -3900,7 +3926,7 @@ public function checkSkip(array $command, string $code, string $checkFile, strin

save_text($checkFile, $code, $tempFile);
$env['TEST_PHP_EVALUATING_SKIPIF'] = '1';
$command[] = $checkFile;
array_push($command, '-d', 'auto_prepend_file=' . SKIPIF_HELPERS_FILE, $checkFile);
$result = trim(system_with_timeout($command, $env));
if (strpos($result, 'nocache') === 0) {
$result = '';
Expand Down
Loading