Skip to content
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

Improve isatty support #2349

Merged
merged 2 commits into from
Jul 18, 2022
Merged

Improve isatty support #2349

merged 2 commits into from
Jul 18, 2022

Conversation

saethlin
Copy link
Member

@saethlin saethlin commented Jul 8, 2022

Per #2292 (comment), this is an attempt at

do something more clever with Miri's isatty shim

Since Unix -> Unix is very simple, I'm starting with a patch that just does that. Happy to augment/rewrite this based on feedback.

The linked file in libtest specifically only supports stdout. If we're doing this to support terminal applications, I think it would be strange to support one but not all 3 of the standard streams.

The atty crate contains a bunch of extra logic that libtest does not contain, in order to support MSYS terminals: softprops/atty@db8d55f so I think if we're going to do Windows support, we should probably access all that logic somehow. I think it's pretty clear that the implementation is not going to change, so I think if we want to, pasting the contents of the atty crate into Miri is on the table, instead of taking a dependency.

@RalfJung RalfJung added the S-waiting-on-author Status: Waiting for the PR author to address review comments label Jul 11, 2022
@saethlin saethlin force-pushed the isatty branch 2 times, most recently from 15efc5c to d673a32 Compare July 17, 2022 00:01
src/shims/unix/fs.rs Outdated Show resolved Hide resolved
src/shims/unix/fs.rs Outdated Show resolved Hide resolved
src/shims/unix/fs.rs Outdated Show resolved Hide resolved
src/shims/unix/fs.rs Outdated Show resolved Hide resolved
src/shims/unix/fs.rs Outdated Show resolved Hide resolved
@RalfJung
Copy link
Member

RalfJung commented Jul 17, 2022

Is there anything that can be tested here? We should at least make sure this codepath is executed in ./miri test... maybe by adding something to tests/pass/libc.rs?

@saethlin
Copy link
Member Author

I'm currently tricking Miri into thinking it has a TTY by running unbuffer -p cargo miri test. unbuffer is part of the expect package. I'm not really sure how to turn that into a test though. atty's tests are no help here, unfortunately.

@RalfJung
Copy link
Member

Yeah we cannot check the return value of isatty, but we can at least call it and make sure that does not explode.

@RalfJung
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Jul 18, 2022

📌 Commit eefdeac has been approved by RalfJung

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Jul 18, 2022

⌛ Testing commit eefdeac with merge 8ec3425...

@bors
Copy link
Collaborator

bors commented Jul 18, 2022

☀️ Test successful - checks-actions
Approved by: RalfJung
Pushing 8ec3425 to master...

@bors bors merged commit 8ec3425 into rust-lang:master Jul 18, 2022
@saethlin saethlin deleted the isatty branch July 28, 2022 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: Waiting for the PR author to address review comments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants