mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
run-tests.php: Adding support for sections EXPECT_EXTERNAL, EXPECTF_EXTERNAL and EXPECTREGEX_EXTERNAL. (Issue 55736)
This commit is contained in:
parent
04fcf6a98b
commit
5ffaf95d3f
7 changed files with 46 additions and 9 deletions
|
@ -1289,18 +1289,22 @@ TEST $file
|
|||
unset($section_text['FILEEOF']);
|
||||
}
|
||||
|
||||
if (@count($section_text['FILE_EXTERNAL']) == 1) {
|
||||
// don't allow tests to retrieve files from anywhere but this subdirectory
|
||||
$section_text['FILE_EXTERNAL'] = dirname($file) . '/' . trim(str_replace('..', '', $section_text['FILE_EXTERNAL']));
|
||||
foreach (array( 'FILE', 'EXPECT', 'EXPECTF', 'EXPECTREGEX' ) as $prefix) {
|
||||
$key = $prefix . '_EXTERNAL';
|
||||
|
||||
if (file_exists($section_text['FILE_EXTERNAL'])) {
|
||||
$section_text['FILE'] = file_get_contents($section_text['FILE_EXTERNAL'], FILE_BINARY);
|
||||
unset($section_text['FILE_EXTERNAL']);
|
||||
if (@count($section_text[$key]) == 1) {
|
||||
// don't allow tests to retrieve files from anywhere but this subdirectory
|
||||
$section_text[$key] = dirname($file) . '/' . trim(str_replace('..', '', $section_text[$key]));
|
||||
|
||||
if (file_exists($section_text[$key])) {
|
||||
$section_text[$prefix] = file_get_contents($section_text[$key], FILE_BINARY);
|
||||
unset($section_text[$key]);
|
||||
} else {
|
||||
$bork_info = "could not load --FILE_EXTERNAL-- " . dirname($file) . '/' . trim($section_text['FILE_EXTERNAL']);
|
||||
$bork_info = "could not load --" . $key . "-- " . dirname($file) . '/' . trim($section_text[$key]);
|
||||
$borked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((@count($section_text['EXPECT']) + @count($section_text['EXPECTF']) + @count($section_text['EXPECTREGEX'])) != 1) {
|
||||
$bork_info = "missing section --EXPECT--, --EXPECTF-- or --EXPECTREGEX--";
|
||||
|
|
6
tests/run-test/test011.phpt
Normal file
6
tests/run-test/test011.phpt
Normal file
|
@ -0,0 +1,6 @@
|
|||
--TEST--
|
||||
EXPECT_EXTERNAL
|
||||
--FILE--
|
||||
abc
|
||||
--EXPECT_EXTERNAL--
|
||||
test011.txt
|
1
tests/run-test/test011.txt
Normal file
1
tests/run-test/test011.txt
Normal file
|
@ -0,0 +1 @@
|
|||
abc
|
12
tests/run-test/test012.phpt
Normal file
12
tests/run-test/test012.phpt
Normal file
|
@ -0,0 +1,12 @@
|
|||
--TEST--
|
||||
EXPECTF_EXTERNAL
|
||||
--FILE--
|
||||
123
|
||||
-123
|
||||
+123
|
||||
+1.1
|
||||
abc
|
||||
0abc
|
||||
x
|
||||
--EXPECTF_EXTERNAL--
|
||||
test012.txt
|
7
tests/run-test/test012.txt
Normal file
7
tests/run-test/test012.txt
Normal file
|
@ -0,0 +1,7 @@
|
|||
%d
|
||||
%i
|
||||
%i
|
||||
%f
|
||||
%s
|
||||
%x
|
||||
%c
|
6
tests/run-test/test013.phpt
Normal file
6
tests/run-test/test013.phpt
Normal file
|
@ -0,0 +1,6 @@
|
|||
--TEST--
|
||||
EXPECTREGEX_EXTERNAL
|
||||
--FILE--
|
||||
abcde12314235xyz34264768286abcde
|
||||
--EXPECTREGEX_EXTERNAL--
|
||||
test013.txt
|
1
tests/run-test/test013.txt
Normal file
1
tests/run-test/test013.txt
Normal file
|
@ -0,0 +1 @@
|
|||
[abcde]+[0-5]*xyz[2-8]+abcde
|
Loading…
Add table
Add a link
Reference in a new issue