mirror of
https://github.com/uutils/diffutils.git
synced 2026-06-10 15:48:59 -07:00
Add tests for diff FILE DIRECTORY
This commit is contained in:
+16
-2
@@ -238,8 +238,6 @@ fn read_from_stdin() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
#[test]
|
||||
fn read_from_directory() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
|
||||
let target = "target/integration";
|
||||
let _ = std::fs::create_dir(target);
|
||||
let directory = &format!("{target}/d");
|
||||
@@ -249,6 +247,7 @@ fn read_from_directory() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut da = File::create(&format!("{directory}/a")).unwrap();
|
||||
da.write_all(b"da\n").unwrap();
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
cmd.arg("-u")
|
||||
.arg(&format!("{target}/d"))
|
||||
.arg(&format!("{target}/a"));
|
||||
@@ -263,5 +262,20 @@ fn read_from_directory() -> Result<(), Box<dyn std::error::Error>> {
|
||||
)
|
||||
);
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
cmd.arg("-u")
|
||||
.arg(&format!("{target}/a"))
|
||||
.arg(&format!("{target}/d"));
|
||||
cmd.assert().code(predicate::eq(1)).failure();
|
||||
|
||||
let output = cmd.output().unwrap().stdout;
|
||||
assert_diff_eq!(
|
||||
output,
|
||||
format!(
|
||||
"--- {}/a\tTIMESTAMP\n+++ {}/d/a\tTIMESTAMP\n@@ -1 +1 @@\n-a\n+da\n",
|
||||
target, target
|
||||
)
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user