1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

tr: Remove the extra newline in stderr

closes #4301
This commit is contained in:
Yang Hau 2023-02-10 22:16:07 +08:00
parent 830f785220
commit ec81a23afc
2 changed files with 24 additions and 20 deletions

View file

@ -37,21 +37,21 @@ pub enum BadSequence {
impl Display for BadSequence {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::MissingCharClassName => writeln!(f, "missing character class name '[::]'"),
Self::MissingCharClassName => write!(f, "missing character class name '[::]'"),
Self::MissingEquivalentClassChar => {
writeln!(f, "missing equivalence class character '[==]'")
write!(f, "missing equivalence class character '[==]'")
}
Self::MultipleCharRepeatInSet2 => {
writeln!(f, "only one [c*] repeat construct may appear in string2")
write!(f, "only one [c*] repeat construct may appear in string2")
}
Self::CharRepeatInSet1 => {
writeln!(f, "the [c*] repeat construct may not appear in string1")
write!(f, "the [c*] repeat construct may not appear in string1")
}
Self::InvalidRepeatCount(count) => {
writeln!(f, "invalid repeat count '{count}' in [c*n] construct")
write!(f, "invalid repeat count '{count}' in [c*n] construct")
}
Self::EmptySet2WhenNotTruncatingSet1 => {
writeln!(f, "when not truncating set1, string2 must be non-empty")
write!(f, "when not truncating set1, string2 must be non-empty")
}
}
}

View file

@ -777,10 +777,7 @@ fn check_against_gnu_tr_tests_range_a_a() {
.stdout_is("zbc");
}
// FIXME: Since pr https://github.com/uutils/coreutils/pull/4261:
// stderr ends with 2 newlines but expected is only 1.
#[test]
#[cfg(disabled_until_fixed)]
fn check_against_gnu_tr_tests_null() {
// ['null', qw(a ''), {IN=>''}, {OUT=>''}, {EXIT=>1},
// {ERR=>"$prog: when not truncating set1, string2 must be non-empty\n"}],
@ -855,10 +852,7 @@ fn check_against_gnu_tr_tests_rep_3() {
.stdout_is("1x2");
}
// FIXME: Since pr https://github.com/uutils/coreutils/pull/4261:
// stderr ends with 2 newlines but expected is only 1.
#[test]
#[cfg(disabled_until_fixed)]
fn check_against_gnu_tr_tests_o_rep_1() {
// # Another couple octal repeat count tests.
// ['o-rep-1', qw('[b*08]' '[x*]'), {IN=>''}, {OUT=>''}, {EXIT=>1},
@ -1032,10 +1026,6 @@ fn check_against_gnu_tr_tests_ross_6() {
.stdout_is("");
}
// FIXME: Since pr https://github.com/uutils/coreutils/pull/4261:
// stderr ends with 2 newlines but expected is only 1.
#[test]
#[cfg(disabled_until_fixed)]
#[test]
fn check_against_gnu_tr_tests_empty_eq() {
// # Ensure that these fail.
@ -1049,10 +1039,6 @@ fn check_against_gnu_tr_tests_empty_eq() {
.stderr_is("tr: missing equivalence class character '[==]'\n");
}
// FIXME: Since pr https://github.com/uutils/coreutils/pull/4261:
// stderr ends with 2 newlines but expected is only 1.
#[test]
#[cfg(disabled_until_fixed)]
#[test]
fn check_against_gnu_tr_tests_empty_cc() {
// ['empty-cc', qw('[::]' x), {IN=>''}, {OUT=>''}, {EXIT=>1},
@ -1064,6 +1050,24 @@ fn check_against_gnu_tr_tests_empty_cc() {
.stderr_is("tr: missing character class name '[::]'\n");
}
#[test]
fn check_against_gnu_tr_tests_repeat_set1() {
new_ucmd!()
.args(&["[a*]", "a"])
.pipe_in("")
.fails()
.stderr_is("tr: the [c*] repeat construct may not appear in string1\n");
}
#[test]
fn check_against_gnu_tr_tests_repeat_set2() {
new_ucmd!()
.args(&["a", "[a*][a*]"])
.pipe_in("")
.fails()
.stderr_is("tr: only one [c*] repeat construct may appear in string2\n");
}
#[test]
fn check_against_gnu_tr_tests_repeat_bs_9() {
// # Weird repeat counts.