Skip to content

Commit 6422d00

Browse files
committed
Remove weird count usage from run-tests
1 parent 99db00b commit 6422d00

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

run-tests.php

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,27 +1852,34 @@ function run_test($php, $file, $env)
18521852
// the redirect section allows a set of tests to be reused outside of
18531853
// a given test dir
18541854
if ($bork_info === null) {
1855-
if (isset($section_text['REDIRECTTEST'])) {
1855+
if (array_key_exists('REDIRECTTEST', $section_text)) {
18561856

18571857
if ($IN_REDIRECT) {
18581858
$bork_info = "Can't redirect a test from within a redirected test";
18591859
}
18601860

18611861
} else {
18621862

1863-
if (!isset($section_text['PHPDBG']) && @count($section_text['FILE']) + @count($section_text['FILEEOF']) + @count($section_text['FILE_EXTERNAL']) != 1) {
1863+
if (
1864+
!array_key_exists('PHPDBG', $section_text)
1865+
&& (
1866+
array_key_exists('FILE', $section_text)
1867+
xor array_key_exists('FILEEOF', $section_text)
1868+
xor array_key_exists('FILE_EXTERNAL', $section_text)
1869+
) === false
1870+
) {
18641871
$bork_info = "missing section --FILE--";
18651872
}
18661873

1867-
if (isset($section_text['FILEEOF'])) {
1874+
if (array_key_exists('FILEEOF', $section_text)) {
18681875
$section_text['FILE'] = preg_replace("/[\r\n]+$/", '', $section_text['FILEEOF']);
18691876
unset($section_text['FILEEOF']);
18701877
}
18711878

18721879
foreach (array('FILE', 'EXPECT', 'EXPECTF', 'EXPECTREGEX') as $prefix) {
18731880
$key = $prefix . '_EXTERNAL';
18741881

1875-
if (isset($section_text[$key])) {
1882+
if (array_key_exists($key, $section_text)) {
18761883
// don't allow tests to retrieve files from anywhere but this subdirectory
18771884
$section_text[$key] = dirname($file) . '/' . trim(str_replace('..', '', $section_text[$key]));
18781885

@@ -1885,7 +1892,13 @@ function run_test($php, $file, $env)
18851892
}
18861893
}
18871894

1888-
if ((@count($section_text['EXPECT']) + @count($section_text['EXPECTF']) + @count($section_text['EXPECTREGEX'])) != 1) {
1895+
if (
1896+
(
1897+
array_key_exists('EXPECT', $section_text)
1898+
xor array_key_exists('EXPECTF', $section_text)
1899+
xor array_key_exists('EXPECTREGEX', $section_text)
1900+
) === false
1901+
) {
18891902
$bork_info = "missing section --EXPECT--, --EXPECTF-- or --EXPECTREGEX--";
18901903
}
18911904
}
@@ -1909,7 +1922,7 @@ function run_test($php, $file, $env)
19091922
return 'BORKED';
19101923
}
19111924

1912-
if (isset($section_text['CAPTURE_STDIO'])) {
1925+
if (array_key_exists('CAPTURE_STDIO', $section_text)) {
19131926
$captureStdIn = stripos($section_text['CAPTURE_STDIO'], 'STDIN') !== false;
19141927
$captureStdOut = stripos($section_text['CAPTURE_STDIO'], 'STDOUT') !== false;
19151928
$captureStdErr = stripos($section_text['CAPTURE_STDIO'], 'STDERR') !== false;
@@ -2216,7 +2229,7 @@ function run_test($php, $file, $env)
22162229
$test_files[] = array($f, $file);
22172230
}
22182231
}
2219-
$test_cnt += @count($test_files) - 1;
2232+
$test_cnt += count($test_files) - 1;
22202233
$test_idx--;
22212234

22222235
show_redirect_start($IN_REDIRECT['TESTS'], $tested, $tested_file);
@@ -2250,7 +2263,7 @@ function run_test($php, $file, $env)
22502263
}
22512264
}
22522265

2253-
if (is_array($org_file) || @count($section_text['REDIRECTTEST']) == 1) {
2266+
if (is_array($org_file) || array_key_exists('REDIRECTTEST', $section_text)) {
22542267

22552268
if (is_array($org_file)) {
22562269
$file = $org_file[0];

0 commit comments

Comments
 (0)