coreutils/tests/by-util/test_tac.rs
Jeffrey Finkelstein abf4c69b28 tac: correct error message when reading from dir.
Correct the error message produced by `tac` when trying to read from a
directory. Previously if the path 'a' referred to a directory, then
running `tac a` would produce the error message

    dir: read error: Invalid argument

after this commit it produces

    a: read error: Invalid argument

which matches GNU `tac`.
2021-07-25 13:55:24 -04:00

70 lines
1.5 KiB
Rust

use crate::common::util::*;
#[test]
fn test_stdin_default() {
new_ucmd!()
.pipe_in("100\n200\n300\n400\n500")
.run()
.stdout_is("500400\n300\n200\n100\n");
}
#[test]
fn test_stdin_non_newline_separator() {
new_ucmd!()
.args(&["-s", ":"])
.pipe_in("100:200:300:400:500")
.run()
.stdout_is("500400:300:200:100:");
}
#[test]
fn test_stdin_non_newline_separator_before() {
new_ucmd!()
.args(&["-b", "-s", ":"])
.pipe_in("100:200:300:400:500")
.run()
.stdout_is("500:400:300:200:100");
}
#[test]
fn test_single_default() {
new_ucmd!()
.arg("prime_per_line.txt")
.run()
.stdout_is_fixture("prime_per_line.expected");
}
#[test]
fn test_single_non_newline_separator() {
new_ucmd!()
.args(&["-s", ":", "delimited_primes.txt"])
.run()
.stdout_is_fixture("delimited_primes.expected");
}
#[test]
fn test_single_non_newline_separator_before() {
new_ucmd!()
.args(&["-b", "-s", ":", "delimited_primes.txt"])
.run()
.stdout_is_fixture("delimited_primes_before.expected");
}
#[test]
fn test_invalid_input() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
scene
.ucmd()
.arg("b")
.fails()
.stderr_contains("failed to open 'b' for reading: No such file or directory");
at.mkdir("a");
scene
.ucmd()
.arg("a")
.fails()
.stderr_contains("a: read error: Invalid argument");
}