Skip to content

Commit 5ffaf95

Browse files
author
Tim Strehle
committed
run-tests.php: Adding support for sections EXPECT_EXTERNAL, EXPECTF_EXTERNAL and EXPECTREGEX_EXTERNAL. (Issue 55736)
1 parent 04fcf6a commit 5ffaf95

File tree

7 files changed

+46
-9
lines changed

7 files changed

+46
-9
lines changed

run-tests.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,16 +1289,20 @@ function run_test($php, $file, $env)
12891289
unset($section_text['FILEEOF']);
12901290
}
12911291

1292-
if (@count($section_text['FILE_EXTERNAL']) == 1) {
1293-
// don't allow tests to retrieve files from anywhere but this subdirectory
1294-
$section_text['FILE_EXTERNAL'] = dirname($file) . '/' . trim(str_replace('..', '', $section_text['FILE_EXTERNAL']));
1292+
foreach (array( 'FILE', 'EXPECT', 'EXPECTF', 'EXPECTREGEX' ) as $prefix) {
1293+
$key = $prefix . '_EXTERNAL';
12951294

1296-
if (file_exists($section_text['FILE_EXTERNAL'])) {
1297-
$section_text['FILE'] = file_get_contents($section_text['FILE_EXTERNAL'], FILE_BINARY);
1298-
unset($section_text['FILE_EXTERNAL']);
1299-
} else {
1300-
$bork_info = "could not load --FILE_EXTERNAL-- " . dirname($file) . '/' . trim($section_text['FILE_EXTERNAL']);
1301-
$borked = true;
1295+
if (@count($section_text[$key]) == 1) {
1296+
// don't allow tests to retrieve files from anywhere but this subdirectory
1297+
$section_text[$key] = dirname($file) . '/' . trim(str_replace('..', '', $section_text[$key]));
1298+
1299+
if (file_exists($section_text[$key])) {
1300+
$section_text[$prefix] = file_get_contents($section_text[$key], FILE_BINARY);
1301+
unset($section_text[$key]);
1302+
} else {
1303+
$bork_info = "could not load --" . $key . "-- " . dirname($file) . '/' . trim($section_text[$key]);
1304+
$borked = true;
1305+
}
13021306
}
13031307
}
13041308

tests/run-test/test011.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
--TEST--
2+
EXPECT_EXTERNAL
3+
--FILE--
4+
abc
5+
--EXPECT_EXTERNAL--
6+
test011.txt

tests/run-test/test011.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
abc

tests/run-test/test012.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
EXPECTF_EXTERNAL
3+
--FILE--
4+
123
5+
-123
6+
+123
7+
+1.1
8+
abc
9+
0abc
10+
x
11+
--EXPECTF_EXTERNAL--
12+
test012.txt

tests/run-test/test012.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
%d
2+
%i
3+
%i
4+
%f
5+
%s
6+
%x
7+
%c

tests/run-test/test013.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
--TEST--
2+
EXPECTREGEX_EXTERNAL
3+
--FILE--
4+
abcde12314235xyz34264768286abcde
5+
--EXPECTREGEX_EXTERNAL--
6+
test013.txt

tests/run-test/test013.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[abcde]+[0-5]*xyz[2-8]+abcde

0 commit comments

Comments
 (0)