diff --git a/tests/conf_load.rs b/tests/conf_load.rs index 048f6ca..4968621 100644 --- a/tests/conf_load.rs +++ b/tests/conf_load.rs @@ -1,10 +1,10 @@ use std::error::Error; -use assert_cmd::Command; +use assert_cmd::cargo::cargo_bin_cmd; #[test] fn load_conf_directory() -> Result<(), Box> { - let mut cmd = Command::cargo_bin("reaction")?; + let mut cmd = cargo_bin_cmd!("reaction"); cmd.args([ "test-config", "--verbose", @@ -70,7 +70,7 @@ streams: fn example_configs_are_equal() { let outputs = ["config/example.yml", "config/example.jsonnet"] .map(|config_path| { - let mut cmd = Command::cargo_bin("reaction").unwrap(); + let mut cmd = cargo_bin_cmd!("reaction"); cmd.args(["test-config", "--config", config_path]); cmd.assert().success().get_output().stdout.clone() }) diff --git a/tests/end_to_end.rs b/tests/end_to_end.rs index 89e52e0..cfe09d6 100644 --- a/tests/end_to_end.rs +++ b/tests/end_to_end.rs @@ -1,6 +1,6 @@ use std::{error::Error, path::Path, process::Stdio, thread::sleep, time::Duration}; -use assert_cmd::Command; +use assert_cmd::cargo::cargo_bin_cmd; use assert_fs::prelude::*; use nix::sys::signal; use predicates::prelude::predicate; @@ -14,7 +14,7 @@ fn actions_delayed_and_on_exit() -> Result<(), Box> { .child("config.jsonnet") .write_file(Path::new("tests/test-conf/test-after.jsonnet"))?; - let mut cmd = Command::cargo_bin("reaction")?; + let mut cmd = cargo_bin_cmd!("reaction"); cmd.args(["start", "--socket", "./s", "--config", "./config.jsonnet"]); cmd.current_dir(tmp_dir.path()); cmd.timeout(Duration::from_secs(5)); @@ -46,7 +46,7 @@ fn kill_stream_on_exit() -> Result<(), Box> { .child("config.jsonnet") .write_file(Path::new("tests/test-conf/test-shutdown.jsonnet"))?; - let cmd = Command::cargo_bin("reaction")?; + let cmd = cargo_bin_cmd!("reaction"); let mut cmd = std::process::Command::new(cmd.get_program()); cmd.args(["start", "--socket", "./s", "--config", "./config.jsonnet"]); cmd.current_dir(tmp_dir.path()); @@ -103,7 +103,7 @@ fn non_utf8_is_stripped() -> Result<(), Box> { .child("config.jsonnet") .write_file(Path::new("tests/test-conf/test-binary-input.jsonnet"))?; - let mut cmd = Command::cargo_bin("reaction")?; + let mut cmd = cargo_bin_cmd!("reaction"); cmd.args(["start", "--socket", "./s", "--config", "config.jsonnet"]); cmd.current_dir(tmp_dir.path()); cmd.timeout(std::time::Duration::from_secs(1)); @@ -124,7 +124,7 @@ fn capture_streams_stderr() -> Result<(), Box> { .child("config.jsonnet") .write_file(Path::new("tests/test-conf/test-stream-stderr.jsonnet"))?; - let mut cmd = Command::cargo_bin("reaction")?; + let mut cmd = cargo_bin_cmd!("reaction"); cmd.args(["start", "--socket", "./s", "--config", "config.jsonnet"]); cmd.current_dir(tmp_dir.path()); cmd.timeout(std::time::Duration::from_secs(1)); @@ -149,7 +149,7 @@ fn manualy_trigger_filter() -> Result<(), Box> { .write_file(Path::new("tests/test-conf/test-trigger.jsonnet"))?; // start daemon - let cmd = Command::cargo_bin("reaction")?; + let cmd = cargo_bin_cmd!("reaction"); let program = cmd.get_program(); let mut cmd = std::process::Command::new(program); cmd.args(["start", "--socket", "./s", "--config", "config.jsonnet"]); @@ -181,7 +181,7 @@ fn manualy_trigger_filter() -> Result<(), Box> { let socket_path = socket.path().to_str().unwrap(); // trigger event manually - let mut cmd_trigger = Command::cargo_bin("reaction")?; + let mut cmd_trigger = cargo_bin_cmd!("reaction"); cmd_trigger.current_dir(tmp_dir.path()); cmd_trigger.args(["trigger", "--socket", socket_path, "s1.f1", "num=95"]); cmd_trigger.timeout(Duration::from_secs(1)); @@ -221,7 +221,7 @@ fn filter_regex_match_eol() -> Result<(), Box> { .child("config.jsonnet") .write_file(Path::new("tests/test-conf/test-eol-match.jsonnet"))?; - let mut cmd = Command::cargo_bin("reaction")?; + let mut cmd = cargo_bin_cmd!("reaction"); cmd.args(["start", "--socket", "./s", "--config", "config.jsonnet"]); cmd.current_dir(tmp_dir.path()); cmd.timeout(std::time::Duration::from_secs(1)); diff --git a/tests/persistence.rs b/tests/persistence.rs index 3cbfd74..d68db33 100644 --- a/tests/persistence.rs +++ b/tests/persistence.rs @@ -1,6 +1,6 @@ use std::{error::Error, path::Path, time::Duration}; -use assert_cmd::Command; +use assert_cmd::cargo::cargo_bin_cmd; use assert_fs::prelude::*; use predicates::prelude::predicate; @@ -13,7 +13,7 @@ fn resume_action() -> Result<(), Box> { .write_file(Path::new("tests/test-conf/test-resume-action.jsonnet"))?; // first run - let mut cmd = Command::cargo_bin("reaction")?; + let mut cmd = cargo_bin_cmd!("reaction"); cmd.args(["start", "--socket", "./s", "--config", "./config.jsonnet"]); cmd.current_dir(tmp_dir.path()); cmd.timeout(Duration::from_secs(5)); @@ -25,7 +25,7 @@ fn resume_action() -> Result<(), Box> { tmp_dir.child("log").assert(&expected); // second run, expect to resume action - let mut cmd = Command::cargo_bin("reaction")?; + let mut cmd = cargo_bin_cmd!("reaction"); cmd.args(["start", "--socket", "./s", "--config", "./config.jsonnet"]); cmd.current_dir(tmp_dir.path()); cmd.timeout(Duration::from_secs(5)); diff --git a/tests/plugin_cluster.rs b/tests/plugin_cluster.rs index 3f43107..cf863fb 100644 --- a/tests/plugin_cluster.rs +++ b/tests/plugin_cluster.rs @@ -1,6 +1,6 @@ use std::{fs::read_to_string, path::Path, thread, time::Duration}; -use assert_cmd::Command; +use assert_cmd::{Command, cargo::cargo_bin_cmd}; use assert_fs::prelude::*; const SECRET_KEY_A: &str = "g7U1LPq2cgGSyk6CH_v1QpoXowSFKVQ8IcFljd_ZKGw="; @@ -100,8 +100,7 @@ fn launch_node(config: String, my_secret: &'static str, expected_output: Vec<&'s .write_file(Path::new("./target/debug/reaction-plugin-cluster")) .unwrap(); - let output = Command::cargo_bin("reaction") - .unwrap() + let output = cargo_bin_cmd!("reaction") .args([ "start", "--socket", diff --git a/tests/plugin_virtual.rs b/tests/plugin_virtual.rs index 19128d8..89f37da 100644 --- a/tests/plugin_virtual.rs +++ b/tests/plugin_virtual.rs @@ -1,6 +1,6 @@ use std::{path::Path, time::Duration}; -use assert_cmd::Command; +use assert_cmd::{Command, cargo::cargo_bin_cmd}; use assert_fs::prelude::*; use predicates::prelude::predicate; @@ -23,8 +23,7 @@ fn plugin_virtual() { .write_file(Path::new("./target/debug/reaction-plugin-virtual")) .unwrap(); - Command::cargo_bin("reaction") - .unwrap() + cargo_bin_cmd!("reaction") .args(["start", "--socket", "./s", "--config", "./config.jsonnet"]) .current_dir(tmp_dir.path()) .timeout(Duration::from_secs(5)) diff --git a/tests/start_stop.rs b/tests/start_stop.rs index c555e54..949b6b8 100644 --- a/tests/start_stop.rs +++ b/tests/start_stop.rs @@ -1,6 +1,6 @@ use std::{path::Path, time::Duration}; -use assert_cmd::Command; +use assert_cmd::cargo::cargo_bin_cmd; use assert_fs::{TempDir, prelude::*}; use predicates::prelude::predicate; @@ -80,8 +80,7 @@ fn run_reaction(tmp_dir: &TempDir) { .write_file(Path::new("tests/start_stop.jsonnet")) .unwrap(); - Command::cargo_bin("reaction") - .unwrap() + cargo_bin_cmd!("reaction") .args(["start", "--socket", "./s", "--config", "./config.jsonnet"]) .current_dir(tmp_dir.path()) .timeout(Duration::from_secs(5))