diff --git a/Cargo.toml b/Cargo.toml index fa80fc6..66b7422 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,8 +11,8 @@ name = "diffutilslib" path = "src/lib.rs" [[bin]] -name = "diffutils" -path = "src/main.rs" +name = "diff" +path = "src/diff.rs" [dependencies] chrono = "0.4.38" diff --git a/src/main.rs b/src/diff.rs similarity index 100% rename from src/main.rs rename to src/diff.rs diff --git a/tests/integration.rs b/tests/integration.rs index 9d0cfaf..b88d7d9 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -14,7 +14,7 @@ use tempfile::{tempdir, NamedTempFile}; #[test] fn unknown_param() -> Result<(), Box> { - let mut cmd = Command::cargo_bin("diffutils")?; + let mut cmd = Command::cargo_bin("diff")?; cmd.arg("--foobar"); cmd.assert() .code(predicate::eq(2)) @@ -31,21 +31,21 @@ fn cannot_read_files() -> Result<(), Box> { let nopath = nofile.into_temp_path(); std::fs::remove_file(&nopath)?; - let mut cmd = Command::cargo_bin("diffutils")?; + let mut cmd = Command::cargo_bin("diff")?; cmd.arg(&nopath).arg(file.path()); cmd.assert() .code(predicate::eq(2)) .failure() .stderr(predicate::str::starts_with("Failed to read from-file")); - let mut cmd = Command::cargo_bin("diffutils")?; + let mut cmd = Command::cargo_bin("diff")?; cmd.arg(file.path()).arg(&nopath); cmd.assert() .code(predicate::eq(2)) .failure() .stderr(predicate::str::starts_with("Failed to read to-file")); - let mut cmd = Command::cargo_bin("diffutils")?; + let mut cmd = Command::cargo_bin("diff")?; cmd.arg(&nopath).arg(&nopath); cmd.assert() .code(predicate::eq(2)) @@ -59,7 +59,7 @@ fn cannot_read_files() -> Result<(), Box> { fn no_differences() -> Result<(), Box> { let file = NamedTempFile::new()?; for option in ["", "-u", "-c", "-e"] { - let mut cmd = Command::cargo_bin("diffutils")?; + let mut cmd = Command::cargo_bin("diff")?; if !option.is_empty() { cmd.arg(option); } @@ -78,7 +78,7 @@ fn no_differences_report_identical_files() -> Result<(), Box Result<(), Box Result<(), Box> { let mut file2 = NamedTempFile::new()?; file2.write_all("bar\n".as_bytes())?; for option in ["", "-u", "-c", "-e"] { - let mut cmd = Command::cargo_bin("diffutils")?; + let mut cmd = Command::cargo_bin("diff")?; if !option.is_empty() { cmd.arg(option); } @@ -140,7 +140,7 @@ fn differences_brief() -> Result<(), Box> { let mut file2 = NamedTempFile::new()?; file2.write_all("bar\n".as_bytes())?; for option in ["", "-u", "-c", "-e"] { - let mut cmd = Command::cargo_bin("diffutils")?; + let mut cmd = Command::cargo_bin("diff")?; if !option.is_empty() { cmd.arg(option); } @@ -163,7 +163,7 @@ fn missing_newline() -> Result<(), Box> { file1.write_all("foo".as_bytes())?; let mut file2 = NamedTempFile::new()?; file2.write_all("bar".as_bytes())?; - let mut cmd = Command::cargo_bin("diffutils")?; + let mut cmd = Command::cargo_bin("diff")?; cmd.arg("-e").arg(file1.path()).arg(file2.path()); cmd.assert() .code(predicate::eq(2)) @@ -179,7 +179,7 @@ fn read_from_stdin() -> Result<(), Box> { let mut file2 = NamedTempFile::new()?; file2.write_all("bar\n".as_bytes())?; - let mut cmd = Command::cargo_bin("diffutils")?; + let mut cmd = Command::cargo_bin("diff")?; cmd.arg("-u") .arg(file1.path()) .arg("-") @@ -195,7 +195,7 @@ fn read_from_stdin() -> Result<(), Box> { ) ); - let mut cmd = Command::cargo_bin("diffutils")?; + let mut cmd = Command::cargo_bin("diff")?; cmd.arg("-u") .arg("-") .arg(file2.path()) @@ -211,7 +211,7 @@ fn read_from_stdin() -> Result<(), Box> { ) ); - let mut cmd = Command::cargo_bin("diffutils")?; + let mut cmd = Command::cargo_bin("diff")?; cmd.arg("-u").arg("-").arg("-"); cmd.assert() .code(predicate::eq(0)) @@ -220,7 +220,7 @@ fn read_from_stdin() -> Result<(), Box> { #[cfg(unix)] { - let mut cmd = Command::cargo_bin("diffutils")?; + let mut cmd = Command::cargo_bin("diff")?; cmd.arg("-u") .arg(file1.path()) .arg("/dev/stdin") @@ -255,7 +255,7 @@ fn compare_file_to_directory() -> Result<(), Box> { let mut da = File::create(&da_path).unwrap(); da.write_all(b"da\n").unwrap(); - let mut cmd = Command::cargo_bin("diffutils")?; + let mut cmd = Command::cargo_bin("diff")?; cmd.arg("-u").arg(&directory).arg(&a_path); cmd.assert().code(predicate::eq(1)).failure(); @@ -269,7 +269,7 @@ fn compare_file_to_directory() -> Result<(), Box> { ) ); - let mut cmd = Command::cargo_bin("diffutils")?; + let mut cmd = Command::cargo_bin("diff")?; cmd.arg("-u").arg(&a_path).arg(&directory); cmd.assert().code(predicate::eq(1)).failure(); diff --git a/tests/run-upstream-testsuite.sh b/tests/run-upstream-testsuite.sh index cb59834..f9c89b3 100755 --- a/tests/run-upstream-testsuite.sh +++ b/tests/run-upstream-testsuite.sh @@ -16,9 +16,9 @@ # tests are run might not match exactly that used when the upstream tests are # run through the autotools. -# By default it expects a release build of the diffutils binary, but a -# different build profile can be specified as an argument -# (e.g. 'dev' or 'test'). +# By default it expects a release build of the diff binary, but a different +# build profile can be specified as an argument (e.g. 'dev' or 'test'). + # Unless overridden by the $TESTS environment variable, all tests in the test # suite will be run. Tests targeting a command that is not yet implemented # (e.g. cmp, diff3 or sdiff) are skipped. @@ -31,7 +31,7 @@ profile="release" [[ -n $1 ]] && profile="$1" # Verify that the diffutils binary was built for the requested profile -binary="$scriptpath/../target/$profile/diffutils" +binary="$scriptpath/../target/$profile/diff" if [[ ! -x "$binary" ]] then echo "Missing build for profile $profile" @@ -52,7 +52,7 @@ git sparse-checkout set --no-cone tests &> /dev/null git checkout &> /dev/null upstreamrev=$(git rev-parse HEAD) -# Ensure that calling `diff` invokes the built `diffutils` binary instead of +# Ensure that calling `diff` invokes the built `diff` binary instead of # the upstream `diff` binary that is most likely installed on the system mkdir src cd src