Skip to content

Commit

Permalink
Merge branch 'issue-55736' of https://github.com/tistre/php-src
Browse files Browse the repository at this point in the history
implements FR #55736

* 'issue-55736' of https://github.com/tistre/php-src:
  run-tests.php: Adding support for sections EXPECT_EXTERNAL, EXPECTF_EXTERNAL and EXPECTREGEX_EXTERNAL. (Issue 55736)
  • Loading branch information
m6w6 committed Oct 9, 2013
2 parents 29d5ff7 + 5ffaf95 commit 5f41cb1
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 9 deletions.
22 changes: 13 additions & 9 deletions run-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -1289,16 +1289,20 @@ function run_test($php, $file, $env)
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']);
} else {
$bork_info = "could not load --FILE_EXTERNAL-- " . dirname($file) . '/' . trim($section_text['FILE_EXTERNAL']);
$borked = true;
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 --" . $key . "-- " . dirname($file) . '/' . trim($section_text[$key]);
$borked = true;
}
}
}

Expand Down
6 changes: 6 additions & 0 deletions tests/run-test/test011.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
--TEST--
EXPECT_EXTERNAL
--FILE--
abc
--EXPECT_EXTERNAL--
test011.txt
1 change: 1 addition & 0 deletions tests/run-test/test011.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
abc
12 changes: 12 additions & 0 deletions tests/run-test/test012.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
EXPECTF_EXTERNAL
--FILE--
123
-123
+123
+1.1
abc
0abc
x
--EXPECTF_EXTERNAL--
test012.txt
7 changes: 7 additions & 0 deletions tests/run-test/test012.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
%d
%i
%i
%f
%s
%x
%c
6 changes: 6 additions & 0 deletions tests/run-test/test013.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
--TEST--
EXPECTREGEX_EXTERNAL
--FILE--
abcde12314235xyz34264768286abcde
--EXPECTREGEX_EXTERNAL--
test013.txt
1 change: 1 addition & 0 deletions tests/run-test/test013.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[abcde]+[0-5]*xyz[2-8]+abcde

0 comments on commit 5f41cb1

Please sign in to comment.