Skip to content
Browse files

add --STDIN-- support

  • Loading branch information...
1 parent 7a53065 commit 4a162b71a22107fea2e5894ef475e89d18d020ef @nunoplopes nunoplopes committed Sep 14, 2006
Showing with 22 additions and 2 deletions.
  1. +5 −2 run-tests.php
  2. +17 −0 tests/run-test/test010.phpt
View
7 run-tests.php
@@ -837,7 +837,7 @@ function error_report($testname, $logname, $tested)
}
}
-function system_with_timeout($commandline, $env = null)
+function system_with_timeout($commandline, $env = null, $stdin = null)
{
global $leak_check;
@@ -852,6 +852,9 @@ function system_with_timeout($commandline, $env = null)
if (!$proc)
return false;
+ if (is_string($stdin)) {
+ fwrite($pipes[0], $stdin);
+ }
fclose($pipes[0]);
while (true) {
@@ -1347,7 +1350,7 @@ function run_test($php, $file, $env)
COMMAND $cmd
";
- $out = system_with_timeout($cmd, $env);
+ $out = system_with_timeout($cmd, $env, isset($section_text['STDIN']) ? $section_text['STDIN'] : null);
if (array_key_exists('CLEAN', $section_text) && (!$no_clean || $cfg['keep']['clean'])) {
if (trim($section_text['CLEAN'])) {
View
17 tests/run-test/test010.phpt
@@ -0,0 +1,17 @@
+--TEST--
+STDIN input
+--FILE--
+<?php
+var_dump(stream_get_contents(STDIN));
+var_dump(stream_get_contents(fopen('php://stdin', 'r')));
+var_dump(file_get_contents('php://stdin'));
+?>
+--STDIN--
+fooBar
+use this to input some thing to the php script
+--EXPECT--
+string(54) "fooBar
+use this to input some thing to the php script
+"
+string(0) ""
+string(0) ""

0 comments on commit 4a162b7

Please sign in to comment.
Something went wrong with that request. Please try again.