]> granicus.if.org Git - php/commitdiff
add --STDIN-- support
authorNuno Lopes <nlopess@php.net>
Thu, 14 Sep 2006 16:58:52 +0000 (16:58 +0000)
committerNuno Lopes <nlopess@php.net>
Thu, 14 Sep 2006 16:58:52 +0000 (16:58 +0000)
run-tests.php
tests/run-test/test010.phpt [new file with mode: 0644]

index a48ee69f2eb68154514a7f192b707c428c6a1395..cacf1760c8747cb90e131db31a7558176a951c90 100755 (executable)
@@ -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 @@ SCRIPT_FILENAME = " . $env['SCRIPT_FILENAME'] . "
 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'])) {
diff --git a/tests/run-test/test010.phpt b/tests/run-test/test010.phpt
new file mode 100644 (file)
index 0000000..cc3ca35
--- /dev/null
@@ -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) ""