10000 Implement stream_vt100_support user function by mlocati · Pull Request #2103 · php/php-src · GitHub
[go: up one dir, main page]

Skip to content

Implement stream_vt100_support user function #2103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 41 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
a0e0d8d
Add VT100 support for Windows
mlocati Aug 29, 2016
18c5c42
Fix function names prefix
mlocati Aug 30, 2016
be50062
Use Unicode version of GetFinalPathNameByHandle
mlocati Aug 30, 2016
e11f3d2
Use EG(windows_version_info) instead of RtlGetVersion
mlocati Aug 30, 2016
6953d2f
Use the specified handle_id instead of STD_OUTPUT_HANDLE
mlocati Aug 30, 2016
bd93781
Switch from stream name to stream resource
mlocati Aug 30, 2016
35bf19a
Allow running tests capturing only stdout and/or stderr
mlocati Aug 30, 2016
d9b1c99
Add tests for stream_vt100_support function
mlocati Aug 30, 2016
2f05643
Export Win32 console functions
mlocati Oct 4, 2016
694e207
Fix x64 build
mlocati Oct 4, 2016
4f4ffd0
Use zend_long instead of long long, use GetConsole instead of GetFina…
mlocati Oct 4, 2016
3fcdc64
Always use zend_long on any platform
mlocati Oct 4, 2016
99bd01e
Use _get_osfhandle to determine the standard handle
mlocati Oct 5, 2016
7b155f4
Accept stream names
mlocati Oct 5, 2016
08e75a2
Raise warnings in case of invalid stream parameter
mlocati Oct 5, 2016
c10467e
Return true if disabling VT100 support on a not-console/redirected st…
mlocati Oct 6, 2016
dd85825
Remove php_win32_console_os_supports_vt100
mlocati Oct 6, 2016
a6e88f6
Differentiate stdin vs stdout/stderr
mlocati Oct 6, 2016
1643715
Simplify setting flag
mlocati Oct 6, 2016
f86567e
Allow avoid piping STDIN
mlocati Oct 6, 2016
658ff84
Let stream_vt100_support accept only resources
mlocati Oct 6, 2016
d9e0531
Fix run-tests
mlocati Oct 6, 2016
157f8e8
Revert console flags in case of failure
mlocati Oct 6, 2016
76411a4
Simplify logic of stream_vt100_support when setting the flag
mlocati Oct 7, 2016
4d956f2
Drop support for STDIN
mlocati Oct 7, 2016
7d348a0
More comprehensive tests for stream_vt100_support
mlocati Oct 7, 2016
4588b50
Remove old tests
mlocati Oct 8, 2016
bf60a78
Fix name of included file and use absolute paths
mlocati Oct 8, 2016
5d2ecf9
Enable ENABLE_VIRTUAL_TERMINAL_PROCESSING on Windows by default
mlocati Oct 8, 2016
7581767
Remove tests for stream_vt100_support
mlocati Oct 9, 2016
d15063c
Split stream_vt100_support into stream_isatty+sapi_windows_vt100_support
mlocati Oct 9, 2016
65ad779
Add tests for stream_isatty
mlocati Oct 9, 2016
67e1eb7
Add tests for sapi_windows_vt100_support
mlocati Oct 9, 2016
f9ff470
Return null from stream_isatty is neither Windows nor Posix
mlocati Oct 14, 2016
6df8c3c
Fallback to S_ISCHR if neither Windows nor Posix
mlocati Oct 14, 2016
1081aa8
Avoid defining argc since it's only used once
mlocati Oct 17, 2016
e4aaa27
Better comment about php_win32_console_fileno_is_console
mlocati Oct 17, 2016
2d062f3
Use events instead of cNumberOfEvents
mlocati Oct 17, 2016
d70a7f2
Do not restore previous console mode
mlocati Oct 17, 2016
c2988ea
Merge master into vt100-windows
mlocati Oct 17, 2016
d1772e6
Don't configure STDOUT/STDERR on Windows with PHP_CLI_WIN32_NO_CONSOLE
mlocati Oct 17, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add tests for stream_isatty
  • Loading branch information
mlocati committed Oct 9, 2016
commit 65ad7796d824c2ea26316681867b157f6a9e597d
36 changes: 36 additions & 0 deletions tests/output/stream_isatty.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

function testToStdOut()
{
$sampleStreams = array(
'STDIN (constant)' => STDIN,
'STDIN (fopen)' => fopen('php://stdin', 'rb'),
'STDIN (php://fd/0)' => fopen('php://fd/0', 'rb'),
'STDOUT (constant)' => STDOUT,
'STDOUT (fopen)' => fopen('php://stdout', 'wb'),
'STDOUT (php://fd/1)' => fopen('php://fd/1', 'wb'),
'STDERR (constant)' => STDERR,
'STDERR (fopen)' => fopen('php://stderr', 'wb'),
'STDERR (php://fd/2)' => fopen('php://fd/2', 'wb'),
'Not a stream' => 'foo',
'Invalid stream (php://temp)' => fopen('php://temp', 'wb'),
'Invalid stream (php://input)' => fopen('php://input', 'wb'),
'Invalid stream (php://memory)' => fopen('php://memory', 'wb'),
'File stream' => $closeMe = fopen(__FILE__, 'rb'),
);

foreach ($sampleStreams as $name => $stream) {
echo "$name: "; var_dump(stream_isatty($stream));
}

fclose($closeMe);
}

