Skip to content

Commit 7355680

Browse files
committed
Add call of sdiff to main and basic integration test
1 parent ed9f154 commit 7355680

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ mod ed_diff;
1818
mod macros;
1919
mod normal_diff;
2020
mod params;
21+
mod sdiff;
2122
mod side_diff;
2223
mod unified_diff;
2324
mod utils;
@@ -72,6 +73,7 @@ fn main() -> ExitCode {
7273
match util_name.to_str() {
7374
Some("diff") => diff::main(args),
7475
Some("cmp") => cmp::main(args),
76+
Some("sdiff") => sdiff::main(args),
7577
Some(name) => {
7678
eprintln!("{name}: utility not supported");
7779
ExitCode::from(2)

tests/integration.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ mod common {
5757
#[cfg(windows)]
5858
let error_message = "The system cannot find the file specified.";
5959

60-
for subcmd in ["diff", "cmp"] {
60+
for subcmd in ["diff", "cmp", "sdiff"] {
6161
let mut cmd = cargo_bin_cmd!("diffutils");
6262
cmd.arg(subcmd);
6363
cmd.arg(&nopath).arg(file.path());
@@ -888,3 +888,27 @@ mod cmp {
888888
Ok(())
889889
}
890890
}
891+
892+
mod sdiff {
893+
use super::*;
894+
895+
#[test]
896+
fn differences() -> Result<(), Box<dyn std::error::Error>> {
897+
let mut file1 = NamedTempFile::new()?;
898+
file1.write_all("foo\n".as_bytes())?;
899+
900+
let mut file2 = NamedTempFile::new()?;
901+
file2.write_all("bar\n".as_bytes())?;
902+
903+
let mut cmd = cargo_bin_cmd!("diffutils");
904+
cmd.arg("diff");
905+
cmd.arg(file1.path()).arg(file2.path());
906+
907+
cmd.assert()
908+
.code(predicate::eq(1))
909+
.failure()
910+
.stdout(predicate::str::is_empty().not());
911+
912+
Ok(())
913+
}
914+
}

0 commit comments

Comments
 (0)