Comments (11)
I just noticed the windows tests are failing. I'm looking into that now. Ill see if I can't figure that out before the end of the week
from atty.
ok. retested with opposite semantics for output streams for appveyor and published new version 0.2.1 which should incorporate the GetStdHandle changes. Thanks so much for your help @retep998 !
from atty.
This is because it is opening $CONOUT
which is always the actual console buffer if there is a console attached. What this should do is GetStdHandle
to get the current stdout handle and check that.
from atty.
It looks like @retep998's suggestion was implemented in this commit: fdabaef
from atty.
It looks like fdabaef hasn't been published to crates.io yet. @softprops Is there anything blocking updating crates.io?
from atty.
@retep998 I pushed a new version but unfortunately I had to rollback my GetStdHandle
approach. So I'm going to leave this open.
Here's some findings
I'm relying soley on appveyor to run my unit tests against various windows targets and they all consistently fail with a 0 return value and a 6 ( invalid handle ) last_error. I ran some tests to compare GetStdHandle
against the result of STD_INPUT_HANDLE
, STD_OUTPUT_HANDLE
, STD_ERROR_HANDLE
against the INVALID_HANDLE
constant and in all cases that seemed fine.
However when passing in that handle to GetConsoleMode
, it would only seem to work for stdin. I did more research and read that GetConsoleScreenBufferInfo
was more reliable than GetConsoleMode
for output streams, but I still ended up getting a 0 return value with last_error value of 6 ( invalid handle ). This is a little frustrating because it's unclear how a handle that does not resolve to INVALID_HANDLE
before being passed into GetConsoleXXX
by last error reports it as being invalid. The only thing that I've been able to consistently get my tests to pass is the CONOUT$
approach.
I could use some win expertise here :) The only thing that I think I could be missing is if, for some reason, the appveyor test environment is actually piping its own output
In the mean time I want to leave this issue open until I can confirm the issue is resolved. I don't have an actual win env to test in myself outside of appveyor. I've provided a short testing/debuging guide in my readme https://github.com/softprops/atty#testing. If one of you gets a chance, can you give something similar to that a try and confirm that the output looks correct.
from atty.
Wanted to drop a pr that kept the GetStdHandle approach open to demonstrate my appveyor test failure #6
from atty.
I could use some win expertise here :) The only thing that I think I could be missing is if, for some reason, the appveyor test environment is actually piping its own output
Exactly this. Appveyor redirects all output to a pipe so that it can capture it. GetStdHandle
returns a valid handle, but that handle is not a console, so is
returning false
is correct. If you really want to test is
returning true
you could probably do FreeConsole
and AllocConsole
which allocates a new console for the process and GetStdHandle
should return handles to that new console.
from atty.
awesome. Thanks @retep998 I'll try and follow up on this tonight. I banged my head against this so hard this weekend I felt like I got a headache :) I wonder why appveyor differs in like that from travis which doesn't seem to do the same.
from atty.
@softprops Thank you for figuring this out!
from atty.
I wonder why appveyor differs in like that from travis which doesn't seem to do the same.
Probably because appveyor is on Windows and travis isn't, and console behavior is quite different between Windows and non-Windows.
from atty.
Related Issues (20)
- add integration tests for various platforms HOT 2
- Compilation failure using rust nightly webassembly target
- Release 1.0 HOT 3
- Consider impl From RawFd for Stream HOT 1
- Does not work correctly for wasm32-unknown-emscripten
- Pipes detected as a tty on MSYS
- Fails to build for Mac OS HOT 2
- Add "isatty" to Cargo.toml keywords HOT 1
- Consider MIT/Apache-2.0 license? HOT 2
- msys check fails with long paths HOT 6
- Build failure because of 2018 edition HOT 4
- Fails tests in captive environments where stdin is closed HOT 2
- Publish a binary package with /example/atty.rs
- Documentation - Goal of the project HOT 2
- Support no_std on windows HOT 1
- Possible soundness bug: alignment not checked
- cron atty::is(atty::Stream::Stdin) HOT 13
- Maintenance status
- Uppdate hermit-abi to v 0.3
- SECURITY: Potential unaligned read HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from atty.