|
| 1 | +--TEST-- |
| 2 | +multiple files syntax check |
| 3 | +--SKIPIF-- |
| 4 | +<?php include "skipif.inc"; ?> |
| 5 | +--FILE-- |
| 6 | +<?php |
| 7 | + |
| 8 | +function run_and_output($cmd) { |
| 9 | + exec($cmd, $output, $exit_code); |
| 10 | + print_r($output); |
| 11 | + var_dump($exit_code); |
| 12 | +} |
| 13 | + |
| 14 | +$php = getenv('TEST_PHP_EXECUTABLE_ESCAPED'); |
| 15 | + |
| 16 | +$filename_good = __DIR__."/024_good.test.php"; |
| 17 | +$filename_good_escaped = escapeshellarg($filename_good); |
| 18 | +$filename_bad = __DIR__."/024_bad.test.php"; |
| 19 | +$filename_bad_escaped = escapeshellarg($filename_bad); |
| 20 | + |
| 21 | +$code = ' |
| 22 | +<?php |
| 23 | +
|
| 24 | +echo "hi"; |
| 25 | +'; |
| 26 | + |
| 27 | +file_put_contents($filename_good, $code); |
| 28 | + |
| 29 | +$code = ' |
| 30 | +<?php |
| 31 | +
|
| 32 | +class test |
| 33 | + private $var; |
| 34 | +} |
| 35 | +
|
| 36 | +?> |
| 37 | +'; |
| 38 | + |
| 39 | +file_put_contents($filename_bad, $code); |
| 40 | + |
| 41 | +run_and_output("$php -n -l $filename_good_escaped $filename_good_escaped 2>&1"); |
| 42 | +run_and_output("$php -n -l $filename_good_escaped some.unknown $filename_good_escaped 2>&1"); |
| 43 | +run_and_output("$php -n -l $filename_good_escaped $filename_bad_escaped $filename_good_escaped 2>&1"); |
| 44 | +run_and_output("$php -n -l $filename_bad_escaped $filename_bad_escaped 2>&1"); |
| 45 | +run_and_output("$php -n -l $filename_bad_escaped some.unknown $filename_bad_escaped 2>&1"); |
| 46 | +run_and_output("$php -n -l $filename_bad_escaped $filename_bad_escaped some.unknown 2>&1"); |
| 47 | + |
| 48 | +echo "Done\n"; |
| 49 | +?> |
| 50 | +--CLEAN-- |
| 51 | +<?php |
| 52 | +@unlink($filename_good); |
| 53 | +@unlink($filename_bad); |
| 54 | +?> |
| 55 | +--EXPECTF-- |
| 56 | +Array |
| 57 | +( |
| 58 | + [0] => No syntax errors detected in %s024_good.test.php |
| 59 | + [1] => No syntax errors detected in %s024_good.test.php |
| 60 | +) |
| 61 | +int(0) |
| 62 | +Array |
| 63 | +( |
| 64 | + [0] => No syntax errors detected in %s024_good.test.php |
| 65 | + [1] => Could not open input file: some.unknown |
| 66 | + [2] => No syntax errors detected in %s024_good.test.php |
| 67 | +) |
| 68 | +int(1) |
| 69 | +Array |
| 70 | +( |
| 71 | + [0] => No syntax errors detected in %s024_good.test.php |
| 72 | + [1] => |
| 73 | + [2] => Parse error: syntax error, unexpected token "private", expecting "{" in %s on line %d |
| 74 | + [3] => Errors parsing %s024_bad.test.php |
| 75 | + [4] => No syntax errors detected in %s024_good.test.php |
| 76 | +) |
| 77 | +int(255) |
| 78 | +Array |
| 79 | +( |
| 80 | + [0] => |
| 81 | + [1] => Parse error: syntax error, unexpected token "private", expecting "{" in %s on line %d |
| 82 | + [2] => Errors parsing %s024_bad.test.php |
| 83 | + [3] => |
| 84 | + [4] => Parse error: syntax error, unexpected token "private", expecting "{" in %s on line %d |
| 85 | + [5] => Errors parsing %s024_bad.test.php |
| 86 | +) |
| 87 | +int(255) |
| 88 | +Array |
| 89 | +( |
| 90 | + [0] => |
| 91 | + [1] => Parse error: syntax error, unexpected token "private", expecting "{" in %s on line %d |
| 92 | + [2] => Errors parsing %s024_bad.test.php |
| 93 | + [3] => Could not open input file: some.unknown |
| 94 | + [4] => |
| 95 | + [5] => Parse error: syntax error, unexpected token "private", expecting "{" in %s on line %d |
| 96 | + [6] => Errors parsing %s024_bad.test.php |
| 97 | +) |
| 98 | +int(255) |
| 99 | +Array |
| 100 | +( |
| 101 | + [0] => |
| 102 | + [1] => Parse error: syntax error, unexpected token "private", expecting "{" in %s on line %d |
| 103 | + [2] => Errors parsing %s024_bad.test.php |
| 104 | + [3] => |
| 105 | + [4] => Parse error: syntax error, unexpected token "private", expecting "{" in %s on line %d |
| 106 | + [5] => Errors parsing %s024_bad.test.php |
| 107 | + [6] => Could not open input file: some.unknown |
| 108 | +) |
| 109 | +int(1) |
| 110 | +Done |
0 commit comments