diff --git a/cargo-typify/tests/integration.rs b/cargo-typify/tests/integration.rs index 46028107..e3b65335 100644 --- a/cargo-typify/tests/integration.rs +++ b/cargo-typify/tests/integration.rs @@ -4,8 +4,6 @@ use tempdir::TempDir; #[test] fn test_simple() { - use assert_cmd::Command; - let input = concat!(env!("CARGO_MANIFEST_DIR"), "/../example.json"); let temp = TempDir::new("cargo-typify").unwrap(); @@ -14,8 +12,8 @@ fn test_simple() { let output_file = temp.path().join("simple.rs"); - let mut cmd = Command::cargo_bin("cargo-typify").unwrap(); - cmd.args(["typify", input_file.to_str().unwrap()]) + assert_cmd::cargo::cargo_bin_cmd!() + .args(["typify", input_file.to_str().unwrap()]) .assert() .success(); @@ -26,15 +24,13 @@ fn test_simple() { #[test] fn test_default_output() { - use assert_cmd::Command; - let input = concat!(env!("CARGO_MANIFEST_DIR"), "/../example.json"); let temp = TempDir::new("cargo-typify").unwrap(); let output_file = temp.path().join("output.rs"); - let mut cmd = Command::cargo_bin("cargo-typify").unwrap(); - cmd.args(["typify", input, "--output", output_file.to_str().unwrap()]) + assert_cmd::cargo::cargo_bin_cmd!() + .args(["typify", input, "--output", output_file.to_str().unwrap()]) .assert() .success(); @@ -45,13 +41,9 @@ fn test_default_output() { #[test] fn test_no_builder_stdout() { - use assert_cmd::Command; - let input = concat!(env!("CARGO_MANIFEST_DIR"), "/../example.json"); - let mut cmd = Command::cargo_bin("cargo-typify").unwrap(); - - let output = cmd + let output = assert_cmd::cargo::cargo_bin_cmd!() .args(["typify", input, "--no-builder", "--output", "-"]) .output() .unwrap(); @@ -65,23 +57,21 @@ fn test_no_builder_stdout() { #[test] fn test_builder() { - use assert_cmd::Command; - let input = concat!(env!("CARGO_MANIFEST_DIR"), "/../example.json"); let temp = TempDir::new("cargo-typify").unwrap(); let output_file = temp.path().join("output.rs"); - let mut cmd = Command::cargo_bin("cargo-typify").unwrap(); - cmd.args([ - "typify", - input, - "--builder", - "--output", - output_file.to_str().unwrap(), - ]) - .assert() - .success(); + assert_cmd::cargo::cargo_bin_cmd!() + .args([ + "typify", + input, + "--builder", + "--output", + output_file.to_str().unwrap(), + ]) + .assert() + .success(); let actual = std::fs::read_to_string(output_file).unwrap(); @@ -90,25 +80,23 @@ fn test_builder() { #[test] fn test_derive() { - use assert_cmd::Command; - let input = concat!(env!("CARGO_MANIFEST_DIR"), "/../example.json"); let temp = TempDir::new("cargo-typify").unwrap(); let output_file = temp.path().join("output.rs"); - let mut cmd = Command::cargo_bin("cargo-typify").unwrap(); - cmd.args([ - "typify", - input, - "--no-builder", - "--additional-derive", - "ExtraDerive", - "--output", - output_file.to_str().unwrap(), - ]) - .assert() - .success(); + assert_cmd::cargo::cargo_bin_cmd!() + .args([ + "typify", + input, + "--no-builder", + "--additional-derive", + "ExtraDerive", + "--output", + output_file.to_str().unwrap(), + ]) + .assert() + .success(); let actual = std::fs::read_to_string(output_file).unwrap(); @@ -117,27 +105,25 @@ fn test_derive() { #[test] fn test_multi_derive() { - use assert_cmd::Command; - let input = concat!(env!("CARGO_MANIFEST_DIR"), "/../example.json"); let temp = TempDir::new("cargo-typify").unwrap(); let output_file = temp.path().join("output.rs"); - let mut cmd = Command::cargo_bin("cargo-typify").unwrap(); - cmd.args([ - "typify", - input, - "--no-builder", - "--additional-derive", - "ExtraDerive", - "--additional-derive", - "AnotherDerive", - "--output", - output_file.to_str().unwrap(), - ]) - .assert() - .success(); + assert_cmd::cargo::cargo_bin_cmd!() + .args([ + "typify", + input, + "--no-builder", + "--additional-derive", + "ExtraDerive", + "--additional-derive", + "AnotherDerive", + "--output", + output_file.to_str().unwrap(), + ]) + .assert() + .success(); let actual = std::fs::read_to_string(output_file).unwrap(); @@ -146,11 +132,10 @@ fn test_multi_derive() { #[test] fn test_help() { - use assert_cmd::Command; - - let mut cmd = Command::cargo_bin("cargo-typify").unwrap(); - - let output = cmd.args(["typify", "--help"]).output().unwrap(); + let output = assert_cmd::cargo::cargo_bin_cmd!() + .args(["typify", "--help"]) + .output() + .unwrap(); let output_stdout = String::from_utf8(output.stdout).unwrap(); let actual = dos2unix(&output_stdout); @@ -161,24 +146,22 @@ fn test_help() { #[test] fn test_btree_map() { - use assert_cmd::Command; - let input = concat!(env!("CARGO_MANIFEST_DIR"), "/../example.json"); let temp = TempDir::new("cargo-typify").unwrap(); let output_file = temp.path().join("output.rs"); - let mut cmd = Command::cargo_bin("cargo-typify").unwrap(); - cmd.args([ - "typify", - input, - "--map-type", - "::std::collections::BTreeMap", - "--output", - output_file.to_str().unwrap(), - ]) - .assert() - .success(); + assert_cmd::cargo::cargo_bin_cmd!() + .args([ + "typify", + input, + "--map-type", + "::std::collections::BTreeMap", + "--output", + output_file.to_str().unwrap(), + ]) + .assert() + .success(); let actual = std::fs::read_to_string(output_file).unwrap();