Skip to content

Rename the diffutils binary to diff, #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
File renamed without changes.
32 changes: 16 additions & 16 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use tempfile::{tempdir, NamedTempFile};

#[test]
fn unknown_param() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin("diffutils")?;
let mut cmd = Command::cargo_bin("diff")?;
cmd.arg("--foobar");
cmd.assert()
.code(predicate::eq(2))
Expand All @@ -31,21 +31,21 @@ fn cannot_read_files() -> Result<(), Box<dyn std::error::Error>> {
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))
Expand All @@ -59,7 +59,7 @@ fn cannot_read_files() -> Result<(), Box<dyn std::error::Error>> {
fn no_differences() -> Result<(), Box<dyn std::error::Error>> {
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);
}
Expand All @@ -78,7 +78,7 @@ fn no_differences_report_identical_files() -> Result<(), Box<dyn std::error::Err
let mut file1 = NamedTempFile::new()?;
file1.write_all("foo\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);
}
Expand All @@ -96,7 +96,7 @@ fn no_differences_report_identical_files() -> Result<(), Box<dyn std::error::Err
let mut file2 = NamedTempFile::new()?;
file2.write_all("foo\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);
}
Expand All @@ -120,7 +120,7 @@ fn differences() -> Result<(), Box<dyn std::error::Error>> {
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);
}
Expand All @@ -140,7 +140,7 @@ fn differences_brief() -> Result<(), Box<dyn std::error::Error>> {
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);
}
Expand All @@ -163,7 +163,7 @@ fn missing_newline() -> Result<(), Box<dyn std::error::Error>> {
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))
Expand All @@ -179,7 +179,7 @@ fn read_from_stdin() -> Result<(), Box<dyn std::error::Error>> {
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("-")
Expand All @@ -195,7 +195,7 @@ fn read_from_stdin() -> Result<(), Box<dyn std::error::Error>> {
)
);

let mut cmd = Command::cargo_bin("diffutils")?;
let mut cmd = Command::cargo_bin("diff")?;
cmd.arg("-u")
.arg("-")
.arg(file2.path())
Expand All @@ -211,7 +211,7 @@ fn read_from_stdin() -> Result<(), Box<dyn std::error::Error>> {
)
);

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))
Expand All @@ -220,7 +220,7 @@ fn read_from_stdin() -> Result<(), Box<dyn std::error::Error>> {

#[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")
Expand Down Expand Up @@ -255,7 +255,7 @@ fn compare_file_to_directory() -> Result<(), Box<dyn std::error::Error>> {
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();

Expand All @@ -269,7 +269,7 @@ fn compare_file_to_directory() -> Result<(), Box<dyn std::error::Error>> {
)
);

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();

Expand Down
10 changes: 5 additions & 5 deletions tests/run-upstream-testsuite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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"
Expand All @@ -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
Expand Down
Loading