Merge pull request #967 from nathanross/cleanup-tests-squashed

tests: normalize around chaining asserts
This commit is contained in:
Jian Zeng
2016-08-14 13:01:00 +08:00
committed by GitHub
38 changed files with 509 additions and 944 deletions
+31 -63
View File
@@ -1,105 +1,82 @@
use common::util::*;
use std::ffi::OsStr;
static UTIL_NAME: &'static str = "comm";
fn at_and_ucmd() -> (AtPath, UCommand) {
let ts = TestScenario::new(UTIL_NAME);
let ucmd = ts.ucmd();
(ts.fixtures, ucmd)
}
fn new_ucmd() -> UCommand {
TestScenario::new(UTIL_NAME).ucmd()
}
fn comm<A: AsRef<OsStr>, B: AsRef<str>>(args: &[A],
file_stdout_relpath_opt: Option<B>,
error_message_opt: Option<B>) {
let (at, mut ucmd) = at_and_ucmd();
let result = ucmd.args(args)
.run();
assert!(result.success == error_message_opt.is_none());
if let Some(_) = error_message_opt {
assert!(result.stderr.len() > 0);
// assert!(result.stderr.trim_right() == s);
} else {
assert!(result.stderr.len() == 0);
}
if let Some(file_stdout_relpath) = file_stdout_relpath_opt {
assert!(result.stdout == at.read(file_stdout_relpath.as_ref()))
}
}
#[test]
fn ab_no_args() {
comm(&["a", "b"], Some("ab.expected"), None);
new_ucmd().args(&["a", "b"]).succeeds().stdout_only_fixture("ab.expected");
}
#[test]
fn ab_dash_one() {
comm(&["a", "b", "-1"], Some("ab1.expected"), None);
new_ucmd().args(&["a", "b", "-1"]).succeeds().stdout_only_fixture("ab1.expected");
}
#[test]
fn ab_dash_two() {
comm(&["a", "b", "-2"], Some("ab2.expected"), None);
new_ucmd().args(&["a", "b", "-2"]).succeeds().stdout_only_fixture("ab2.expected");
}
#[test]
fn ab_dash_three() {
comm(&["a", "b", "-3"], Some("ab3.expected"), None);
new_ucmd().args(&["a", "b", "-3"]).succeeds().stdout_only_fixture("ab3.expected");
}
#[test]
fn aempty() {
comm(&["a", "empty"], Some("aempty.expected"), None);
new_ucmd().args(&["a", "empty"]).succeeds().stdout_only_fixture("aempty.expected");
}
#[test]
fn emptyempty() {
comm(&["empty", "empty"], Some("emptyempty.expected"), None);
new_ucmd().args(&["empty", "empty"]).succeeds().stdout_only_fixture("emptyempty.expected");
}
#[cfg_attr(not(feature="test_unimplemented"),ignore)]
#[test]
fn output_delimiter() {
comm(&["--output-delimiter=word", "a", "b"],
Some("ab_delimiter_word.expected"),
None);
new_ucmd().args(&["--output-delimiter=word", "a", "b"])
.succeeds().stdout_only_fixture("ab_delimiter_word.expected");
}
#[cfg_attr(not(feature="test_unimplemented"),ignore)]
#[test]
fn output_delimiter_require_arg() {
comm(&["--output-delimiter=", "a", "b"],
None,
Some("error to be defined"));
new_ucmd().args(&["--output-delimiter=", "a", "b"])
.fails().stderr_only("error to be defined");
}
// even though (info) documentation suggests this is an option
// in latest GNU Coreutils comm, it actually is not.
// this test is essentially an alarm in case someone well-intendingly
// implements it.
//marked as unimplemented as error message not set yet.
#[cfg_attr(not(feature="test_unimplemented"),ignore)]
#[test]
fn zero_terminated() {
for param in vec!["-z", "--zero-terminated"] {
comm(&[param, "a", "b"], None, Some("error to be defined"));
new_ucmd().args(&[param, "a", "b"]).fails().stderr_only("error to be defined");
}
}
#[cfg_attr(not(feature="test_unimplemented"),ignore)]
#[test]
fn check_order() {
comm(&["--check-order", "bad_order_1", "bad_order_2"],
Some("bad_order12.check_order.expected"),
Some("error to be defined"));
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");
}
#[cfg_attr(not(feature="test_unimplemented"),ignore)]
#[test]
fn nocheck_order() {
comm(&["--nocheck-order", "bad_order_1", "bad_order_2"],
Some("bad_order12.nocheck_order.expected"),
None);
new_ucmd().args(&["--nocheck-order", "bad_order_1", "bad_order_2"])
.succeeds()
.stdout_only_fixture("bad_order12.nocheck_order.expected");
}
// when neither --check-order nor --no-check-order is provided,
@@ -108,7 +85,7 @@ fn nocheck_order() {
#[cfg_attr(not(feature="test_unimplemented"),ignore)]
#[test]
fn defaultcheck_order() {
comm(&["a", "bad_order_1"], None, Some("error to be defined"));
new_ucmd().args(&["a", "bad_order_1"]).fails().stderr_only("error to be defined");
}
// * the first: if both files are not in order, the default behavior is the only
@@ -120,17 +97,17 @@ fn defaultcheck_order() {
#[test]
fn defaultcheck_order_identical_bad_order_files() {
comm(&["bad_order_1", "bad_order_1"],
Some("bad_order11.defaultcheck_order.expected"),
None);
new_ucmd().args(&["bad_order_1", "bad_order_1"])
.succeeds().stdout_only_fixture("bad_order11.defaultcheck_order.expected");
}
#[cfg_attr(not(feature="test_unimplemented"),ignore)]
#[test]
fn defaultcheck_order_two_different_bad_order_files() {
comm(&["bad_order_1", "bad_order_2"],
Some("bad_order12.nocheck_order.expected"),
Some("error to be defined"));
new_ucmd().args(&["bad_order_1", "bad_order_2"])
.fails()
.stdout_is_fixture("bad_order12.nocheck_order.expected")
.stderr_is("error to be defined");
}
// * the third: (it is not know whether this is a bug or not)
@@ -146,27 +123,18 @@ fn defaultcheck_order_two_different_bad_order_files() {
#[cfg_attr(not(feature="test_unimplemented"),ignore)]
#[test]
fn unintuitive_default_behavior_1() {
comm(&["defaultcheck_unintuitive_1", "defaultcheck_unintuitive_2"],
Some("defaultcheck_unintuitive.expected"),
None);
new_ucmd().args(&["defaultcheck_unintuitive_1", "defaultcheck_unintuitive_2"])
.succeeds().stdout_only_fixture("defaultcheck_unintuitive.expected");
}
#[ignore] //bug? should help be stdout if not called via -h|--help?
#[test]
fn no_arguments() {
let result = new_ucmd()
.run();
assert!(!result.success);
assert!(result.stdout.len() == 0);
assert!(result.stderr.len() > 0);
new_ucmd().fails().no_stdout().no_stderr();
}
#[ignore] //bug? should help be stdout if not called via -h|--help?
#[test]
fn one_argument() {
let result = new_ucmd()
.arg("a").run();
assert!(!result.success);
assert!(result.stdout.len() == 0);
assert!(result.stderr.len() > 0);
new_ucmd().arg("a").fails().no_stdout().no_stderr();
}
+7 -20
View File
@@ -7,40 +7,27 @@ fn new_ucmd() -> UCommand {
#[test]
fn test_path_with_trailing_slashes() {
let dir = "/root/alpha/beta/gamma/delta/epsilon/omega//";
let out = new_ucmd().arg(dir).run().stdout;
assert_eq!(out.trim_right(), "/root/alpha/beta/gamma/delta/epsilon");
new_ucmd().arg("/root/alpha/beta/gamma/delta/epsilon/omega//")
.run().stdout_is("/root/alpha/beta/gamma/delta/epsilon");
}
#[test]
fn test_path_without_trailing_slashes() {
let dir = "/root/alpha/beta/gamma/delta/epsilon/omega";
let out = new_ucmd().arg(dir).run().stdout;
assert_eq!(out.trim_right(), "/root/alpha/beta/gamma/delta/epsilon");
new_ucmd().arg("/root/alpha/beta/gamma/delta/epsilon/omega")
.run().stdout_is("/root/alpha/beta/gamma/delta/epsilon");
}
#[test]
fn test_root() {
let dir = "/";
let out = new_ucmd().arg(dir).run().stdout;
assert_eq!(out.trim_right(), "/");
new_ucmd().arg("/").run().stdout_is("/");
}
#[test]
fn test_pwd() {
let dir = ".";
let out = new_ucmd().arg(dir).run().stdout;
assert_eq!(out.trim_right(), ".");
new_ucmd().arg(".").run().stdout_is(".");
}
#[test]
fn test_empty() {
let dir = "";
let out = new_ucmd().arg(dir).run().stdout;
assert_eq!(out.trim_right(), ".");
new_ucmd().arg("").run().stdout_is(".");
}
+9 -27
View File
@@ -7,48 +7,30 @@ fn new_ucmd() -> UCommand {
#[test]
fn test_simple_arithmetic() {
let out = new_ucmd()
.args(&["1", "+", "1"]).run().stdout;
assert_eq!(out, "2\n");
new_ucmd().args(&["1", "+", "1"]).run().stdout_is("2\n");
let out = new_ucmd()
.args(&["1", "-", "1"]).run().stdout;
assert_eq!(out, "0\n");
new_ucmd().args(&["1", "-", "1"]).run().stdout_is("0\n");
let out = new_ucmd()
.args(&["3", "*", "2"]).run().stdout;
assert_eq!(out, "6\n");
new_ucmd().args(&["3", "*", "2"]).run().stdout_is("6\n");
let out = new_ucmd()
.args(&["4", "/", "2"]).run().stdout;
assert_eq!(out, "2\n");
new_ucmd().args(&["4", "/", "2"]).run().stdout_is("2\n");
}
#[test]
fn test_parenthesis() {
let out = new_ucmd()
.args(&["(", "1", "+", "1", ")", "*", "2"]).run().stdout;
assert_eq!(out, "4\n");
new_ucmd().args(&["(", "1", "+", "1", ")", "*", "2"]).run().stdout_is("4\n");
}
#[test]
fn test_or() {
let out = new_ucmd()
.args(&["0", "|", "foo"]).run().stdout;
assert_eq!(out, "foo\n");
new_ucmd().args(&["0", "|", "foo"]).run().stdout_is("foo\n");
let out = new_ucmd()
.args(&["foo", "|", "bar"]).run().stdout;
assert_eq!(out, "foo\n");
new_ucmd().args(&["foo", "|", "bar"]).run().stdout_is("foo\n");
}
#[test]
fn test_and() {
let out = new_ucmd()
.args(&["foo", "&", "1"]).run().stdout;
assert_eq!(out, "foo\n");
new_ucmd().args(&["foo", "&", "1"]).run().stdout_is("foo\n");
let out = new_ucmd()
.args(&["", "&", "1"]).run().stdout;
assert_eq!(out, "0\n");
new_ucmd().args(&["", "&", "1"]).run().stdout_is("0\n");
}
+1 -2
View File
@@ -166,8 +166,7 @@ fn test_big_primes() {
fn run(instring: &[u8], outstring: &[u8]) {
// now run factor
let out = new_ucmd().run_piped_stdin(instring).stdout;
assert_eq!(out, String::from_utf8(outstring.to_owned()).unwrap());
new_ucmd().pipe_in(instring).run().stdout_is(String::from_utf8(outstring.to_owned()).unwrap());
}
const PRIMES_BY_BITS: &'static [&'static [u64]] = &[PRIMES14, PRIMES15, PRIMES16, PRIMES17,
+1 -3
View File
@@ -7,7 +7,5 @@ fn new_ucmd() -> UCommand {
#[test]
fn test_exit_code() {
let exit_status = new_ucmd()
.run().success;
assert_eq!(exit_status, false);
new_ucmd().fails();
}
+2 -7
View File
@@ -16,9 +16,7 @@ fn test_default_80_column_wrap() {
#[test]
fn test_40_column_hard_cutoff() {
new_ucmd()
.arg("-w")
.arg("40")
.arg("lorem_ipsum.txt")
.args(&["-w", "40", "lorem_ipsum.txt"])
.run()
.stdout_is_fixture("lorem_ipsum_40_column_hard.expected");
}
@@ -26,10 +24,7 @@ fn test_40_column_hard_cutoff() {
#[test]
fn test_40_column_word_boundary() {
new_ucmd()
.arg("-s")
.arg("-w")
.arg("40")
.arg("lorem_ipsum.txt")
.args(&["-s", "-w", "40", "lorem_ipsum.txt"])
.run()
.stdout_is_fixture("lorem_ipsum_40_column_word.expected");
}
+4 -10
View File
@@ -21,22 +21,16 @@ macro_rules! test_digest {
#[test]
fn test_single_file() {
let (at, mut ucmd) = at_and_ucmd();
let result = ucmd.arg(DIGEST_ARG).arg("input.txt").run();
assert_empty_stderr!(result);
assert!(result.success);
assert_eq!(get_hash!(result.stdout), at.read(EXPECTED_FILE));
assert_eq!(at.read(EXPECTED_FILE),
get_hash!(ucmd.arg(DIGEST_ARG).arg("input.txt").succeeds().no_stderr().stdout));
}
#[test]
fn test_stdin() {
let (at, mut ucmd) = at_and_ucmd();
let input = at.read("input.txt");
let result = ucmd.arg(DIGEST_ARG).run_piped_stdin(input);
assert_empty_stderr!(result);
assert!(result.success);
assert_eq!(get_hash!(result.stdout), at.read(EXPECTED_FILE));
assert_eq!(at.read(EXPECTED_FILE),
get_hash!(ucmd.arg(DIGEST_ARG).pipe_in(input).succeeds().no_stderr().stdout));
}
}
)*)
+14 -38
View File
@@ -12,12 +12,8 @@ fn at_and_ucmd() -> (AtPath, UCommand) {
fn test_install_help() {
let (_, mut ucmd) = at_and_ucmd();
let result = ucmd.arg("--help").run();
assert!(result.success);
assert_empty_stderr!(result);
assert!(result.stdout.contains("Usage:"));
assert!(
ucmd.arg("--help").succeeds().no_stderr().stdout.contains("Usage:"));
}
#[test]
@@ -30,10 +26,7 @@ fn test_install_basic() {
at.touch(file1);
at.touch(file2);
at.mkdir(dir);
let result = ucmd.arg(file1).arg(file2).arg(dir).run();
assert!(result.success);
assert_empty_stderr!(result);
ucmd.arg(file1).arg(file2).arg(dir).succeeds().no_stderr();
assert!(at.file_exists(file1));
assert!(at.file_exists(file2));
@@ -50,10 +43,8 @@ fn test_install_unimplemented_arg() {
at.touch(file);
at.mkdir(dir);
let result = ucmd.arg(context_arg).arg(file).arg(dir).run();
assert!(!result.success);
assert!(result.stderr.contains("Unimplemented"));
assert!(ucmd.arg(context_arg).arg(file).arg(dir)
.fails().stderr.contains("Unimplemented"));
assert!(!at.file_exists(&format!("{}/{}", dir, file)));
}
@@ -66,10 +57,8 @@ fn test_install_component_directories() {
let component3 = "test_install_target_dir_component_c3";
let directories_arg = "-d";
let result = ucmd.arg(directories_arg).arg(component1).arg(component2).arg(component3).run();
assert!(result.success);
assert_empty_stderr!(result);
ucmd.args(&[directories_arg, component1, component2, component3])
.succeeds().no_stderr();
assert!(at.dir_exists(component1));
assert!(at.dir_exists(component2));
@@ -83,10 +72,8 @@ fn test_install_component_directories_failing() {
let directories_arg = "-d";
at.mkdir(component);
let result = ucmd.arg(directories_arg).arg(component).run();
assert!(!result.success);
assert!(result.stderr.contains("File exists"));
assert!(ucmd.arg(directories_arg).arg(component)
.fails().stderr.contains("File exists"));
}
#[test]
@@ -98,10 +85,7 @@ fn test_install_mode_numeric() {
at.touch(file);
at.mkdir(dir);
let result = ucmd.arg(file).arg(dir).arg(mode_arg).run();
assert!(result.success);
assert_empty_stderr!(result);
ucmd.arg(file).arg(dir).arg(mode_arg).succeeds().no_stderr();
let dest_file = &format!("{}/{}", dir, file);
assert!(at.file_exists(file));
@@ -119,10 +103,7 @@ fn test_install_mode_symbolic() {
at.touch(file);
at.mkdir(dir);
let result = ucmd.arg(file).arg(dir).arg(mode_arg).run();
assert!(result.success);
assert_empty_stderr!(result);
ucmd.arg(file).arg(dir).arg(mode_arg).succeeds().no_stderr();
let dest_file = &format!("{}/{}", dir, file);
assert!(at.file_exists(file));
@@ -140,10 +121,8 @@ fn test_install_mode_failing() {
at.touch(file);
at.mkdir(dir);
let result = ucmd.arg(file).arg(dir).arg(mode_arg).run();
assert!(!result.success);
assert!(result.stderr.contains("Invalid mode string: numeric parsing error"));
assert!(ucmd.arg(file).arg(dir).arg(mode_arg)
.fails().stderr.contains("Invalid mode string: numeric parsing error"));
let dest_file = &format!("{}/{}", dir, file);
assert!(at.file_exists(file));
@@ -157,10 +136,7 @@ fn test_install_mode_directories() {
let directories_arg = "-d";
let mode_arg = "--mode=333";
let result = ucmd.arg(directories_arg).arg(component).arg(mode_arg).run();
assert!(result.success);
assert_empty_stderr!(result);
ucmd.arg(directories_arg).arg(component).arg(mode_arg).succeeds().no_stderr();
assert!(at.dir_exists(component));
let permissions = at.metadata(component).permissions();
+5 -12
View File
@@ -17,10 +17,7 @@ fn test_link_existing_file() {
at.write(file, "foobar");
assert!(at.file_exists(file));
let result = ucmd.args(&[file, link]).run();
assert_empty_stderr!(result);
assert!(result.success);
ucmd.args(&[file, link]).succeeds().no_stderr();
assert!(at.file_exists(file));
assert!(at.file_exists(link));
assert_eq!(at.read(file), at.read(link));
@@ -31,10 +28,8 @@ fn test_link_no_circular() {
let (at, mut ucmd) = at_and_ucmd();
let link = "test_link_no_circular";
let result = ucmd.args(&[link, link]).run();
assert_eq!(result.stderr,
"link: error: No such file or directory (os error 2)\n");
assert!(!result.success);
ucmd.args(&[link, link]).fails()
.stderr_is("link: error: No such file or directory (os error 2)\n");
assert!(!at.file_exists(link));
}
@@ -44,10 +39,8 @@ fn test_link_nonexistent_file() {
let file = "test_link_nonexistent_file";
let link = "test_link_nonexistent_file_link";
let result = ucmd.args(&[file, link]).run();
assert_eq!(result.stderr,
"link: error: No such file or directory (os error 2)\n");
assert!(!result.success);
ucmd.args(&[file, link]).fails()
.stderr_is("link: error: No such file or directory (os error 2)\n");
assert!(!at.file_exists(file));
assert!(!at.file_exists(link));
}
+29 -73
View File
@@ -15,9 +15,8 @@ fn test_symlink_existing_file() {
at.touch(file);
let result = ucmd.args(&["-s", file, link]).run();
assert_empty_stderr!(result);
assert!(result.success);
ucmd.args(&["-s", file, link]).succeeds().no_stderr();
assert!(at.file_exists(file));
assert!(at.is_symlink(link));
assert_eq!(at.resolve_link(link), file);
@@ -29,9 +28,7 @@ fn test_symlink_dangling_file() {
let file = "test_symlink_dangling_file";
let link = "test_symlink_dangling_file_link";
let result = ucmd.args(&["-s", file, link]).run();
assert_empty_stderr!(result);
assert!(result.success);
ucmd.args(&["-s", file, link]).succeeds().no_stderr();
assert!(!at.file_exists(file));
assert!(at.is_symlink(link));
assert_eq!(at.resolve_link(link), file);
@@ -45,9 +42,7 @@ fn test_symlink_existing_directory() {
at.mkdir(dir);
let result = ucmd.args(&["-s", dir, link]).run();
assert_empty_stderr!(result);
assert!(result.success);
ucmd.args(&["-s", dir, link]).succeeds().no_stderr();
assert!(at.dir_exists(dir));
assert!(at.is_symlink(link));
assert_eq!(at.resolve_link(link), dir);
@@ -59,9 +54,7 @@ fn test_symlink_dangling_directory() {
let dir = "test_symlink_dangling_dir";
let link = "test_symlink_dangling_dir_link";
let result = ucmd.args(&["-s", dir, link]).run();
assert_empty_stderr!(result);
assert!(result.success);
ucmd.args(&["-s", dir, link]).succeeds().no_stderr();
assert!(!at.dir_exists(dir));
assert!(at.is_symlink(link));
assert_eq!(at.resolve_link(link), dir);
@@ -72,9 +65,7 @@ fn test_symlink_circular() {
let (at, mut ucmd) = at_and_ucmd();
let link = "test_symlink_circular";
let result = ucmd.args(&["-s", link]).run();
assert_empty_stderr!(result);
assert!(result.success);
ucmd.args(&["-s", link]).succeeds().no_stderr();
assert!(at.is_symlink(link));
assert_eq!(at.resolve_link(link), link);
}
@@ -88,8 +79,7 @@ fn test_symlink_dont_overwrite() {
at.touch(file);
at.touch(link);
let result = ucmd.args(&["-s", file, link]).run();
assert!(!result.success);
ucmd.args(&["-s", file, link]).fails();
assert!(at.file_exists(file));
assert!(at.file_exists(link));
assert!(!at.is_symlink(link));
@@ -108,8 +98,7 @@ fn test_symlink_overwrite_force() {
assert_eq!(at.resolve_link(link), file_a);
// Force overwrite of existing symlink
let result = ucmd.args(&["--force", "-s", file_b, link]).run();
assert!(result.success);
ucmd.args(&["--force", "-s", file_b, link]).succeeds();
assert!(at.is_symlink(link));
assert_eq!(at.resolve_link(link), file_b);
}
@@ -124,22 +113,16 @@ fn test_symlink_interactive() {
at.touch(file);
at.touch(link);
let result1 = scene.ucmd()
.args(&["-i", "-s", file, link])
.run_piped_stdin("n");
assert_empty_stderr!(result1);
assert!(result1.success);
scene.ucmd()
.args(&["-i", "-s", file, link])
.pipe_in("n").succeeds().no_stderr();
assert!(at.file_exists(file));
assert!(!at.is_symlink(link));
let result2 = scene.ucmd()
.args(&["-i", "-s", file, link])
.run_piped_stdin("Yesh");
assert_empty_stderr!(result2);
assert!(result2.success);
scene.ucmd()
.args(&["-i", "-s", file, link])
.pipe_in("Yesh").succeeds().no_stderr();
assert!(at.file_exists(file));
assert!(at.is_symlink(link));
@@ -158,10 +141,8 @@ fn test_symlink_simple_backup() {
assert!(at.is_symlink(link));
assert_eq!(at.resolve_link(link), file);
let result = ucmd.args(&["-b", "-s", file, link]).run();
ucmd.args(&["-b", "-s", file, link]).succeeds().no_stderr();
assert_empty_stderr!(result);
assert!(result.success);
assert!(at.file_exists(file));
assert!(at.is_symlink(link));
@@ -186,10 +167,7 @@ fn test_symlink_custom_backup_suffix() {
assert_eq!(at.resolve_link(link), file);
let arg = &format!("--suffix={}", suffix);
let result = ucmd.args(&["-b", arg, "-s", file, link]).run();
assert_empty_stderr!(result);
assert!(result.success);
ucmd.args(&["-b", arg, "-s", file, link]).succeeds().no_stderr();
assert!(at.file_exists(file));
assert!(at.is_symlink(link));
@@ -212,10 +190,7 @@ fn test_symlink_backup_numbering() {
assert!(at.is_symlink(link));
assert_eq!(at.resolve_link(link), file);
let result = ucmd.args(&["-s", "--backup=t", file, link]).run();
assert_empty_stderr!(result);
assert!(result.success);
ucmd.args(&["-s", "--backup=t", file, link]).succeeds().no_stderr();
assert!(at.file_exists(file));
assert!(at.is_symlink(link));
@@ -247,10 +222,7 @@ fn test_symlink_existing_backup() {
assert!(at.is_symlink(link_backup));
assert_eq!(at.resolve_link(link_backup), file);
let result = ucmd.args(&["-s", "--backup=nil", file, link]).run();
assert_empty_stderr!(result);
assert!(result.success);
ucmd.args(&["-s", "--backup=nil", file, link]).succeeds().no_stderr();
assert!(at.file_exists(file));
assert!(at.is_symlink(link_backup));
@@ -271,10 +243,7 @@ fn test_symlink_target_dir() {
at.touch(file_b);
at.mkdir(dir);
let result = ucmd.args(&["-s", "-t", dir, file_a, file_b]).run();
assert_empty_stderr!(result);
assert!(result.success);
ucmd.args(&["-s", "-t", dir, file_a, file_b]).succeeds().no_stderr();
let file_a_link = &format!("{}/{}", dir, file_a);
assert!(at.is_symlink(file_a_link));
@@ -294,10 +263,7 @@ fn test_symlink_overwrite_dir() {
at.touch(path_a);
at.mkdir(path_b);
let result = ucmd.args(&["-s", "-T", path_a, path_b]).run();
assert_empty_stderr!(result);
assert!(result.success);
ucmd.args(&["-s", "-T", path_a, path_b]).succeeds().no_stderr();
assert!(at.file_exists(path_a));
assert!(at.is_symlink(path_b));
@@ -315,18 +281,15 @@ fn test_symlink_overwrite_nonempty_dir() {
at.mkdir(path_b);
at.touch(dummy);
let result = ucmd.args(&["-v", "-T", "-s", path_a, path_b]).run();
// Not same error as GNU; the error message is a Rust builtin
// TODO: test (and implement) correct error message (or at least decide whether to do so)
// Current: "ln: error: Directory not empty (os error 66)"
// GNU: "ln: cannot link 'a' to 'b': Directory not empty"
assert!(result.stderr.len() > 0);
// Verbose output for the link should not be shown on failure
assert!(result.stdout.len() == 0);
assert!(ucmd.args(&["-v", "-T", "-s", path_a, path_b])
.fails().no_stdout().stderr.len() > 0);
assert!(!result.success);
assert!(at.file_exists(path_a));
assert!(at.dir_exists(path_b));
}
@@ -344,11 +307,9 @@ fn test_symlink_errors() {
// $ ln -T -t a b
// ln: cannot combine --target-directory (-t) and --no-target-directory (-T)
let result = ucmd.args(&["-T", "-t", dir, file_a, file_b]).run();
assert_eq!(result.stderr,
"ln: error: cannot combine --target-directory (-t) and --no-target-directory \
ucmd.args(&["-T", "-t", dir, file_a, file_b]).fails()
.stderr_is("ln: error: cannot combine --target-directory (-t) and --no-target-directory \
(-T)\n");
assert!(!result.success);
}
#[test]
@@ -360,16 +321,11 @@ fn test_symlink_verbose() {
at.touch(file_a);
let result = scene.ucmd().args(&["-v", file_a, file_b]).run();
assert_empty_stderr!(result);
assert_eq!(result.stdout, format!("'{}' -> '{}'\n", file_b, file_a));
assert!(result.success);
scene.ucmd().args(&["-v", file_a, file_b])
.succeeds().stdout_only(format!("'{}' -> '{}'\n", file_b, file_a));
at.touch(file_b);
let result = scene.ucmd().args(&["-v", "-b", file_a, file_b]).run();
assert_empty_stderr!(result);
assert_eq!(result.stdout,
format!("'{}' -> '{}' (backup: '{}~')\n", file_b, file_a, file_b));
assert!(result.success);
scene.ucmd().args(&["-v", "-b", file_a, file_b])
.succeeds().stdout_only(format!("'{}' -> '{}' (backup: '{}~')\n", file_b, file_a, file_b));
}
+1 -5
View File
@@ -7,9 +7,5 @@ fn new_ucmd() -> UCommand {
#[test]
fn test_ls_ls() {
let result = new_ucmd().run();
let exit_success = result.success;
assert_eq!(exit_success, true);
new_ucmd().succeeds();
}
+10 -20
View File
@@ -13,41 +13,31 @@ static TEST_DIR5: &'static str = "mkdir_test5/mkdir_test5_1";
#[test]
fn test_mkdir_mkdir() {
let exit_success = new_ucmd()
.arg(TEST_DIR1).run().success;
assert_eq!(exit_success, true);
new_ucmd().arg(TEST_DIR1).succeeds();
}
#[test]
fn test_mkdir_dup_dir() {
let scene = TestScenario::new(UTIL_NAME);
let exit_success = scene.ucmd().arg(TEST_DIR2).run().success;
let exit_success2 = scene.ucmd().arg(TEST_DIR2).run().success;
assert!(exit_success);
assert!(!exit_success2);
scene.ucmd().arg(TEST_DIR2).succeeds();
scene.ucmd().arg(TEST_DIR2).fails();
}
#[test]
fn test_mkdir_mode() {
let exit_success = new_ucmd()
.arg("-m")
.arg("755")
.arg(TEST_DIR3)
.run()
.success;
assert!(exit_success);
new_ucmd()
.arg("-m")
.arg("755")
.arg(TEST_DIR3)
.succeeds();
}
#[test]
fn test_mkdir_parent() {
let exit_success = new_ucmd()
.arg("-p").arg(TEST_DIR4).run().success;
assert!(exit_success);
new_ucmd().arg("-p").arg(TEST_DIR4).succeeds();
}
#[test]
fn test_mkdir_no_parent() {
let exit_success = new_ucmd()
.arg(TEST_DIR5).run().success;
assert!(!exit_success);
new_ucmd().arg(TEST_DIR5).fails();
}
+46 -95
View File
@@ -24,24 +24,14 @@ fn test_mktemp_mktemp() {
let pathname = scene.fixtures.as_string();
let exit_success1 = scene.ucmd().env(TMPDIR, &pathname).arg(TEST_TEMPLATE1).run().success;
let exit_success2 = scene.ucmd().env(TMPDIR, &pathname).arg(TEST_TEMPLATE2).run().success;
let exit_success3 = scene.ucmd().env(TMPDIR, &pathname).arg(TEST_TEMPLATE3).run().success;
let exit_success4 = scene.ucmd().env(TMPDIR, &pathname).arg(TEST_TEMPLATE4).run().success;
let exit_success5 = scene.ucmd().env(TMPDIR, &pathname).arg(TEST_TEMPLATE5).run().success;
let exit_success6 = scene.ucmd().env(TMPDIR, &pathname).arg(TEST_TEMPLATE6).run().success;
let exit_success7 = scene.ucmd().env(TMPDIR, &pathname).arg(TEST_TEMPLATE7).run().success;
let exit_success8 = scene.ucmd().env(TMPDIR, &pathname).arg(TEST_TEMPLATE8).run().success;
assert!(exit_success1);
assert!(!exit_success2);
assert!(!exit_success3);
assert!(!exit_success4);
assert!(exit_success5);
assert!(exit_success6);
assert!(exit_success7);
assert!(!exit_success8);
scene.ucmd().env(TMPDIR, &pathname).arg(TEST_TEMPLATE1).succeeds();
scene.ucmd().env(TMPDIR, &pathname).arg(TEST_TEMPLATE2).fails();
scene.ucmd().env(TMPDIR, &pathname).arg(TEST_TEMPLATE3).fails();
scene.ucmd().env(TMPDIR, &pathname).arg(TEST_TEMPLATE4).fails();
scene.ucmd().env(TMPDIR, &pathname).arg(TEST_TEMPLATE5).succeeds();
scene.ucmd().env(TMPDIR, &pathname).arg(TEST_TEMPLATE6).succeeds();
scene.ucmd().env(TMPDIR, &pathname).arg(TEST_TEMPLATE7).succeeds();
scene.ucmd().env(TMPDIR, &pathname).arg(TEST_TEMPLATE8).fails();
}
#[test]
@@ -50,23 +40,14 @@ fn test_mktemp_make_temp_dir() {
let pathname = scene.fixtures.as_string();
let exit_success1 = scene.ucmd().env(TMPDIR, &pathname).arg("-d").arg(TEST_TEMPLATE1).run().success;
let exit_success2 = scene.ucmd().env(TMPDIR, &pathname).arg("-d").arg(TEST_TEMPLATE2).run().success;
let exit_success3 = scene.ucmd().env(TMPDIR, &pathname).arg("-d").arg(TEST_TEMPLATE3).run().success;
let exit_success4 = scene.ucmd().env(TMPDIR, &pathname).arg("-d").arg(TEST_TEMPLATE4).run().success;
let exit_success5 = scene.ucmd().env(TMPDIR, &pathname).arg("-d").arg(TEST_TEMPLATE5).run().success;
let exit_success6 = scene.ucmd().env(TMPDIR, &pathname).arg("-d").arg(TEST_TEMPLATE6).run().success;
let exit_success7 = scene.ucmd().env(TMPDIR, &pathname).arg("-d").arg(TEST_TEMPLATE7).run().success;
let exit_success8 = scene.ucmd().env(TMPDIR, &pathname).arg("-d").arg(TEST_TEMPLATE8).run().success;
assert!(exit_success1);
assert!(!exit_success2);
assert!(!exit_success3);
assert!(!exit_success4);
assert!(exit_success5);
assert!(exit_success6);
assert!(exit_success7);
assert!(!exit_success8);
scene.ucmd().env(TMPDIR, &pathname).arg("-d").arg(TEST_TEMPLATE1).succeeds();
scene.ucmd().env(TMPDIR, &pathname).arg("-d").arg(TEST_TEMPLATE2).fails();
scene.ucmd().env(TMPDIR, &pathname).arg("-d").arg(TEST_TEMPLATE3).fails();
scene.ucmd().env(TMPDIR, &pathname).arg("-d").arg(TEST_TEMPLATE4).fails();
scene.ucmd().env(TMPDIR, &pathname).arg("-d").arg(TEST_TEMPLATE5).succeeds();
scene.ucmd().env(TMPDIR, &pathname).arg("-d").arg(TEST_TEMPLATE6).succeeds();
scene.ucmd().env(TMPDIR, &pathname).arg("-d").arg(TEST_TEMPLATE7).succeeds();
scene.ucmd().env(TMPDIR, &pathname).arg("-d").arg(TEST_TEMPLATE8).fails();
}
#[test]
@@ -75,35 +56,25 @@ fn test_mktemp_dry_run() {
let pathname = scene.fixtures.as_string();
let exit_success1 = scene.ucmd().env(TMPDIR, &pathname).arg("-u").arg(TEST_TEMPLATE1).run().success;
let exit_success2 = scene.ucmd().env(TMPDIR, &pathname).arg("-u").arg(TEST_TEMPLATE2).run().success;
let exit_success3 = scene.ucmd().env(TMPDIR, &pathname).arg("-u").arg(TEST_TEMPLATE3).run().success;
let exit_success4 = scene.ucmd().env(TMPDIR, &pathname).arg("-u").arg(TEST_TEMPLATE4).run().success;
let exit_success5 = scene.ucmd().env(TMPDIR, &pathname).arg("-u").arg(TEST_TEMPLATE5).run().success;
let exit_success6 = scene.ucmd().env(TMPDIR, &pathname).arg("-u").arg(TEST_TEMPLATE6).run().success;
let exit_success7 = scene.ucmd().env(TMPDIR, &pathname).arg("-u").arg(TEST_TEMPLATE7).run().success;
let exit_success8 = scene.ucmd().env(TMPDIR, &pathname).arg("-u").arg(TEST_TEMPLATE8).run().success;
scene.ucmd().env(TMPDIR, &pathname).arg("-u").arg(TEST_TEMPLATE1).succeeds();
scene.ucmd().env(TMPDIR, &pathname).arg("-u").arg(TEST_TEMPLATE2).fails();
scene.ucmd().env(TMPDIR, &pathname).arg("-u").arg(TEST_TEMPLATE3).fails();
scene.ucmd().env(TMPDIR, &pathname).arg("-u").arg(TEST_TEMPLATE4).fails();
scene.ucmd().env(TMPDIR, &pathname).arg("-u").arg(TEST_TEMPLATE5).succeeds();
scene.ucmd().env(TMPDIR, &pathname).arg("-u").arg(TEST_TEMPLATE6).succeeds();
scene.ucmd().env(TMPDIR, &pathname).arg("-u").arg(TEST_TEMPLATE7).succeeds();
scene.ucmd().env(TMPDIR, &pathname).arg("-u").arg(TEST_TEMPLATE8).fails();
assert!(exit_success1);
assert!(!exit_success2);
assert!(!exit_success3);
assert!(!exit_success4);
assert!(exit_success5);
assert!(exit_success6);
assert!(exit_success7);
assert!(!exit_success8);
}
#[test]
fn test_mktemp_quiet() {
let scene = TestScenario::new(UTIL_NAME);
let result1 = scene.ucmd().arg("-p").arg("/definitely/not/exist/I/promise").arg("-q").run();
let result2 = scene.ucmd().arg("-d").arg("-p").arg("/definitely/not/exist/I/promise").arg("-q").run();
assert!(result1.stderr.is_empty() && result1.stdout.is_empty() && !result1.success);
assert!(result2.stderr.is_empty() && result2.stdout.is_empty() && !result2.success);
scene.ucmd().arg("-p").arg("/definitely/not/exist/I/promise").arg("-q")
.fails().no_stdout().no_stderr();
scene.ucmd().arg("-d").arg("-p").arg("/definitely/not/exist/I/promise").arg("-q")
.fails().no_stdout().no_stderr();
}
#[test]
@@ -112,49 +83,29 @@ fn test_mktemp_suffix() {
let pathname = scene.fixtures.as_string();
let exit_success1 = scene.ucmd().env(TMPDIR, &pathname).arg("--suffix").arg("suf").arg(TEST_TEMPLATE1).run().success;
let exit_success2 = scene.ucmd().env(TMPDIR, &pathname).arg("--suffix").arg("suf").arg(TEST_TEMPLATE2).run().success;
let exit_success3 = scene.ucmd().env(TMPDIR, &pathname).arg("--suffix").arg("suf").arg(TEST_TEMPLATE3).run().success;
let exit_success4 = scene.ucmd().env(TMPDIR, &pathname).arg("--suffix").arg("suf").arg(TEST_TEMPLATE4).run().success;
let exit_success5 = scene.ucmd().env(TMPDIR, &pathname).arg("--suffix").arg("suf").arg(TEST_TEMPLATE5).run().success;
let exit_success6 = scene.ucmd().env(TMPDIR, &pathname).arg("--suffix").arg("suf").arg(TEST_TEMPLATE6).run().success;
let exit_success7 = scene.ucmd().env(TMPDIR, &pathname).arg("--suffix").arg("suf").arg(TEST_TEMPLATE7).run().success;
let exit_success8 = scene.ucmd().env(TMPDIR, &pathname).arg("--suffix").arg("suf").arg(TEST_TEMPLATE8).run().success;
assert!(exit_success1);
assert!(!exit_success2);
assert!(!exit_success3);
assert!(!exit_success4);
assert!(exit_success5);
assert!(!exit_success6);
assert!(!exit_success7);
assert!(!exit_success8);
scene.ucmd().env(TMPDIR, &pathname).arg("--suffix").arg("suf").arg(TEST_TEMPLATE1).succeeds();
scene.ucmd().env(TMPDIR, &pathname).arg("--suffix").arg("suf").arg(TEST_TEMPLATE2).fails();
scene.ucmd().env(TMPDIR, &pathname).arg("--suffix").arg("suf").arg(TEST_TEMPLATE3).fails();
scene.ucmd().env(TMPDIR, &pathname).arg("--suffix").arg("suf").arg(TEST_TEMPLATE4).fails();
scene.ucmd().env(TMPDIR, &pathname).arg("--suffix").arg("suf").arg(TEST_TEMPLATE5).succeeds();
scene.ucmd().env(TMPDIR, &pathname).arg("--suffix").arg("suf").arg(TEST_TEMPLATE6).fails();
scene.ucmd().env(TMPDIR, &pathname).arg("--suffix").arg("suf").arg(TEST_TEMPLATE7).fails();
scene.ucmd().env(TMPDIR, &pathname).arg("--suffix").arg("suf").arg(TEST_TEMPLATE8).fails();
}
#[test]
fn test_mktemp_tmpdir() {
let scene = TestScenario::new(UTIL_NAME);
let path = TempDir::new_in(scene.fixtures.as_string(), UTIL_NAME).unwrap();
let pathname = path.path().as_os_str();
let path = TempDir::new_in(scene.fixtures.as_string(), UTIL_NAME).unwrap();
let pathname = path.path().as_os_str();
let exit_success1 = scene.ucmd().arg("-p").arg(pathname).arg(TEST_TEMPLATE1).run().success;
let exit_success2 = scene.ucmd().arg("-p").arg(pathname).arg(TEST_TEMPLATE2).run().success;
let exit_success3 = scene.ucmd().arg("-p").arg(pathname).arg(TEST_TEMPLATE3).run().success;
let exit_success4 = scene.ucmd().arg("-p").arg(pathname).arg(TEST_TEMPLATE4).run().success;
let exit_success5 = scene.ucmd().arg("-p").arg(pathname).arg(TEST_TEMPLATE5).run().success;
let exit_success6 = scene.ucmd().arg("-p").arg(pathname).arg(TEST_TEMPLATE6).run().success;
let exit_success7 = scene.ucmd().arg("-p").arg(pathname).arg(TEST_TEMPLATE7).run().success;
let exit_success8 = scene.ucmd().arg("-p").arg(pathname).arg(TEST_TEMPLATE8).run().success;
assert!(exit_success1);
assert!(!exit_success2);
assert!(!exit_success3);
assert!(!exit_success4);
assert!(exit_success5);
assert!(exit_success6);
assert!(exit_success7);
assert!(!exit_success8);
scene.ucmd().arg("-p").arg(pathname).arg(TEST_TEMPLATE1).succeeds();
scene.ucmd().arg("-p").arg(pathname).arg(TEST_TEMPLATE2).fails();
scene.ucmd().arg("-p").arg(pathname).arg(TEST_TEMPLATE3).fails();
scene.ucmd().arg("-p").arg(pathname).arg(TEST_TEMPLATE4).fails();
scene.ucmd().arg("-p").arg(pathname).arg(TEST_TEMPLATE5).succeeds();
scene.ucmd().arg("-p").arg(pathname).arg(TEST_TEMPLATE6).succeeds();
scene.ucmd().arg("-p").arg(pathname).arg(TEST_TEMPLATE7).succeeds();
scene.ucmd().arg("-p").arg(pathname).arg(TEST_TEMPLATE8).fails();
}
+39 -111
View File
@@ -19,9 +19,7 @@ fn test_mv_rename_dir() {
at.mkdir(dir1);
let result = ucmd.arg(dir1).arg(dir2).run();
assert_empty_stderr!(result);
assert!(result.success);
ucmd.arg(dir1).arg(dir2).succeeds().no_stderr();
assert!(at.dir_exists(dir2));
}
@@ -34,10 +32,7 @@ fn test_mv_rename_file() {
at.touch(file1);
let result = ucmd.arg(file1).arg(file2).run();
assert_empty_stderr!(result);
assert!(result.success);
ucmd.arg(file1).arg(file2).succeeds().no_stderr();
assert!(at.file_exists(file2));
}
@@ -50,9 +45,7 @@ fn test_mv_move_file_into_dir() {
at.mkdir(dir);
at.touch(file);
let result = ucmd.arg(file).arg(dir).run();
assert_empty_stderr!(result);
assert!(result.success);
ucmd.arg(file).arg(dir).succeeds().no_stderr();
assert!(at.file_exists(&format!("{}/{}", dir, file)));
}
@@ -69,14 +62,11 @@ fn test_mv_strip_slashes() {
at.mkdir(dir);
at.touch(file);
let result = scene.ucmd().arg(&source).arg(dir).run();
assert!(!result.success);
scene.ucmd().arg(&source).arg(dir).fails();
assert!(!at.file_exists(&format!("{}/{}", dir, file)));
let result = scene.ucmd().arg("--strip-trailing-slashes").arg(source).arg(dir).run();
assert_empty_stderr!(result);
assert!(result.success);
scene.ucmd().arg("--strip-trailing-slashes").arg(source).arg(dir).succeeds().no_stderr();
assert!(at.file_exists(&format!("{}/{}", dir, file)));
}
@@ -92,9 +82,7 @@ fn test_mv_multiple_files() {
at.touch(file_a);
at.touch(file_b);
let result = ucmd.arg(file_a).arg(file_b).arg(target_dir).run();
assert_empty_stderr!(result);
assert!(result.success);
ucmd.arg(file_a).arg(file_b).arg(target_dir).succeeds().no_stderr();
assert!(at.file_exists(&format!("{}/{}", target_dir, file_a)));
assert!(at.file_exists(&format!("{}/{}", target_dir, file_b)));
@@ -111,9 +99,7 @@ fn test_mv_multiple_folders() {
at.mkdir(dir_a);
at.mkdir(dir_b);
let result = ucmd.arg(dir_a).arg(dir_b).arg(target_dir).run();
assert_empty_stderr!(result);
assert!(result.success);
ucmd.arg(dir_a).arg(dir_b).arg(target_dir).succeeds().no_stderr();
assert!(at.dir_exists(&format!("{}/{}", target_dir, dir_a)));
assert!(at.dir_exists(&format!("{}/{}", target_dir, dir_b)));
@@ -130,19 +116,13 @@ fn test_mv_interactive() {
at.touch(file_b);
let result1 = scene.ucmd().arg("-i").arg(file_a).arg(file_b).run_piped_stdin("n");
assert_empty_stderr!(result1);
assert!(result1.success);
scene.ucmd().arg("-i").arg(file_a).arg(file_b).pipe_in("n").succeeds().no_stderr();
assert!(at.file_exists(file_a));
assert!(at.file_exists(file_b));
let result2 = scene.ucmd().arg("-i").arg(file_a).arg(file_b).run_piped_stdin("Yesh");
assert_empty_stderr!(result2);
assert!(result2.success);
scene.ucmd().arg("-i").arg(file_a).arg(file_b).pipe_in("Yesh").succeeds().no_stderr();
assert!(!at.file_exists(file_a));
assert!(at.file_exists(file_b));
@@ -157,9 +137,7 @@ fn test_mv_no_clobber() {
at.touch(file_a);
at.touch(file_b);
let result = ucmd.arg("-n").arg(file_a).arg(file_b).run();
assert_empty_stderr!(result);
assert!(result.success);
ucmd.arg("-n").arg(file_a).arg(file_b).succeeds().no_stderr();
assert!(at.file_exists(file_a));
assert!(at.file_exists(file_b));
@@ -174,9 +152,7 @@ fn test_mv_replace_file() {
at.touch(file_a);
at.touch(file_b);
let result = ucmd.arg(file_a).arg(file_b).run();
assert_empty_stderr!(result);
assert!(result.success);
ucmd.arg(file_a).arg(file_b).succeeds().no_stderr();
assert!(!at.file_exists(file_a));
assert!(at.file_exists(file_b));
@@ -191,9 +167,7 @@ fn test_mv_force_replace_file() {
at.touch(file_a);
at.touch(file_b);
let result = ucmd.arg("--force").arg(file_a).arg(file_b).run();
assert_empty_stderr!(result);
assert!(result.success);
ucmd.arg("--force").arg(file_a).arg(file_b).succeeds().no_stderr();
assert!(!at.file_exists(file_a));
assert!(at.file_exists(file_b));
@@ -207,10 +181,7 @@ fn test_mv_simple_backup() {
at.touch(file_a);
at.touch(file_b);
let result = ucmd.arg("-b").arg(file_a).arg(file_b).run();
assert_empty_stderr!(result);
assert!(result.success);
ucmd.arg("-b").arg(file_a).arg(file_b).succeeds().no_stderr();
assert!(!at.file_exists(file_a));
assert!(at.file_exists(file_b));
@@ -226,14 +197,11 @@ fn test_mv_custom_backup_suffix() {
at.touch(file_a);
at.touch(file_b);
let result = ucmd.arg("-b")
.arg(format!("--suffix={}", suffix))
.arg(file_a)
.arg(file_b)
.run();
assert_empty_stderr!(result);
assert!(result.success);
ucmd.arg("-b")
.arg(format!("--suffix={}", suffix))
.arg(file_a)
.arg(file_b)
.succeeds().no_stderr();
assert!(!at.file_exists(file_a));
assert!(at.file_exists(file_b));
@@ -248,10 +216,7 @@ fn test_mv_backup_numbering() {
at.touch(file_a);
at.touch(file_b);
let result = ucmd.arg("--backup=t").arg(file_a).arg(file_b).run();
assert_empty_stderr!(result);
assert!(result.success);
ucmd.arg("--backup=t").arg(file_a).arg(file_b).succeeds().no_stderr();
assert!(!at.file_exists(file_a));
assert!(at.file_exists(file_b));
@@ -269,10 +234,7 @@ fn test_mv_existing_backup() {
at.touch(file_a);
at.touch(file_b);
at.touch(file_b_backup);
let result = ucmd.arg("--backup=nil").arg(file_a).arg(file_b).run();
assert_empty_stderr!(result);
assert!(result.success);
ucmd.arg("--backup=nil").arg(file_a).arg(file_b).succeeds().no_stderr();
assert!(!at.file_exists(file_a));
assert!(at.file_exists(file_b));
@@ -295,18 +257,12 @@ fn test_mv_update_option() {
filetime::set_file_times(at.plus_as_string(file_a), now, now).unwrap();
filetime::set_file_times(at.plus_as_string(file_b), now, later).unwrap();
let result1 = scene.ucmd().arg("--update").arg(file_a).arg(file_b).run();
assert_empty_stderr!(result1);
assert!(result1.success);
scene.ucmd().arg("--update").arg(file_a).arg(file_b).run();
assert!(at.file_exists(file_a));
assert!(at.file_exists(file_b));
let result2 = scene.ucmd().arg("--update").arg(file_b).arg(file_a).run();
assert_empty_stderr!(result2);
assert!(result2.success);
scene.ucmd().arg("--update").arg(file_b).arg(file_a).succeeds().no_stderr();
assert!(at.file_exists(file_a));
assert!(!at.file_exists(file_b));
@@ -322,10 +278,7 @@ fn test_mv_target_dir() {
at.touch(file_a);
at.touch(file_b);
at.mkdir(dir);
let result = ucmd.arg("-t").arg(dir).arg(file_a).arg(file_b).run();
assert_empty_stderr!(result);
assert!(result.success);
ucmd.arg("-t").arg(dir).arg(file_a).arg(file_b).succeeds().no_stderr();
assert!(!at.file_exists(file_a));
assert!(!at.file_exists(file_b));
@@ -341,10 +294,7 @@ fn test_mv_overwrite_dir() {
at.mkdir(dir_a);
at.mkdir(dir_b);
let result = ucmd.arg("-T").arg(dir_a).arg(dir_b).run();
assert_empty_stderr!(result);
assert!(result.success);
ucmd.arg("-T").arg(dir_a).arg(dir_b).succeeds().no_stderr();
assert!(!at.dir_exists(dir_a));
assert!(at.dir_exists(dir_b));
@@ -360,18 +310,14 @@ fn test_mv_overwrite_nonempty_dir() {
at.mkdir(dir_a);
at.mkdir(dir_b);
at.touch(dummy);
let result = ucmd.arg("-vT").arg(dir_a).arg(dir_b).run();
// Not same error as GNU; the error message is a rust builtin
// TODO: test (and implement) correct error message (or at least decide whether to do so)
// Current: "mv: error: couldn't rename path (Directory not empty; from=a; to=b)"
// GNU: "mv: cannot move a to b: Directory not empty"
assert!(result.stderr.len() > 0);
// Verbose output for the move should not be shown on failure
assert!(result.stdout.len() == 0);
assert!(ucmd.arg("-vT").arg(dir_a).arg(dir_b).fails().no_stdout().stderr.len() > 0);
assert!(!result.success);
assert!(at.dir_exists(dir_a));
assert!(at.dir_exists(dir_b));
}
@@ -384,15 +330,11 @@ fn test_mv_backup_dir() {
at.mkdir(dir_a);
at.mkdir(dir_b);
let result = ucmd.arg("-vbT").arg(dir_a).arg(dir_b).run();
assert_empty_stderr!(result);
assert_eq!(result.stdout,
format!("{} -> {} (backup: {}~)\n",
ucmd.arg("-vbT").arg(dir_a).arg(dir_b).succeeds()
.stdout_only(format!("{} -> {} (backup: {}~)\n",
dir_a,
dir_b,
dir_b));
assert!(result.success);
assert!(!at.dir_exists(dir_a));
assert!(at.dir_exists(dir_b));
@@ -412,28 +354,21 @@ fn test_mv_errors() {
// $ mv -T -t a b
// mv: cannot combine --target-directory (-t) and --no-target-directory (-T)
let result = scene.ucmd().arg("-T").arg("-t").arg(dir).arg(file_a).arg(file_b).run();
assert_eq!(result.stderr,
"mv: error: cannot combine --target-directory (-t) and --no-target-directory \
scene.ucmd().arg("-T").arg("-t").arg(dir).arg(file_a).arg(file_b).fails()
.stderr_is("mv: error: cannot combine --target-directory (-t) and --no-target-directory \
(-T)\n");
assert!(!result.success);
// $ at.touch file && at.mkdir dir
// $ mv -T file dir
// err == mv: cannot overwrite directory dir with non-directory
let result = scene.ucmd().arg("-T").arg(file_a).arg(dir).run();
assert_eq!(result.stderr,
format!("mv: error: cannot overwrite directory {} with non-directory\n",
scene.ucmd().arg("-T").arg(file_a).arg(dir).fails()
.stderr_is(format!("mv: error: cannot overwrite directory {} with non-directory\n",
dir));
assert!(!result.success);
// $ at.mkdir dir && at.touch file
// $ mv dir file
// err == mv: cannot overwrite non-directory file with directory dir
let result = scene.ucmd().arg(dir).arg(file_a).run();
assert!(result.stderr.len() > 0);
assert!(!result.success);
assert!(scene.ucmd().arg(dir).arg(file_a).fails().stderr.len() > 0);
}
#[test]
@@ -447,22 +382,15 @@ fn test_mv_verbose() {
at.touch(file_a);
at.touch(file_b);
let result = scene.ucmd().arg("-v").arg(file_a).arg(file_b).run();
assert_empty_stderr!(result);
assert_eq!(result.stdout,
format!("{} -> {}\n", file_a, file_b));
assert!(result.success);
scene.ucmd().arg("-v").arg(file_a).arg(file_b).succeeds()
.stdout_only(format!("{} -> {}\n", file_a, file_b));
at.touch(file_a);
let result = scene.ucmd().arg("-vb").arg(file_a).arg(file_b).run();
assert_empty_stderr!(result);
assert_eq!(result.stdout,
format!("{} -> {} (backup: {}~)\n",
file_a,
file_b,
file_b));
assert!(result.success);
scene.ucmd().arg("-vb").arg(file_a).arg(file_b).succeeds()
.stdout_only(format!("{} -> {} (backup: {}~)\n",
file_a,
file_b,
file_b));
}
// Todo:
+14 -15
View File
@@ -7,23 +7,22 @@ fn new_ucmd() -> UCommand {
#[test]
fn test_stdin_nonewline() {
let result = new_ucmd()
.run_piped_stdin("No Newline".as_bytes());
assert_eq!(result.stdout, " 1\tNo Newline\n");
new_ucmd().pipe_in("No Newline").run().stdout_is(" 1\tNo Newline\n");
}
#[test]
fn test_stdin_newline() {
let result = new_ucmd()
new_ucmd()
.args(&["-s", "-", "-w", "1"])
.run_piped_stdin("Line One\nLine Two\n".as_bytes());
assert_eq!(result.stdout, "1-Line One\n2-Line Two\n");
.pipe_in("Line One\nLine Two\n")
.run()
.stdout_is("1-Line One\n2-Line Two\n");
}
#[test]
fn test_padding_without_overflow() {
let result = new_ucmd()
.args(&["-i", "1000", "-s", "x", "-n", "rz", "simple.txt"]).run();
assert_eq!(result.stdout,
new_ucmd()
.args(&["-i", "1000", "-s", "x", "-n", "rz", "simple.txt"]).run()
.stdout_is(
"000001xL1\n001001xL2\n002001xL3\n003001xL4\n004001xL5\n005001xL6\n006001xL7\n0070\
01xL8\n008001xL9\n009001xL10\n010001xL11\n011001xL12\n012001xL13\n013001xL14\n014\
001xL15\n");
@@ -31,9 +30,9 @@ fn test_padding_without_overflow() {
#[test]
fn test_padding_with_overflow() {
let result = new_ucmd()
.args(&["-i", "1000", "-s", "x", "-n", "rz", "-w", "4", "simple.txt"]).run();
assert_eq!(result.stdout,
new_ucmd()
.args(&["-i", "1000", "-s", "x", "-n", "rz", "-w", "4", "simple.txt"]).run()
.stdout_is(
"0001xL1\n1001xL2\n2001xL3\n3001xL4\n4001xL5\n5001xL6\n6001xL7\n7001xL8\n8001xL9\n\
9001xL10\n10001xL11\n11001xL12\n12001xL13\n13001xL14\n14001xL15\n");
}
@@ -50,9 +49,9 @@ fn test_sections_and_styles() {
|Followed by 4x empty\n\n\n\n\n9 |Nonempty\n10 |Nonempty\n11 \
|Nonempty.\n")]
.iter() {
let result = new_ucmd()
new_ucmd()
.args(&["-s", "|", "-n", "ln", "-w", "3", "-b", "a", "-l", "5", fixture])
.run();
assert_eq!(result.stdout, output);
.run()
.stdout_is(output);
}
}
+1 -4
View File
@@ -8,10 +8,7 @@ fn new_ucmd() -> UCommand {
#[test]
fn test_combine_pairs_of_lines() {
new_ucmd()
.arg("-s")
.arg("-d")
.arg("\t\n")
.arg("html_colors.txt")
.args(&["-s", "-d", "\t\n", "html_colors.txt"])
.run()
.stdout_is_fixture("html_colors.expected");
}
+6 -14
View File
@@ -8,18 +8,10 @@ fn new_ucmd() -> UCommand {
#[test]
fn test_default_mode() {
// test the default mode
{
// accept some reasonable default
let result = new_ucmd()
.args(&["abc/def"]).run();
assert_eq!(result.stdout, "");
assert!(result.success);
}
{
// fail on long inputs
let result = new_ucmd()
.args(&[repeat_str("test", 20000)]).run();
assert_eq!(result.stdout, "");
assert!(!result.success);
}
// accept some reasonable default
new_ucmd().args(&["abc/def"]).succeeds().no_stdout();
// fail on long inputs
new_ucmd().args(&[repeat_str("test", 20000)]).fails().no_stdout();
}
+55 -64
View File
@@ -5,288 +5,279 @@ fn new_ucmd() -> UCommand {
TestScenario::new(UTIL_NAME).ucmd()
}
fn expect_stdout(input: Vec<&str>, expected: &str) {
let results = new_ucmd()
.args(&input).run();
// assert_empty_stderr!(result);
// assert!(result.success);
assert_eq!(expected, results.stdout);
}
#[test]
fn basic_literal() {
expect_stdout(vec!["hello world"], "hello world");
new_ucmd().args(&["hello world"]).succeeds().stdout_only("hello world");
}
#[test]
fn escaped_tab() {
expect_stdout(vec!["hello\\t world"], "hello\t world");
new_ucmd().args(&["hello\\t world"]).succeeds().stdout_only("hello\t world");
}
#[test]
fn escaped_newline() {
expect_stdout(vec!["hello\\n world"], "hello\n world");
new_ucmd().args(&["hello\\n world"]).succeeds().stdout_only("hello\n world");
}
#[test]
fn escaped_slash() {
expect_stdout(vec!["hello\\\\ world"], "hello\\ world");
new_ucmd().args(&["hello\\\\ world"]).succeeds().stdout_only("hello\\ world");
}
#[test]
fn escaped_hex() {
expect_stdout(vec!["\\x41"], "A");
new_ucmd().args(&["\\x41"]).succeeds().stdout_only("A");
}
#[test]
fn escaped_octal() {
expect_stdout(vec!["\\101"], "A");
new_ucmd().args(&["\\101"]).succeeds().stdout_only("A");
}
#[test]
fn escaped_unicode_fourdigit() {
expect_stdout(vec!["\\u0125"], "ĥ");
new_ucmd().args(&["\\u0125"]).succeeds().stdout_only("ĥ");
}
#[test]
fn escaped_unicode_eightdigit() {
expect_stdout(vec!["\\U00000125"], "ĥ");
new_ucmd().args(&["\\U00000125"]).succeeds().stdout_only("ĥ");
}
#[test]
fn escaped_percent_sign() {
expect_stdout(vec!["hello%% world"], "hello% world");
new_ucmd().args(&["hello%% world"]).succeeds().stdout_only("hello% world");
}
#[test]
fn escaped_unrecognized() {
expect_stdout(vec!["c\\d"], "c\\d");
new_ucmd().args(&["c\\d"]).succeeds().stdout_only("c\\d");
}
#[test]
fn sub_string() {
expect_stdout(vec!["hello %s", "world"], "hello world");
new_ucmd().args(&["hello %s", "world"]).succeeds().stdout_only("hello world");
}
#[test]
fn sub_multifield() {
expect_stdout(vec!["%s %s", "hello", "world"], "hello world");
new_ucmd().args(&["%s %s", "hello", "world"]).succeeds().stdout_only("hello world");
}
#[test]
fn sub_repeat_formatstr() {
expect_stdout(vec!["%s.", "hello", "world"], "hello.world.");
new_ucmd().args(&["%s.", "hello", "world"]).succeeds().stdout_only("hello.world.");
}
#[test]
fn sub_string_ignore_escapes() {
expect_stdout(vec!["hello %s", "\\tworld"], "hello \\tworld");
new_ucmd().args(&["hello %s", "\\tworld"]).succeeds().stdout_only("hello \\tworld");
}
#[test]
fn sub_bstring_handle_escapes() {
expect_stdout(vec!["hello %b", "\\tworld"], "hello \tworld");
new_ucmd().args(&["hello %b", "\\tworld"]).succeeds().stdout_only("hello \tworld");
}
#[test]
fn sub_bstring_ignore_subs() {
expect_stdout(vec!["hello %b", "world %% %i"], "hello world %% %i");
new_ucmd().args(&["hello %b", "world %% %i"]).succeeds().stdout_only("hello world %% %i");
}
#[test]
fn sub_char() {
expect_stdout(vec!["the letter %c", "A"], "the letter A");
new_ucmd().args(&["the letter %c", "A"]).succeeds().stdout_only("the letter A");
}
#[test]
fn sub_num_int() {
expect_stdout(vec!["twenty is %i", "20"], "twenty is 20");
new_ucmd().args(&["twenty is %i", "20"]).succeeds().stdout_only("twenty is 20");
}
#[test]
fn sub_num_int_minwidth() {
expect_stdout(vec!["twenty is %1i", "20"], "twenty is 20");
new_ucmd().args(&["twenty is %1i", "20"]).succeeds().stdout_only("twenty is 20");
}
#[test]
fn sub_num_int_neg() {
expect_stdout(vec!["neg. twenty is %i", "-20"], "neg. twenty is -20");
new_ucmd().args(&["neg. twenty is %i", "-20"]).succeeds().stdout_only("neg. twenty is -20");
}
#[test]
fn sub_num_int_oct_in() {
expect_stdout(vec!["twenty is %i", "024"], "twenty is 20");
new_ucmd().args(&["twenty is %i", "024"]).succeeds().stdout_only("twenty is 20");
}
#[test]
fn sub_num_int_oct_in_neg() {
expect_stdout(vec!["neg. twenty is %i", "-024"], "neg. twenty is -20");
new_ucmd().args(&["neg. twenty is %i", "-024"]).succeeds().stdout_only("neg. twenty is -20");
}
#[test]
fn sub_num_int_hex_in() {
expect_stdout(vec!["twenty is %i", "0x14"], "twenty is 20");
new_ucmd().args(&["twenty is %i", "0x14"]).succeeds().stdout_only("twenty is 20");
}
#[test]
fn sub_num_int_hex_in_neg() {
expect_stdout(vec!["neg. twenty is %i", "-0x14"], "neg. twenty is -20");
new_ucmd().args(&["neg. twenty is %i", "-0x14"]).succeeds().stdout_only("neg. twenty is -20");
}
#[test]
fn sub_num_int_charconst_in() {
expect_stdout(vec!["ninetyseven is %i", "'a"], "ninetyseven is 97");
new_ucmd().args(&["ninetyseven is %i", "'a"]).succeeds().stdout_only("ninetyseven is 97");
}
#[test]
fn sub_num_uint() {
expect_stdout(vec!["twenty is %u", "20"], "twenty is 20");
new_ucmd().args(&["twenty is %u", "20"]).succeeds().stdout_only("twenty is 20");
}
#[test]
fn sub_num_octal() {
expect_stdout(vec!["twenty in octal is %o", "20"], "twenty in octal is 24");
new_ucmd().args(&["twenty in octal is %o", "20"]).succeeds().stdout_only("twenty in octal is 24");
}
#[test]
fn sub_num_hex_lower() {
expect_stdout(vec!["thirty in hex is %x", "30"], "thirty in hex is 1e");
new_ucmd().args(&["thirty in hex is %x", "30"]).succeeds().stdout_only("thirty in hex is 1e");
}
#[test]
fn sub_num_hex_upper() {
expect_stdout(vec!["thirty in hex is %X", "30"], "thirty in hex is 1E");
new_ucmd().args(&["thirty in hex is %X", "30"]).succeeds().stdout_only("thirty in hex is 1E");
}
#[test]
fn sub_num_float() {
expect_stdout(vec!["twenty is %f", "20"], "twenty is 20.000000");
new_ucmd().args(&["twenty is %f", "20"]).succeeds().stdout_only("twenty is 20.000000");
}
#[test]
fn sub_num_float_round() {
expect_stdout(vec!["two is %f", "1.9999995"], "two is 2.000000");
new_ucmd().args(&["two is %f", "1.9999995"]).succeeds().stdout_only("two is 2.000000");
}
#[test]
fn sub_num_sci_lower() {
expect_stdout(vec!["twenty is %e", "20"], "twenty is 2.000000e+01");
new_ucmd().args(&["twenty is %e", "20"]).succeeds().stdout_only("twenty is 2.000000e+01");
}
#[test]
fn sub_num_sci_upper() {
expect_stdout(vec!["twenty is %E", "20"], "twenty is 2.000000E+01");
new_ucmd().args(&["twenty is %E", "20"]).succeeds().stdout_only("twenty is 2.000000E+01");
}
#[test]
fn sub_num_sci_trunc() {
expect_stdout(vec!["pi is ~ %e", "3.1415926535"], "pi is ~ 3.141593e+00");
new_ucmd().args(&["pi is ~ %e", "3.1415926535"]).succeeds().stdout_only("pi is ~ 3.141593e+00");
}
#[test]
fn sub_num_dec_trunc() {
expect_stdout(vec!["pi is ~ %g", "3.1415926535"], "pi is ~ 3.141593");
new_ucmd().args(&["pi is ~ %g", "3.1415926535"]).succeeds().stdout_only("pi is ~ 3.141593");
}
#[cfg_attr(not(feature="test_unimplemented"),ignore)]
#[test]
fn sub_num_hex_float_lower() {
expect_stdout(vec!["%a", ".875"], "0xep-4");
new_ucmd().args(&["%a", ".875"]).succeeds().stdout_only("0xep-4");
}
#[cfg_attr(not(feature="test_unimplemented"),ignore)]
#[test]
fn sub_num_hex_float_upper() {
expect_stdout(vec!["%A", ".875"], "0XEP-4");
new_ucmd().args(&["%A", ".875"]).succeeds().stdout_only("0XEP-4");
}
#[test]
fn sub_minwidth() {
expect_stdout(vec!["hello %7s", "world"], "hello world");
new_ucmd().args(&["hello %7s", "world"]).succeeds().stdout_only("hello world");
}
#[test]
fn sub_minwidth_negative() {
expect_stdout(vec!["hello %-7s", "world"], "hello world ");
new_ucmd().args(&["hello %-7s", "world"]).succeeds().stdout_only("hello world ");
}
#[test]
fn sub_str_max_chars_input() {
expect_stdout(vec!["hello %7.2s", "world"], "hello wo");
new_ucmd().args(&["hello %7.2s", "world"]).succeeds().stdout_only("hello wo");
}
#[test]
fn sub_int_decimal() {
expect_stdout(vec!["%0.i", "11"], "11");
new_ucmd().args(&["%0.i", "11"]).succeeds().stdout_only("11");
}
#[test]
fn sub_int_leading_zeroes() {
expect_stdout(vec!["%.4i", "11"], "0011");
new_ucmd().args(&["%.4i", "11"]).succeeds().stdout_only("0011");
}
#[test]
fn sub_int_leading_zeroes_prio() {
expect_stdout(vec!["%5.4i", "11"], " 0011");
new_ucmd().args(&["%5.4i", "11"]).succeeds().stdout_only(" 0011");
}
#[test]
fn sub_float_dec_places() {
expect_stdout(vec!["pi is ~ %.11f", "3.1415926535"],
"pi is ~ 3.14159265350");
new_ucmd().args(&["pi is ~ %.11f", "3.1415926535"]).succeeds().stdout_only("pi is ~ 3.14159265350");
}
#[test]
fn sub_float_hex_in() {
expect_stdout(vec!["%f", "0xF1.1F"], "241.121094");
new_ucmd().args(&["%f", "0xF1.1F"]).succeeds().stdout_only("241.121094");
}
#[test]
fn sub_float_no_octal_in() {
expect_stdout(vec!["%f", "077"], "77.000000");
new_ucmd().args(&["%f", "077"]).succeeds().stdout_only("77.000000");
}
#[test]
fn sub_any_asterisk_firstparam() {
expect_stdout(vec!["%*i", "3", "11", "4", "12"], " 11 12");
new_ucmd().args(&["%*i", "3", "11", "4", "12"]).succeeds().stdout_only(" 11 12");
}
#[test]
fn sub_any_asterisk_second_param() {
expect_stdout(vec!["%.*i", "3", "11", "4", "12"], "0110012");
new_ucmd().args(&["%.*i", "3", "11", "4", "12"]).succeeds().stdout_only("0110012");
}
#[test]
fn sub_any_asterisk_both_params() {
expect_stdout(vec!["%*.*i", "4", "3", "11", "5", "4", "12"], " 011 0012");
new_ucmd().args(&["%*.*i", "4", "3", "11", "5", "4", "12"]).succeeds().stdout_only(" 011 0012");
}
#[test]
fn sub_any_asterisk_octal_arg() {
expect_stdout(vec!["%.*i", "011", "12345678"], "012345678");
new_ucmd().args(&["%.*i", "011", "12345678"]).succeeds().stdout_only("012345678");
}
#[test]
fn sub_any_asterisk_hex_arg() {
expect_stdout(vec!["%.*i", "0xA", "123456789"], "0123456789");
new_ucmd().args(&["%.*i", "0xA", "123456789"]).succeeds().stdout_only("0123456789");
}
#[test]
fn sub_any_specifiers_no_params() {
expect_stdout(vec!["%ztlhLji", "3"], "3");
new_ucmd().args(&["%ztlhLji", "3"]).succeeds().stdout_only("3");
}
#[test]
fn sub_any_specifiers_after_first_param() {
expect_stdout(vec!["%0ztlhLji", "3"], "3");
new_ucmd().args(&["%0ztlhLji", "3"]).succeeds().stdout_only("3");
}
#[test]
fn sub_any_specifiers_after_period() {
expect_stdout(vec!["%0.ztlhLji", "3"], "3");
new_ucmd().args(&["%0.ztlhLji", "3"]).succeeds().stdout_only("3");
}
#[test]
fn sub_any_specifiers_after_second_param() {
expect_stdout(vec!["%0.0ztlhLji", "3"], "3");
new_ucmd().args(&["%0.0ztlhLji", "3"]).succeeds().stdout_only("3");
}
+14 -18
View File
@@ -7,46 +7,42 @@ fn new_ucmd() -> UCommand {
#[test]
fn gnu_ext_disabled_roff_no_ref() {
let opts = vec!["-G", "-R"];
test_ptx(&opts, "gnu_ext_disabled_roff_no_ref.expected");
new_ucmd().args(&["-G", "-R", "input"])
.succeeds().stdout_only_fixture("gnu_ext_disabled_roff_no_ref.expected");
}
#[test]
fn gnu_ext_disabled_roff_input_ref() {
let opts = vec!["-G", "-r", "-R"];
test_ptx(&opts, "gnu_ext_disabled_roff_input_ref.expected");
new_ucmd().args(&["-G", "-r", "-R", "input"])
.succeeds().stdout_only_fixture("gnu_ext_disabled_roff_input_ref.expected");
}
#[test]
fn gnu_ext_disabled_roff_auto_ref() {
let opts = vec!["-G", "-A", "-R"];
test_ptx(&opts, "gnu_ext_disabled_roff_auto_ref.expected");
new_ucmd().args(&["-G", "-A", "-R", "input"])
.succeeds().stdout_only_fixture("gnu_ext_disabled_roff_auto_ref.expected");
}
#[test]
fn gnu_ext_disabled_tex_no_ref() {
let opts = vec!["-G", "-T", "-R"];
test_ptx(&opts, "gnu_ext_disabled_tex_no_ref.expected");
new_ucmd().args(&["-G", "-T", "-R", "input"])
.succeeds().stdout_only_fixture("gnu_ext_disabled_tex_no_ref.expected");
}
#[test]
fn gnu_ext_disabled_tex_input_ref() {
let opts = vec!["-G", "-T", "-r", "-R"];
test_ptx(&opts, "gnu_ext_disabled_tex_input_ref.expected");
new_ucmd().args(&["-G", "-T", "-r", "-R", "input"])
.succeeds().stdout_only_fixture("gnu_ext_disabled_tex_input_ref.expected");
}
#[test]
fn gnu_ext_disabled_tex_auto_ref() {
let opts = vec!["-G", "-T", "-A", "-R"];
test_ptx(&opts, "gnu_ext_disabled_tex_auto_ref.expected");
new_ucmd().args(&["-G", "-T", "-A", "-R", "input"])
.succeeds().stdout_only_fixture("gnu_ext_disabled_tex_auto_ref.expected");
}
#[test]
fn gnu_ext_disabled_ignore_and_only_file() {
let opts = vec!["-G", "-o", "only", "-i", "ignore"];
test_ptx(&opts, "gnu_ext_disabled_ignore_and_only_file.expected");
}
fn test_ptx(opts: &Vec<&str>, expected: &str) {
new_ucmd().args(opts).arg("input").succeeds().stdout_only_fixture(expected);
new_ucmd().args(&["-G", "-o", "only", "-i", "ignore", "input"])
.succeeds().stdout_only_fixture("gnu_ext_disabled_ignore_and_only_file.expected");
}
+1 -4
View File
@@ -10,8 +10,5 @@ fn at_and_ucmd() -> (AtPath, UCommand) {
#[test]
fn test_default() {
let (at, mut ucmd) = at_and_ucmd();
let out = ucmd.run().stdout;
let expected = at.root_dir_resolved();
assert_eq!(out.trim_right(), expected);
ucmd.run().stdout_is(at.root_dir_resolved());
}

Some files were not shown because too many files have changed in this diff Show More