From cbff2f1972d852070c87be55d0959afebdb10463 Mon Sep 17 00:00:00 2001 From: Daniel Eades Date: Sat, 27 Dec 2025 10:06:30 +0000 Subject: [PATCH 1/2] fix: remove usage of deprecated 'assert_cmd::Command' --- cargo-typify/tests/integration.rs | 32 ++++++++----------------------- 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/cargo-typify/tests/integration.rs b/cargo-typify/tests/integration.rs index 46028107..7b1c28c8 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,7 +12,7 @@ fn test_simple() { let output_file = temp.path().join("simple.rs"); - let mut cmd = Command::cargo_bin("cargo-typify").unwrap(); + let mut cmd = assert_cmd::cargo::cargo_bin_cmd!("cargo-typify"); cmd.args(["typify", input_file.to_str().unwrap()]) .assert() .success(); @@ -26,14 +24,12 @@ 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(); + let mut cmd = assert_cmd::cargo::cargo_bin_cmd!("cargo-typify"); cmd.args(["typify", input, "--output", output_file.to_str().unwrap()]) .assert() .success(); @@ -45,11 +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 mut cmd = assert_cmd::cargo::cargo_bin_cmd!("cargo-typify"); let output = cmd .args(["typify", input, "--no-builder", "--output", "-"]) @@ -65,14 +59,12 @@ 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(); + let mut cmd = assert_cmd::cargo::cargo_bin_cmd!("cargo-typify"); cmd.args([ "typify", input, @@ -90,14 +82,12 @@ 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(); + let mut cmd = assert_cmd::cargo::cargo_bin_cmd!("cargo-typify"); cmd.args([ "typify", input, @@ -117,14 +107,12 @@ 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(); + let mut cmd = assert_cmd::cargo::cargo_bin_cmd!("cargo-typify"); cmd.args([ "typify", input, @@ -146,9 +134,7 @@ fn test_multi_derive() { #[test] fn test_help() { - use assert_cmd::Command; - - let mut cmd = Command::cargo_bin("cargo-typify").unwrap(); + let mut cmd = assert_cmd::cargo::cargo_bin_cmd!("cargo-typify"); let output = cmd.args(["typify", "--help"]).output().unwrap(); @@ -161,14 +147,12 @@ 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(); + let mut cmd = assert_cmd::cargo::cargo_bin_cmd!("cargo-typify"); cmd.args([ "typify", input, From 8775673ee7844ccdc55cab1687553c8ab2d44139 Mon Sep 17 00:00:00 2001 From: Daniel Eades Date: Mon, 29 Dec 2025 20:26:29 +0000 Subject: [PATCH 2/2] fixup --- cargo-typify/tests/integration.rs | 113 +++++++++++++++--------------- 1 file changed, 56 insertions(+), 57 deletions(-) diff --git a/cargo-typify/tests/integration.rs b/cargo-typify/tests/integration.rs index 7b1c28c8..e3b65335 100644 --- a/cargo-typify/tests/integration.rs +++ b/cargo-typify/tests/integration.rs @@ -12,8 +12,8 @@ fn test_simple() { let output_file = temp.path().join("simple.rs"); - let mut cmd = assert_cmd::cargo::cargo_bin_cmd!("cargo-typify"); - cmd.args(["typify", input_file.to_str().unwrap()]) + assert_cmd::cargo::cargo_bin_cmd!() + .args(["typify", input_file.to_str().unwrap()]) .assert() .success(); @@ -29,8 +29,8 @@ fn test_default_output() { let temp = TempDir::new("cargo-typify").unwrap(); let output_file = temp.path().join("output.rs"); - let mut cmd = assert_cmd::cargo::cargo_bin_cmd!("cargo-typify"); - 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(); @@ -43,9 +43,7 @@ fn test_default_output() { fn test_no_builder_stdout() { let input = concat!(env!("CARGO_MANIFEST_DIR"), "/../example.json"); - let mut cmd = assert_cmd::cargo::cargo_bin_cmd!("cargo-typify"); - - let output = cmd + let output = assert_cmd::cargo::cargo_bin_cmd!() .args(["typify", input, "--no-builder", "--output", "-"]) .output() .unwrap(); @@ -64,16 +62,16 @@ fn test_builder() { let temp = TempDir::new("cargo-typify").unwrap(); let output_file = temp.path().join("output.rs"); - let mut cmd = assert_cmd::cargo::cargo_bin_cmd!("cargo-typify"); - 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(); @@ -87,18 +85,18 @@ fn test_derive() { let temp = TempDir::new("cargo-typify").unwrap(); let output_file = temp.path().join("output.rs"); - let mut cmd = assert_cmd::cargo::cargo_bin_cmd!("cargo-typify"); - 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(); @@ -112,20 +110,20 @@ fn test_multi_derive() { let temp = TempDir::new("cargo-typify").unwrap(); let output_file = temp.path().join("output.rs"); - let mut cmd = assert_cmd::cargo::cargo_bin_cmd!("cargo-typify"); - 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(); @@ -134,9 +132,10 @@ fn test_multi_derive() { #[test] fn test_help() { - let mut cmd = assert_cmd::cargo::cargo_bin_cmd!("cargo-typify"); - - 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); @@ -152,17 +151,17 @@ fn test_btree_map() { let temp = TempDir::new("cargo-typify").unwrap(); let output_file = temp.path().join("output.rs"); - let mut cmd = assert_cmd::cargo::cargo_bin_cmd!("cargo-typify"); - 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();