fix(tests): use cargo_bin_cmd for apply_patch

This commit is contained in:
James Peter
2025-12-20 21:52:22 +10:00
parent 5aaa7f4b79
commit 03421b9543
3 changed files with 8 additions and 12 deletions
+4 -5
View File
@@ -1,6 +1,5 @@
use assert_cmd::prelude::*;
use std::fs;
use std::process::Command;
use tempfile::tempdir;
#[test]
@@ -16,7 +15,7 @@ fn test_apply_patch_cli_add_and_update() -> anyhow::Result<()> {
+hello
*** End Patch"#
);
Command::new(assert_cmd::cargo::cargo_bin!("apply_patch"))
assert_cmd::cargo::cargo_bin_cmd!("apply_patch")
.arg(add_patch)
.current_dir(tmp.path())
.assert()
@@ -33,7 +32,7 @@ fn test_apply_patch_cli_add_and_update() -> anyhow::Result<()> {
+world
*** End Patch"#
);
Command::new(assert_cmd::cargo::cargo_bin!("apply_patch"))
assert_cmd::cargo::cargo_bin_cmd!("apply_patch")
.arg(update_patch)
.current_dir(tmp.path())
.assert()
@@ -57,7 +56,7 @@ fn test_apply_patch_cli_stdin_add_and_update() -> anyhow::Result<()> {
+hello
*** End Patch"#
);
let mut cmd = Command::new(assert_cmd::cargo::cargo_bin!("apply_patch"));
let mut cmd = assert_cmd::cargo::cargo_bin_cmd!("apply_patch");
cmd.current_dir(tmp.path());
cmd.write_stdin(add_patch)
.assert()
@@ -74,7 +73,7 @@ fn test_apply_patch_cli_stdin_add_and_update() -> anyhow::Result<()> {
+world
*** End Patch"#
);
let mut cmd = Command::new(assert_cmd::cargo::cargo_bin!("apply_patch"));
let mut cmd = assert_cmd::cargo::cargo_bin_cmd!("apply_patch");
cmd.current_dir(tmp.path());
cmd.write_stdin(update_patch)
.assert()
+1 -3
View File
@@ -1,10 +1,8 @@
use assert_cmd::prelude::*;
use pretty_assertions::assert_eq;
use std::collections::BTreeMap;
use std::fs;
use std::path::Path;
use std::path::PathBuf;
use std::process::Command;
use tempfile::tempdir;
#[test]
@@ -36,7 +34,7 @@ fn run_apply_patch_scenario(dir: &Path) -> anyhow::Result<()> {
// Run apply_patch in the temporary directory. We intentionally do not assert
// on the exit status here; the scenarios are specified purely in terms of
// final filesystem state, which we compare below.
Command::new(assert_cmd::cargo::cargo_bin!("apply_patch"))
assert_cmd::cargo::cargo_bin_cmd!("apply_patch")
.arg(patch)
.current_dir(tmp.path())
.output()?;
+3 -4
View File
@@ -1,18 +1,17 @@
use assert_cmd::prelude::*;
use assert_cmd::Command;
use pretty_assertions::assert_eq;
use std::fs;
use std::path::Path;
use std::process::Command;
use tempfile::tempdir;
fn run_apply_patch_in_dir(dir: &Path, patch: &str) -> anyhow::Result<assert_cmd::assert::Assert> {
let mut cmd = Command::new(assert_cmd::cargo::cargo_bin!("apply_patch"));
let mut cmd = assert_cmd::cargo::cargo_bin_cmd!("apply_patch");
cmd.current_dir(dir);
Ok(cmd.arg(patch).assert())
}
fn apply_patch_command(dir: &Path) -> anyhow::Result<Command> {
let mut cmd = Command::new(assert_cmd::cargo::cargo_bin!("apply_patch"));
let mut cmd = assert_cmd::cargo::cargo_bin_cmd!("apply_patch");
cmd.current_dir(dir);
Ok(cmd)
}