-
-
Notifications
You must be signed in to change notification settings - Fork 143
Add logic to new stream functions on Windows #105
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
Conversation
*/ | ||
public function testSapiWindowsVt100Support() | ||
{ | ||
if ('\\' !== DIRECTORY_SEPARATOR) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@requires OSFAMILY ...
instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current code matches the convention we're following, LGTM as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's behind that convention? looks pretty weird to me to not use solution provided by test runner but do it manually
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dunno exactly, maybe just discoverability is better, so more commonly used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll do it whatever way you chaps want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's keep it this way, that's consistent with the code base
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the reason is support for older PHPUnit versions (IIRC, OSFAMILY
was added later)
src/Php72/Php72.php
Outdated
{ | ||
// We cannot actually enable vt100 support | ||
if (true === $enable || !self::stream_isatty($stream)) { | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just wondering if I have got the logic right here, in automatically returning false if the enable param is true. It makes sense in the strictest way, in that you cannot actually enable the setting without using the native function. But in terms of how the polyfill will used, it may be better to remove this bit (because an application would probably always set the enable param to true). Thoughts please.
Also, I haven't covered the case where enable = false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps if (false === $enable ...
would be better, in that one would simply not apply the vt100 formatting sequences, regardless of what the native function would return.
I've changed the logic in The only way to enable support for vt100 sequences in modern Windows consoles is to use the So in userland, an app that outputs vt100 sequences will either enable it early on, or on-demand in an output handler. It would unnecessary to disable it, because an app would simply omit vt100 sequences if they were inappropriate. |
I would trust you on this one, looks 👍 to me. |
@nicolas-grekas Thanks. I reviewed the PR that added this to php-src and contributed some mods and stuff (like the |
@nicolas-grekas Apologies, but I found some Git Bash weirdness happening when testing composer/xdebug-handler In addition, if you invoke |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late review, LGTM, except the tests, which need to be enhanced.
Right now, our CI doesn't use PHP 7.2, I'll do it in another PR.
For now, can you ensure this passes on PHP 7.2 on your Windows machine once comments are addressed?
*/ | ||
public function testSapiWindowsVt100Support() | ||
{ | ||
if ('\\' !== DIRECTORY_SEPARATOR) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's keep it this way, that's consistent with the code base
tests/Php72/Php72Test.php
Outdated
$this->markTestSkipped('Windows only test'); | ||
} | ||
|
||
$this->assertFalse(p::sapi_windows_vt100_support(STDOUT, false)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should make the test pass without the p::
prefix: the testing framework will ensure the test is run twice: with and without the polyfill when possible, so that behavior parity is "proven" on 7.2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we do know it, but as you see it's not obvious, maybe it worth to put that knowledge somewhere? (contributing file perhaps?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@keradus Why not :) The readme has this sentence on the topic:
Polyfills are unit-tested alongside their native implementation so that feature and behavior parity can be proven and enforced in the long run.
Feel free to submit a PR to amend the README.md, or another file that could be a better fit to you.
tests/Php72/Php72Test.php
Outdated
public function testStreamIsatty() | ||
{ | ||
$fp = fopen('php://temp', 'r+'); | ||
$this->assertFalse(p::stream_isatty($fp)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no p::
, see above
@nicolas-grekas To confirm: The tests pass on PHP-7.2 on Windows |
Thank you @johnstevenson. |
The tests are pretty useless, but it is impossible to guarantee what the descriptors are pointing to in all test environments.