-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
tests/more: run all tests with terminal_simulation #6121
tests/more: run all tests with terminal_simulation #6121
Conversation
Huh, this is weird. The terminal is fixed (even running it several times and in various ways, the terminal never breaks), but now
|
I get the same result as @BenWiederhake: the terminal is fixed and |
Looks like the terminal simulation is broken then, I'll take another look... |
@cre4ture since you implemented the terminal simulation, do you know what could be wrong with stdin? It looks like it keeps hanging. This is also a bug in |
@tertsdiepraam I will take a look into the tests. Afterwards, maybe I can help. |
after investigation, I think the issue is on I compared the behaviour of GNU with uutils: uli@hp13-ulix:~/dev_rust/coreutils$ echo -n "" | more ; echo $?
0
uli@hp13-ulix:~/dev_rust/coreutils$ echo -n "" | target/debug/coreutils more ; echo $?
more: bad usage
Try 'target/debug/coreutils more --help' for more information.
1
uli@hp13-ulix:~/dev_rust/coreutils$ I did some more tests in a similar direction (using The following patch fixes the issue for me. I would have pushed it directly to this PR, but I don't know how to do this. diff --git a/src/uu/more/src/more.rs b/src/uu/more/src/more.rs
index 0b8c838f2..987b48998 100644
--- a/src/uu/more/src/more.rs
+++ b/src/uu/more/src/more.rs
@@ -5,7 +5,7 @@
use std::{
fs::File,
- io::{stdin, stdout, BufReader, Read, Stdout, Write},
+ io::{stdin, stdout, BufReader, IsTerminal, Read, Stdout, Write},
panic::set_hook,
path::Path,
time::Duration,
@@ -158,10 +158,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
}
reset_term(&mut stdout);
} else {
- stdin().read_to_string(&mut buff).unwrap();
- if buff.is_empty() {
+ if stdin().is_terminal() {
return Err(UUsageError::new(1, "bad usage"));
}
+ stdin().read_to_string(&mut buff).unwrap();
let mut stdout = setup_term();
more(&buff, &mut stdout, false, None, None, &mut options)?;
reset_term(&mut stdout); |
@cre4ture Sounds good! Could you put that up as a PR? I do think that somethings up with the terminal simulation though. Or at least some additional configuration might be necessary, where it's possible to simulate a terminal only for output or something like that. Would that make sense? |
true, especially for tools like |
bb33614
to
88d0a4d
Compare
88d0a4d
to
52ed61f
Compare
GNU testsuite comparison:
|
inactive for a while, closing. cc @tertsdiepraam |
Closes #6100
@cakebaker @BenWiederhake, could you check whether this solves the problem for you too?
I think that with this change, we can run the tests in the CI too, but I first want to check whether the issue is fixed. I could also clean this up, but I went with a quick and dirty solution first.