function testToStdErr()
{
ob_start();
testToStdOut();
$result = ob_get_contents();
ob_end_clean();
fwrite(STDERR, $result);
}
26 changes: 26 additions & 0 deletions tests/output/stream_isatty_err.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--TEST--
Test stream_isatty with redirected STDERR
--CAPTURE_STDIO--
STDERR
--FILE--
<?php
require dirname(__FILE__).'/stream_isatty.inc';
testToStdErr();
?>
--EXPECTF--
STDIN (constant): bool(true)
STDIN (fopen): bool(true)
STDIN (php://fd/0): bool(true)
STDOUT (constant): bool(true)
STDOUT (fopen): bool(true)
STDOUT (php://fd/1): bool(true)
STDERR (constant): bool(false)
STDERR (fopen): bool(false)
STDERR (php://fd/2): bool(false)
Not a stream:
Warning: stream_isatty() expects parameter 1 to be resource, string given in %s on line %d
bool(false)
Invalid stream (php://temp): bool(false)
Invalid stream (php://input): bool(false)
Invalid stream (php://memory): bool(false)
File stream: bool(false)
26 changes: 26 additions & 0 deletions tests/output/stream_isatty_in-err.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--TEST--
Test stream_isatty with redirected STDIN/STDERR
--CAPTURE_STDIO--
STDIN STDERR
--FILE--
<?php
require dirname(__FILE__).'/stream_isatty.inc';
testToStdErr();
?>
--EXPECTF--
STDIN (constant): bool(false)
STDIN (fopen): bool(false)
STDIN (php://fd/0): bool(false)
STDOUT (constant): bool(true)
STDOUT (fopen): bool(true)
STDOUT (php://fd/1): bool(true)
STDERR (constant): bool(false)
STDERR (fopen): bool(false)
STDERR (php://fd/2): bool(false)
Not a stream:
Warning: stream_isatty() expects parameter 1 to be resource, string given in %s on line %d
bool(false)
Invalid stream (php://temp): bool(false)
Invalid stream (php://input): bool(false)
Invalid stream (php://memory): bool(false)
File stream: bool(false)
26 changes: 26 additions & 0 deletions tests/output/stream_isatty_in-out-err.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--TEST--
Test stream_isatty with redirected STDIN/STDOUT/STDERR
--CAPTURE_STDIO--
STDIN STDOUT STDERR
--FILE--
<?php
require dirname(__FILE__).'/stream_isatty.inc';
testToStdOut();
?>
--EXPECTF--
STDIN (constant): bool(false)
STDIN (fopen): bool(false)
STDIN (php://fd/0): bool(false)
STDOUT (constant): bool(false)
STDOUT (fopen): bool(false)
STDOUT (php://fd/1): bool(false)
STDERR (constant): bool(false)
STDERR (fopen): bool(false)
STDERR (php://fd/2): bool(false)
Not a stream:
Warning: stream_isatty() expects parameter 1 to be resource, string given in %s on line %d
bool(false)
Invalid stream (php://temp): bool(false)
Invalid stream (php://input): bool(false)
Invalid stream (php://memory): bool(false)
File stream: bool(false)
26 changes: 26 additions & 0 deletions tests/output/stream_isatty_in-out.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--TEST--
Test stream_isatty with redirected STDIN/STDOUT
--CAPTURE_STDIO--
STDIN STDOUT
--FILE--
<?php
require dirname(__FILE__).'/stream_isatty.inc';
testToStdOut();
?>
--EXPECTF--
STDIN (constant): bool(false)
STDIN (fopen): bool(false)
STDIN (php://fd/0): bool(false)
STDOUT (constant): bool(false)
STDOUT (fopen): bool(false)
STDOUT (php://fd/1): bool(false)
STDERR (constant): bool(true)
STDERR (fopen): bool(true)
STDERR (php://fd/2): bool(true)
Not a stream:
Warning: stream_isatty() expects parameter 1 to be resource, string given in %s on line %d
bool(false)
Invalid stream (php://temp): bool(false)
Invalid stream (php://input): bool(false)
Invalid stream (php://memory): bool(false)
File stream: bool(false)
26 changes: 26 additions & 0 deletions tests/output/stream_isatty_out-err.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--TEST--
Test stream_isatty with redirected STDOUT/STDERR
--CAPTURE_STDIO--
STDOUT STDERR
--FILE--
<?php
require dirname(__FILE__).'/stream_isatty.inc';
testToStdOut();
?>
--EXPECTF--
STDIN (constant): bool(true)
STDIN (fopen): bool(true)
STDIN (php://fd/0): bool(true)
STDOUT (constant): bool(false)
STDOUT (fopen): bool(false)
STDOUT (php://f 57AE d/1): bool(false)
STDERR (constant): bool(false)
STDERR (fopen): bool(false)
STDERR (php://fd/2): bool(false)
Not a stream:
Warning: stream_isatty() expects parameter 1 to be resource, string given in %s on line %d
bool(false)
Invalid stream (php://temp): bool(false)
Invalid stream (php://input): bool(false)
Invalid stream (php://memory): bool(false)
File stream: bool(false)
26 changes: 26 additions & 0 deletions tests/output/stream_isatty_out.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--TEST--
Test stream_isatty with redirected STDOUT
--CAPTURE_STDIO--
STDOUT
--FILE--
<?php
require dirname(__FILE__).'/stream_isatty.inc';
testToStdOut();
?>
--EXPECTF--
STDIN (constant): bool(true)
STDIN (fopen): bool(true)
STDIN (php://fd/0): bool(true)
STDOUT (constant): bool(false)
STDOUT (fopen): bool(false)
STDOUT (php://fd/1): bool(false)
STDERR (constant): bool(true)
STDERR (fopen): bool(true)
STDERR (php://fd/2): bool(true)
Not a stream:
Warning: stream_isatty() expects parameter 1 to be resource, string given in %s on line %d
bool(false)
Invalid stream (php://temp): bool(false)
Invalid stream (php://input): bool(false)
Invalid stream (php://memory): bool(false)
File stream: bool(false)
0