mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
users: Avoid > /dev/full panic
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
// spell-checker:ignore (paths) wtmp
|
||||
|
||||
use std::ffi::OsString;
|
||||
use std::io::{Write, stdout};
|
||||
use std::path::Path;
|
||||
|
||||
use clap::builder::ValueParser;
|
||||
@@ -73,7 +74,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
|
||||
if !users.is_empty() {
|
||||
users.sort();
|
||||
println!("{}", users.join(" "));
|
||||
writeln!(stdout().lock(), "{}", users.join(" "))?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -6,6 +6,21 @@ use uutests::new_ucmd;
|
||||
#[cfg(any(target_vendor = "apple", target_os = "linux"))]
|
||||
use uutests::{util::TestScenario, util_name};
|
||||
|
||||
#[ignore = "does not work as same as users > /dev/full"]
|
||||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
fn test_full_panic() {
|
||||
let full = std::fs::OpenOptions::new()
|
||||
.write(true)
|
||||
.open("/dev/full")
|
||||
.unwrap();
|
||||
|
||||
new_ucmd!()
|
||||
.set_stdout(full)
|
||||
.fails()
|
||||
.stderr_contains("No space");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
new_ucmd!().arg("--definitely-invalid").fails_with_code(1);
|
||||
|
||||
Reference in New Issue
Block a user