1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37: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 { impl Display for BadSequence {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self { match self {
Self::MissingCharClassName => writeln!(f, "missing character class name '[::]'"), Self::MissingCharClassName => write!(f, "missing character class name '[::]'"),
Self::MissingEquivalentClassChar => { Self::MissingEquivalentClassChar => {
writeln!(f, "missing equivalence class character '[==]'") write!(f, "missing equivalence class character '[==]'")
} }
Self::MultipleCharRepeatInSet2 => { 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 => { 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) => { 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 => { 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"); .stdout_is("zbc");
} }
// FIXME: Since pr https://github.com/uutils/coreutils/pull/4261:
// stderr ends with 2 newlines but expected is only 1.
#[test] #[test]
#[cfg(disabled_until_fixed)]
fn check_against_gnu_tr_tests_null() { fn check_against_gnu_tr_tests_null() {
// ['null', qw(a ''), {IN=>''}, {OUT=>''}, {EXIT=>1}, // ['null', qw(a ''), {IN=>''}, {OUT=>''}, {EXIT=>1},
// {ERR=>"$prog: when not truncating set1, string2 must be non-empty\n"}], // {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"); .stdout_is("1x2");
} }
// FIXME: Since pr https://github.com/uutils/coreutils/pull/4261:
// stderr ends with 2 newlines but expected is only 1.
#[test] #[test]
#[cfg(disabled_until_fixed)]
fn check_against_gnu_tr_tests_o_rep_1() { fn check_against_gnu_tr_tests_o_rep_1() {
// # Another couple octal repeat count tests. // # Another couple octal repeat count tests.
// ['o-rep-1', qw('[b*08]' '[x*]'), {IN=>''}, {OUT=>''}, {EXIT=>1}, // ['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(""); .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] #[test]
fn check_against_gnu_tr_tests_empty_eq() { fn check_against_gnu_tr_tests_empty_eq() {
// # Ensure that these fail. // # Ensure that these fail.
@ -1049,10 +1039,6 @@ fn check_against_gnu_tr_tests_empty_eq() {
.stderr_is("tr: missing equivalence class character '[==]'\n"); .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] #[test]
fn check_against_gnu_tr_tests_empty_cc() { fn check_against_gnu_tr_tests_empty_cc() {
// ['empty-cc', qw('[::]' x), {IN=>''}, {OUT=>''}, {EXIT=>1}, // ['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"); .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] #[test]
fn check_against_gnu_tr_tests_repeat_bs_9() { fn check_against_gnu_tr_tests_repeat_bs_9() {
// # Weird repeat counts. // # Weird repeat counts.