Skip to content

Commit f4211cc

Browse files
zxvfcsylvestre
authored andcommitted
Add call of sdiff to main and basic integration test
1 parent ad5706b commit f4211cc

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
@@ -59,7 +59,7 @@ mod common {
5959
#[cfg(windows)]
6060
let error_message = "The system cannot find the file specified.";
6161

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

0 commit comments

Comments
 (0)