Skip to content

Commit d15e762

Browse files
ChrisDrydensylvestre
authored andcommitted
date,comm,tty: add integration tests for write error handling
1 parent 01605c3 commit d15e762

3 files changed

Lines changed: 35 additions & 0 deletions

File tree

tests/by-util/test_comm.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,3 +727,18 @@ fn test_read_error() {
727727
.fails()
728728
.stderr_contains("comm: /proc/self/mem: Input/output error");
729729
}
730+
731+
#[test]
732+
#[cfg(unix)]
733+
fn test_comm_write_error_dev_full() {
734+
use std::fs::OpenOptions;
735+
let scene = TestScenario::new(util_name!());
736+
scene.fixtures.write("a", "a\n");
737+
let dev_full = OpenOptions::new().write(true).open("/dev/full").unwrap();
738+
scene
739+
.ucmd()
740+
.args(&["a", "a"])
741+
.set_stdout(dev_full)
742+
.fails()
743+
.stderr_contains("No space left on device");
744+
}

tests/by-util/test_date.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2066,3 +2066,15 @@ fn test_percent_percent_not_replaced() {
20662066
.stdout_is(expected);
20672067
}
20682068
}
2069+
2070+
#[test]
2071+
#[cfg(unix)]
2072+
fn test_date_write_error_dev_full() {
2073+
use std::fs::OpenOptions;
2074+
let dev_full = OpenOptions::new().write(true).open("/dev/full").unwrap();
2075+
new_ucmd!()
2076+
.arg("+%s")
2077+
.set_stdout(dev_full)
2078+
.fails()
2079+
.stderr_contains("write error");
2080+
}

tests/by-util/test_tty.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,11 @@ fn test_stdout_fail() {
8787
let status = proc.wait().unwrap();
8888
assert_eq!(status.code(), Some(3));
8989
}
90+
91+
#[test]
92+
#[cfg(unix)]
93+
fn test_version_pipe_no_stderr() {
94+
let mut child = new_ucmd!().arg("--version").run_no_wait();
95+
child.close_stdout();
96+
child.wait().unwrap().no_stderr();
97+
}

0 commit comments

Comments
 (0)