Comments (6)
Actually, I'm not entirely certain this is so useful. I was able to relatively cleanly add testing to my own project, so I don't have a strong use case for it. Other projects that use atty might be structured differently and thus benefit from the ability to mock atty, but not mine.
from atty.
Nice. I'll leave this open in case you need it. Also neat project!
from atty.
@casey how did you do this in just
?
This might also be useful for #15.
from atty.
Hmm, it's been a while since I wrote the tests. I think that I had an option to force color, regardless of if we were printing to a terminal, so if I wanted to test formatting I could set that option to be true.
from atty.
We have something like:
fn permission_prompt(message: String) -> DenoResult<()> {
if !atty::is(atty::Stream::Stdin) || !atty::is(atty::Stream::Stderr) { return Err(permission_denied()) };
eprint!("{} Grant? yN", message);
... // more stuff
What maybe you'd want to do is refactor to use dependency injection instead? https://stackoverflow.com/a/28370712/1240268 but then you not able to get an atty::Stream
.
from atty.
Okay, here's one way to fake TTYs in stdin, stdout and stderr:
https://stackoverflow.com/a/52954716/1240268
https://gist.github.com/hayd/4f46a68fc697ba8888a7b517a414583e
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 HOT 1
- 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.