2021-05-30 05:10:54 +00:00
|
|
|
// spell-checker:ignore (words) defaultcheck nocheck
|
|
|
|
|
2020-05-25 17:05:26 +00:00
|
|
|
use crate::common::util::*;
|
2016-05-22 07:46:54 +00:00
|
|
|
|
2016-02-18 14:29:50 +00:00
|
|
|
#[test]
|
|
|
|
fn ab_no_args() {
|
2020-04-13 18:36:03 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.args(&["a", "b"])
|
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("ab.expected");
|
2016-02-18 14:29:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn ab_dash_one() {
|
2020-04-13 18:36:03 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.args(&["a", "b", "-1"])
|
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("ab1.expected");
|
2016-02-18 14:29:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn ab_dash_two() {
|
2020-04-13 18:36:03 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.args(&["a", "b", "-2"])
|
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("ab2.expected");
|
2016-02-18 14:29:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn ab_dash_three() {
|
2020-04-13 18:36:03 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.args(&["a", "b", "-3"])
|
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("ab3.expected");
|
2016-02-18 14:29:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2021-05-30 05:10:54 +00:00
|
|
|
fn a_empty() {
|
2020-04-13 18:36:03 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.args(&["a", "empty"])
|
|
|
|
.succeeds()
|
2021-05-31 03:55:28 +00:00
|
|
|
.stdout_only_fixture("aempty.expected"); // spell-checker:disable-line
|
2016-02-18 14:29:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2021-05-30 05:10:54 +00:00
|
|
|
fn empty_empty() {
|
2020-04-13 18:36:03 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.args(&["empty", "empty"])
|
|
|
|
.succeeds()
|
2021-05-30 05:10:54 +00:00
|
|
|
.stdout_only_fixture("emptyempty.expected"); // spell-checker:disable-line
|
2016-02-18 14:29:50 +00:00
|
|
|
}
|
|
|
|
|
2020-04-13 18:36:03 +00:00
|
|
|
#[cfg_attr(not(feature = "test_unimplemented"), ignore)]
|
2016-02-18 14:29:50 +00:00
|
|
|
#[test]
|
|
|
|
fn output_delimiter() {
|
2020-04-13 18:36:03 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.args(&["--output-delimiter=word", "a", "b"])
|
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("ab_delimiter_word.expected");
|
2016-02-18 14:29:50 +00:00
|
|
|
}
|
|
|
|
|
2020-04-13 18:36:03 +00:00
|
|
|
#[cfg_attr(not(feature = "test_unimplemented"), ignore)]
|
2016-02-18 14:29:50 +00:00
|
|
|
#[test]
|
|
|
|
fn output_delimiter_require_arg() {
|
2020-04-13 18:36:03 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.args(&["--output-delimiter=", "a", "b"])
|
|
|
|
.fails()
|
|
|
|
.stderr_only("error to be defined");
|
2016-02-18 14:29:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// even though (info) documentation suggests this is an option
|
|
|
|
// in latest GNU Coreutils comm, it actually is not.
|
2021-05-30 05:10:54 +00:00
|
|
|
// this test is essentially an alarm in case some well-intending
|
|
|
|
// developer implements it.
|
2016-08-13 21:59:21 +00:00
|
|
|
//marked as unimplemented as error message not set yet.
|
2020-04-13 18:36:03 +00:00
|
|
|
#[cfg_attr(not(feature = "test_unimplemented"), ignore)]
|
2016-02-18 14:29:50 +00:00
|
|
|
#[test]
|
|
|
|
fn zero_terminated() {
|
2021-05-29 12:32:35 +00:00
|
|
|
for ¶m in &["-z", "--zero-terminated"] {
|
2020-04-13 18:36:03 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.args(&[param, "a", "b"])
|
|
|
|
.fails()
|
|
|
|
.stderr_only("error to be defined");
|
2016-02-18 14:29:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-13 18:36:03 +00:00
|
|
|
#[cfg_attr(not(feature = "test_unimplemented"), ignore)]
|
2015-11-28 19:36:29 +00:00
|
|
|
#[test]
|
2016-02-18 14:29:50 +00:00
|
|
|
fn check_order() {
|
2020-04-13 18:36:03 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.args(&["--check-order", "bad_order_1", "bad_order_2"])
|
|
|
|
.fails()
|
|
|
|
.stdout_is_fixture("bad_order12.check_order.expected")
|
|
|
|
.stderr_is("error to be defined");
|
2015-11-28 19:36:29 +00:00
|
|
|
}
|
|
|
|
|
2020-04-13 18:36:03 +00:00
|
|
|
#[cfg_attr(not(feature = "test_unimplemented"), ignore)]
|
2015-11-28 19:36:29 +00:00
|
|
|
#[test]
|
2016-02-18 14:29:50 +00:00
|
|
|
fn nocheck_order() {
|
2020-04-13 18:36:03 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.args(&["--nocheck-order", "bad_order_1", "bad_order_2"])
|
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("bad_order12.nocheck_order.expected");
|
2015-11-28 19:36:29 +00:00
|
|
|
}
|
|
|
|
|
2016-02-18 14:29:50 +00:00
|
|
|
// when neither --check-order nor --no-check-order is provided,
|
|
|
|
// stderr and the error code behaves like check order, but stdout
|
|
|
|
// behaves like nocheck_order. However with some quirks detailed below.
|
2020-04-13 18:36:03 +00:00
|
|
|
#[cfg_attr(not(feature = "test_unimplemented"), ignore)]
|
2015-11-28 19:36:29 +00:00
|
|
|
#[test]
|
2016-02-18 14:29:50 +00:00
|
|
|
fn defaultcheck_order() {
|
2020-04-13 18:36:03 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.args(&["a", "bad_order_1"])
|
|
|
|
.fails()
|
|
|
|
.stderr_only("error to be defined");
|
2015-11-28 19:36:29 +00:00
|
|
|
}
|
|
|
|
|
2016-02-18 14:29:50 +00:00
|
|
|
// * the first: if both files are not in order, the default behavior is the only
|
|
|
|
// behavior that will provide an error message
|
|
|
|
|
|
|
|
// * the second: if two rows are paired but are out of order,
|
|
|
|
// it won't matter if all rows in the two files are exactly the same.
|
|
|
|
// This is specified in the documentation
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn defaultcheck_order_identical_bad_order_files() {
|
2020-04-13 18:36:03 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.args(&["bad_order_1", "bad_order_1"])
|
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("bad_order11.defaultcheck_order.expected");
|
2016-02-18 14:29:50 +00:00
|
|
|
}
|
|
|
|
|
2020-04-13 18:36:03 +00:00
|
|
|
#[cfg_attr(not(feature = "test_unimplemented"), ignore)]
|
2016-02-18 14:29:50 +00:00
|
|
|
#[test]
|
|
|
|
fn defaultcheck_order_two_different_bad_order_files() {
|
2020-04-13 18:36:03 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.args(&["bad_order_1", "bad_order_2"])
|
|
|
|
.fails()
|
|
|
|
.stdout_is_fixture("bad_order12.nocheck_order.expected")
|
|
|
|
.stderr_is("error to be defined");
|
2016-02-18 14:29:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// * the third: (it is not know whether this is a bug or not)
|
|
|
|
// for the first incident, and only the first incident,
|
|
|
|
// where both lines are different and one or both file lines being
|
|
|
|
// compared are out of order from the preceding line,
|
|
|
|
// it is ignored and no errors occur.
|
|
|
|
|
|
|
|
// * the fourth: (it is not known whether this is a bug or not)
|
|
|
|
// there are additional, not-yet-understood circumstances where an out-of-order
|
|
|
|
// pair is ignored and is not counted against the 1 maximum out-of-order line.
|
|
|
|
|
2020-04-13 18:36:03 +00:00
|
|
|
#[cfg_attr(not(feature = "test_unimplemented"), ignore)]
|
2015-11-28 19:36:29 +00:00
|
|
|
#[test]
|
2016-02-18 14:29:50 +00:00
|
|
|
fn unintuitive_default_behavior_1() {
|
2020-04-13 18:36:03 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.args(&["defaultcheck_unintuitive_1", "defaultcheck_unintuitive_2"])
|
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("defaultcheck_unintuitive.expected");
|
2015-11-28 19:36:29 +00:00
|
|
|
}
|
|
|
|
|
2016-02-18 14:29:50 +00:00
|
|
|
#[ignore] //bug? should help be stdout if not called via -h|--help?
|
2015-11-28 19:36:29 +00:00
|
|
|
#[test]
|
2016-02-18 14:29:50 +00:00
|
|
|
fn no_arguments() {
|
2016-08-23 11:52:43 +00:00
|
|
|
new_ucmd!().fails().no_stdout().no_stderr();
|
2015-11-28 19:36:29 +00:00
|
|
|
}
|
|
|
|
|
2016-02-18 14:29:50 +00:00
|
|
|
#[ignore] //bug? should help be stdout if not called via -h|--help?
|
2015-11-28 19:36:29 +00:00
|
|
|
#[test]
|
2016-02-18 14:29:50 +00:00
|
|
|
fn one_argument() {
|
2016-08-23 11:52:43 +00:00
|
|
|
new_ucmd!().arg("a").fails().no_stdout().no_stderr();
|
2015-11-28 19:36:29 +00:00
|
|
|
}
|