From ec39b1521b9c24e7404af8242812f92d58331949 Mon Sep 17 00:00:00 2001 From: Martin Emde Date: Tue, 16 Dec 2025 18:00:53 -0800 Subject: [PATCH 1/2] Update Rust toolchain to 1.92.0 Fix new clippy lints --- rust-toolchain.toml | 2 +- src/packs/checker.rs | 6 ++---- src/packs/configuration.rs | 2 +- src/packs/creator.rs | 6 ++++-- src/packs/file_utils.rs | 4 ++-- src/packs/parsing/ruby/parse_utils.rs | 4 +--- src/packs/parsing/ruby/rails_utils.rs | 2 +- 7 files changed, 12 insertions(+), 14 deletions(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 6b1db70..808dff7 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.83.0" +channel = "1.92.0" components = ["clippy", "rustfmt"] targets = ["x86_64-apple-darwin", "aarch64-apple-darwin", "x86_64-unknown-linux-gnu"] diff --git a/src/packs/checker.rs b/src/packs/checker.rs index 336f63b..cad1cb4 100644 --- a/src/packs/checker.rs +++ b/src/packs/checker.rs @@ -517,8 +517,7 @@ mod tests { #[test] fn test_write_violations() { let chec_result = CheckAllResult { - reportable_violations: vec![ - Violation { + reportable_violations: [Violation { message: "foo/bar/file1.rb:10:5\nPrivacy violation: `::Foo::PrivateClass` is private to `foo`, but referenced from `bar`".to_string(), identifier: ViolationIdentifier { violation_type: "Privacy".to_string(), @@ -539,8 +538,7 @@ mod tests { referencing_pack_name: "foo".to_string(), defining_pack_name: "bar".to_string(), } - } - ].iter().cloned().collect(), + }].iter().cloned().collect(), stale_violations: Vec::new(), strict_mode_violations: HashSet::new(), }; diff --git a/src/packs/configuration.rs b/src/packs/configuration.rs index c1f5e6f..273b9d3 100644 --- a/src/packs/configuration.rs +++ b/src/packs/configuration.rs @@ -86,7 +86,7 @@ impl Configuration { pub(crate) fn constant_resolver_configuration( &self, - ) -> ConstantResolverConfiguration { + ) -> ConstantResolverConfiguration<'_> { ConstantResolverConfiguration { absolute_root: &self.absolute_root, cache_directory: &self.cache_directory, diff --git a/src/packs/creator.rs b/src/packs/creator.rs index cd4e39c..7eefa8b 100644 --- a/src/packs/creator.rs +++ b/src/packs/creator.rs @@ -35,8 +35,10 @@ pub fn create( )?; write_pack_to_disk(&new_pack)?; - let pack_name = - &name.split('/').last().context("unable to find pack name")?; + let pack_name = &name + .split('/') + .next_back() + .context("unable to find pack name")?; std::fs::create_dir_all(new_pack_path.join("app/public/").join(pack_name)) .context(format!("failed to create app/public/{}", &name))?; std::fs::create_dir_all( diff --git a/src/packs/file_utils.rs b/src/packs/file_utils.rs index ae4d88d..8b1a500 100644 --- a/src/packs/file_utils.rs +++ b/src/packs/file_utils.rs @@ -27,10 +27,10 @@ pub fn get_file_type(path: &Path) -> Option { let is_ruby_file = ruby_extensions .into_iter() - .any(|ext| extension.map_or(false, |e| e == ext)) + .any(|ext| extension.is_some_and(|e| e == ext)) || ruby_special_files.iter().any(|file| path.ends_with(file)); - let is_erb_file = path.extension().map_or(false, |ext| ext == "erb"); + let is_erb_file = path.extension().is_some_and(|ext| ext == "erb"); if is_ruby_file { Some(SupportedFileType::Ruby) diff --git a/src/packs/parsing/ruby/parse_utils.rs b/src/packs/parsing/ruby/parse_utils.rs index 7f35b61..e589ed2 100644 --- a/src/packs/parsing/ruby/parse_utils.rs +++ b/src/packs/parsing/ruby/parse_utils.rs @@ -116,9 +116,7 @@ pub fn get_reference_from_active_record_association( .chain(ASSOCIATION_METHOD_NAMES.iter().copied().map(String::from)) .collect(); - let is_association = combined_associations - .iter() - .any(|association_method| node.method_name == *association_method); + let is_association = combined_associations.contains(&node.method_name); if is_association { let first_arg: Option<&Node> = node.args.first(); diff --git a/src/packs/parsing/ruby/rails_utils.rs b/src/packs/parsing/ruby/rails_utils.rs index e9b85fe..bf924ba 100644 --- a/src/packs/parsing/ruby/rails_utils.rs +++ b/src/packs/parsing/ruby/rails_utils.rs @@ -16,9 +16,9 @@ pub(crate) fn get_acronyms_from_disk( let inflections_file = std::fs::read_to_string(inflections_path).unwrap(); let inflections_lines = inflections_file.lines(); + let re = Regex::new(r#"['\\"]"#).unwrap(); for line in inflections_lines { if line.contains(".acronym") { - let re = Regex::new(r#"['\\"]"#).unwrap(); let acronym = re.split(line).nth(1).unwrap(); acronyms.insert(acronym.to_string()); } From 165a8dac2d35a23165fa394504de9b3041049b52 Mon Sep 17 00:00:00 2001 From: Martin Emde Date: Tue, 16 Dec 2025 19:35:21 -0800 Subject: [PATCH 2/2] Update assert_cmd and fix deprecation warnings --- Cargo.toml | 2 +- tests/add_constant_dependencies.rs | 6 ++-- tests/add_dependency_test.rs | 8 ++--- tests/check_test.rs | 45 ++++++++++++----------------- tests/check_unused_dependencies.rs | 10 +++---- tests/corrupt_todo_test.rs | 4 +-- tests/create_test.rs | 10 +++---- tests/delete_cache_test.rs | 6 ++-- tests/dependencies_test.rs | 8 ++--- tests/enforcement_globs.rs | 5 ++-- tests/expose_monkey_patches_test.rs | 6 ++-- tests/folder_privacy_test.rs | 12 ++++---- tests/layer_violations_test.rs | 10 +++---- tests/list_definitions_test.rs | 8 ++--- tests/list_packs_test.rs | 6 ++-- tests/update_test.rs | 16 +++++----- tests/validate_test.rs | 12 ++++---- tests/visibility_test.rs | 10 +++---- 18 files changed, 86 insertions(+), 98 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c2e8a29..009362c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,7 +50,7 @@ fnmatch-regex2 = "0.3.0" strip-ansi-escapes = "0.2.0" [dev-dependencies] -assert_cmd = "2.0.10" # testing CLI +assert_cmd = "2.1.1" # testing CLI rusty-hook = "^0.11.2" # git hooks predicates = "3.0.2" # kind of like rspec assertions pretty_assertions = "1.3.0" # Shows a more readable diff when comparing objects diff --git a/tests/add_constant_dependencies.rs b/tests/add_constant_dependencies.rs index cb718fb..93075a3 100644 --- a/tests/add_constant_dependencies.rs +++ b/tests/add_constant_dependencies.rs @@ -1,4 +1,4 @@ -use assert_cmd::Command; +use assert_cmd::cargo::cargo_bin_cmd; use predicates::prelude::*; use pretty_assertions::assert_eq; use serial_test::serial; @@ -9,7 +9,7 @@ mod common; #[test] #[serial] fn test_add_constant_dependencies() -> anyhow::Result<()> { - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/app_with_missing_dependencies") .arg("update-dependencies-for-constant") @@ -43,7 +43,7 @@ fn test_add_constant_dependencies() -> anyhow::Result<()> { #[test] #[serial] fn test_add_constant_dependencies_no_dependencies() -> anyhow::Result<()> { - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/app_with_missing_dependencies") .arg("update-dependencies-for-constant") diff --git a/tests/add_dependency_test.rs b/tests/add_dependency_test.rs index cd37824..89cbd12 100644 --- a/tests/add_dependency_test.rs +++ b/tests/add_dependency_test.rs @@ -1,4 +1,4 @@ -use assert_cmd::Command; +use assert_cmd::cargo::cargo_bin_cmd; use predicates::prelude::*; use pretty_assertions::assert_eq; use serial_test::serial; @@ -9,7 +9,7 @@ mod common; #[test] #[serial] fn test_add_dependency() -> Result<(), Box> { - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/app_with_missing_dependency") .arg("add-dependency") @@ -41,7 +41,7 @@ fn test_add_dependency() -> Result<(), Box> { #[test] #[serial] fn test_add_dependency_creating_cycle() -> Result<(), Box> { - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/app_with_missing_dependency") .arg("add-dependency") @@ -80,7 +80,7 @@ fn test_add_dependency_creating_cycle() -> Result<(), Box> { #[test] fn test_add_dependency_unnecessarily() -> Result<(), Box> { - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/app_with_missing_dependency") .arg("add-dependency") diff --git a/tests/check_test.rs b/tests/check_test.rs index ae6b135..f3d8448 100644 --- a/tests/check_test.rs +++ b/tests/check_test.rs @@ -1,4 +1,4 @@ -use assert_cmd::Command; +use assert_cmd::cargo::cargo_bin_cmd; use predicates::prelude::*; use std::{error::Error, fs}; @@ -11,7 +11,7 @@ pub fn stripped_output(output: Vec) -> String { #[test] fn test_check_with_privacy_dependency_error_template_overrides( ) -> Result<(), Box> { - let output = Command::cargo_bin("pks")? + let output = cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/privacy_violation_overrides") .arg("--debug") @@ -33,7 +33,7 @@ fn test_check_with_privacy_dependency_error_template_overrides( } #[test] fn test_check() -> Result<(), Box> { - let output = Command::cargo_bin("pks")? + let output = cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/simple_app") .arg("--debug") @@ -56,7 +56,7 @@ fn test_check() -> Result<(), Box> { #[test] fn test_check_enforce_privacy_disabled() -> Result<(), Box> { - let output = Command::cargo_bin("pks")? + let output = cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/simple_app") .arg("--debug") @@ -79,7 +79,7 @@ fn test_check_enforce_privacy_disabled() -> Result<(), Box> { #[test] fn test_check_enforce_dependency_disabled() -> Result<(), Box> { - let output = Command::cargo_bin("pks")? + let output = cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/simple_app") .arg("--debug") @@ -102,7 +102,7 @@ fn test_check_enforce_dependency_disabled() -> Result<(), Box> { #[test] fn test_check_with_single_file() -> Result<(), Box> { - let output = Command::cargo_bin("pks")? + let output = cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/simple_app") .arg("--debug") @@ -127,7 +127,7 @@ fn test_check_with_single_file() -> Result<(), Box> { #[test] fn test_check_with_single_file_experimental_parser( ) -> Result<(), Box> { - let output = Command::cargo_bin("pks")? + let output = cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/simple_app") .arg("--debug") @@ -152,7 +152,7 @@ fn test_check_with_single_file_experimental_parser( #[test] fn test_check_with_package_todo_file() -> Result<(), Box> { - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/contains_package_todo") .arg("--debug") @@ -168,7 +168,7 @@ fn test_check_with_package_todo_file() -> Result<(), Box> { #[test] fn test_check_with_package_todo_file_csv() -> Result<(), Box> { - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/contains_package_todo") .arg("--debug") @@ -188,7 +188,7 @@ fn test_check_with_package_todo_file_csv() -> Result<(), Box> { #[test] fn test_check_with_package_todo_file_ignoring_recorded_violations( ) -> Result<(), Box> { - let output = Command::cargo_bin("pks")? + let output = cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/contains_package_todo") .arg("--debug") @@ -212,8 +212,7 @@ fn test_check_with_package_todo_file_ignoring_recorded_violations( #[test] fn test_check_with_experimental_parser() -> Result<(), Box> { - let output = Command::cargo_bin("pks") - .unwrap() + let output = cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/simple_app") .arg("--experimental-parser") @@ -237,8 +236,7 @@ fn test_check_with_experimental_parser() -> Result<(), Box> { #[test] fn test_check_with_stale_violations() -> Result<(), Box> { - Command::cargo_bin("pks") - .unwrap() + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/contains_stale_violations") .arg("check") @@ -255,8 +253,7 @@ fn test_check_with_stale_violations() -> Result<(), Box> { #[test] fn test_check_with_stale_violations_when_file_no_longer_exists( ) -> Result<(), Box> { - Command::cargo_bin("pks") - .unwrap() + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/contains_stale_violations_no_file") .arg("check") @@ -272,8 +269,7 @@ fn test_check_with_stale_violations_when_file_no_longer_exists( #[test] fn test_check_with_relationship_violations() -> Result<(), Box> { - Command::cargo_bin("pks") - .unwrap() + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/app_with_rails_relationships") .arg("check") @@ -289,8 +285,7 @@ fn test_check_with_relationship_violations() -> Result<(), Box> { #[test] fn test_check_without_stale_violations() -> Result<(), Box> { - Command::cargo_bin("pks") - .unwrap() + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/contains_package_todo") .arg("check") @@ -309,8 +304,7 @@ fn test_check_without_stale_violations() -> Result<(), Box> { #[test] fn test_check_with_strict_mode() -> Result<(), Box> { - Command::cargo_bin("pks") - .unwrap() + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/uses_strict_mode") .arg("check") @@ -329,8 +323,7 @@ fn test_check_with_strict_mode() -> Result<(), Box> { #[test] fn test_check_with_strict_mode_output_csv() -> Result<(), Box> { - Command::cargo_bin("pks") - .unwrap() + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/uses_strict_mode") .arg("check") @@ -354,7 +347,7 @@ fn test_check_contents() -> Result<(), Box> { let foo_rb_contents = fs::read_to_string(format!("{}/{}", project_root, relative_path))?; - let output = Command::cargo_bin("pks")? + let output = cargo_bin_cmd!("pks") .arg("--project-root") .arg(project_root) .arg("--debug") @@ -385,7 +378,7 @@ fn test_check_contents_ignoring_recorded_violations( let foo_rb_contents = fs::read_to_string(format!("{}/{}", project_root, relative_path))?; - let output = Command::cargo_bin("pks")? + let output = cargo_bin_cmd!("pks") .arg("--project-root") .arg(project_root) .arg("--debug") diff --git a/tests/check_unused_dependencies.rs b/tests/check_unused_dependencies.rs index 640259e..77be8bf 100644 --- a/tests/check_unused_dependencies.rs +++ b/tests/check_unused_dependencies.rs @@ -1,10 +1,10 @@ -use assert_cmd::prelude::*; +use assert_cmd::cargo::cargo_bin_cmd; use predicates::prelude::*; -use std::{error::Error, fs, process::Command}; +use std::{error::Error, fs}; mod common; fn assert_check_unused_dependencies(cmd: &str) -> Result<(), Box> { - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/app_with_dependency_cycles") .arg("--debug") @@ -51,7 +51,7 @@ fn assert_auto_correct_unused_dependencies( let foo_package_yml = fs::read_to_string("tests/fixtures/app_with_unnecessary_dependencies/packs/foo/package.yml").unwrap(); assert_eq!(foo_package_yml, expected_before_autocorrect); - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/app_with_unnecessary_dependencies") .arg("--debug") @@ -94,7 +94,7 @@ fn test_auto_correct_unnecessary_dependencies() -> Result<(), Box> { #[test] fn test_check_unnecessary_dependencies_no_issue() -> Result<(), Box> { - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/simple_app") .arg("--debug") diff --git a/tests/corrupt_todo_test.rs b/tests/corrupt_todo_test.rs index ec94340..9ee4889 100644 --- a/tests/corrupt_todo_test.rs +++ b/tests/corrupt_todo_test.rs @@ -1,10 +1,10 @@ -use assert_cmd::Command; +use assert_cmd::cargo::cargo_bin_cmd; use predicates::prelude::*; mod common; #[test] fn test_check_with_corrupt_todo() -> anyhow::Result<()> { - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/contains_corrupt_todo") .arg("--debug") diff --git a/tests/create_test.rs b/tests/create_test.rs index 42c2d94..19b4fe6 100644 --- a/tests/create_test.rs +++ b/tests/create_test.rs @@ -1,4 +1,4 @@ -use assert_cmd::Command; +use assert_cmd::cargo::cargo_bin_cmd; use predicates::prelude::*; use pretty_assertions::assert_eq; use std::{error::Error, fs, path::Path}; @@ -9,7 +9,7 @@ mod common; fn test_create() -> Result<(), Box> { common::delete_foobar(); - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/simple_app") .arg("create") @@ -76,7 +76,7 @@ fn test_create_with_readme_template_default_path() -> Result<(), Box> "This is a test custom README template", )?; - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/simple_packs_first_app") .arg("create") @@ -106,7 +106,7 @@ fn test_create_with_readme_template_custom_path() -> Result<(), Box> { common::delete_foobar_app_with_custom_readme(); - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/app_with_custom_readme") .arg("create") @@ -131,7 +131,7 @@ fn test_create_with_readme_template_custom_path() -> Result<(), Box> #[test] fn test_create_already_exists() -> Result<(), Box> { - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/simple_packs_first_app") .arg("create") diff --git a/tests/delete_cache_test.rs b/tests/delete_cache_test.rs index ec5d658..9b95a24 100644 --- a/tests/delete_cache_test.rs +++ b/tests/delete_cache_test.rs @@ -1,5 +1,5 @@ -use assert_cmd::prelude::*; -use std::{error::Error, fs, path::PathBuf, process::Command}; +use assert_cmd::cargo::cargo_bin_cmd; +use std::{error::Error, fs, path::PathBuf}; mod common; fn is_tmp_cache_packwerk_empty() -> Result { @@ -34,7 +34,7 @@ fn test_delete_cache() -> Result<(), Box> { assert!(!is_tmp_cache_packwerk_empty().unwrap()); - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--debug") .arg("--project-root") .arg("tests/fixtures/simple_app") diff --git a/tests/dependencies_test.rs b/tests/dependencies_test.rs index 648465f..023d76e 100644 --- a/tests/dependencies_test.rs +++ b/tests/dependencies_test.rs @@ -1,13 +1,13 @@ -use assert_cmd::prelude::*; +use assert_cmd::cargo::cargo_bin_cmd; use predicates::prelude::*; -use std::{error::Error, process::Command}; +use std::error::Error; mod common; #[test] fn test_list_pack_dependencies_with_explicit_dependencies( ) -> Result<(), Box> { - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/simple_app") .arg("--debug") @@ -25,7 +25,7 @@ fn test_list_pack_dependencies_with_explicit_dependencies( #[test] fn list_pack_dependencies_with_implicit_dependencies( ) -> Result<(), Box> { - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/contains_package_todo") .arg("--debug") diff --git a/tests/enforcement_globs.rs b/tests/enforcement_globs.rs index b1b3706..15debac 100644 --- a/tests/enforcement_globs.rs +++ b/tests/enforcement_globs.rs @@ -1,12 +1,11 @@ +use assert_cmd::cargo::cargo_bin_cmd; use std::error::Error; -use assert_cmd::Command; - mod common; #[test] fn test_check() -> Result<(), Box> { - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/simple_app_with_enforcement_globs") .arg("--debug") diff --git a/tests/expose_monkey_patches_test.rs b/tests/expose_monkey_patches_test.rs index f01545d..758b738 100644 --- a/tests/expose_monkey_patches_test.rs +++ b/tests/expose_monkey_patches_test.rs @@ -1,6 +1,6 @@ -use assert_cmd::prelude::*; +use assert_cmd::cargo::cargo_bin_cmd; use predicates::prelude::*; -use std::{error::Error, process::Command}; +use std::error::Error; mod common; #[test] @@ -10,7 +10,7 @@ fn test_expose_monkey_patches() -> Result<(), Box> { let expected_message_portion = String::from( "The following is a list of constants that are redefined by your app.", ); - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/app_with_monkey_patches") .arg("--experimental-parser") diff --git a/tests/folder_privacy_test.rs b/tests/folder_privacy_test.rs index 3f72f32..0639296 100644 --- a/tests/folder_privacy_test.rs +++ b/tests/folder_privacy_test.rs @@ -1,11 +1,11 @@ -use assert_cmd::prelude::*; +use assert_cmd::cargo::cargo_bin_cmd; use predicates::prelude::*; -use std::{error::Error, process::Command}; +use std::error::Error; mod common; #[test] fn test_check() -> Result<(), Box> { - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/folder_privacy_violations") .arg("--debug") @@ -20,7 +20,7 @@ fn test_check() -> Result<(), Box> { #[test] fn test_check_with_error_template_overrides() -> Result<(), Box> { - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/folder_privacy_violations_with_overrides") .arg("--debug") @@ -35,7 +35,7 @@ fn test_check_with_error_template_overrides() -> Result<(), Box> { #[test] fn test_check_enforce_folder_privacy_disabled() -> Result<(), Box> { - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/folder_privacy_violations") .arg("--debug") @@ -51,7 +51,7 @@ fn test_check_enforce_folder_privacy_disabled() -> Result<(), Box> { #[test] fn test_invisible_pack_violation_with_deprecated_enforce_folder_visibility( ) -> Result<(), Box> { - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/folder_visibility_violations") .arg("--debug") diff --git a/tests/layer_violations_test.rs b/tests/layer_violations_test.rs index 8795dec..21cdf60 100644 --- a/tests/layer_violations_test.rs +++ b/tests/layer_violations_test.rs @@ -1,11 +1,11 @@ -use assert_cmd::prelude::*; -use std::{error::Error, process::Command}; +use assert_cmd::cargo::cargo_bin_cmd; +use std::error::Error; mod common; #[test] fn test_check_with_error_template_overrides() -> Result<(), Box> { - let output = Command::cargo_bin("pks")? + let output = cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/layer_violations_with_overrides") .arg("--debug") @@ -27,7 +27,7 @@ fn test_check_with_error_template_overrides() -> Result<(), Box> { } #[test] fn test_check() -> Result<(), Box> { - let output = Command::cargo_bin("pks")? + let output = cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/layer_violations") .arg("--debug") @@ -50,7 +50,7 @@ fn test_check() -> Result<(), Box> { #[test] fn test_check_enforce_layers_disabled() -> Result<(), Box> { - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/layer_violations") .arg("--debug") diff --git a/tests/list_definitions_test.rs b/tests/list_definitions_test.rs index 8b8dc3c..6848630 100644 --- a/tests/list_definitions_test.rs +++ b/tests/list_definitions_test.rs @@ -1,11 +1,11 @@ -use assert_cmd::prelude::*; +use assert_cmd::cargo::cargo_bin_cmd; use predicates::prelude::*; -use std::{error::Error, process::Command}; +use std::error::Error; mod common; #[test] fn test_list_definitions_experimental() -> Result<(), Box> { - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/app_with_monkey_patches") .arg("--debug") @@ -38,7 +38,7 @@ fn test_list_definitions_experimental() -> Result<(), Box> { #[test] fn test_list_definitions_with_ambiguous_experimental( ) -> Result<(), Box> { - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/app_with_monkey_patches") .arg("--debug") diff --git a/tests/list_packs_test.rs b/tests/list_packs_test.rs index 2c50b43..6c4a91d 100644 --- a/tests/list_packs_test.rs +++ b/tests/list_packs_test.rs @@ -1,10 +1,10 @@ -use assert_cmd::prelude::*; +use assert_cmd::cargo::cargo_bin_cmd; use predicates::prelude::*; -use std::{error::Error, process::Command}; +use std::error::Error; #[test] fn lint_packs() -> Result<(), Box> { - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/simple_app") .arg("--debug") diff --git a/tests/update_test.rs b/tests/update_test.rs index 8b3595b..e8d76ff 100644 --- a/tests/update_test.rs +++ b/tests/update_test.rs @@ -1,7 +1,7 @@ -use assert_cmd::prelude::*; +use assert_cmd::cargo::cargo_bin_cmd; use predicates::prelude::*; use serial_test::serial; -use std::{error::Error, path::Path, process::Command}; +use std::{error::Error, path::Path}; mod common; use pretty_assertions::assert_eq; @@ -19,7 +19,7 @@ fn update_todo() -> Result<(), Box> { } fn test_update(command: &str) -> Result<(), Box> { - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/simple_app") .arg("--debug") @@ -63,8 +63,7 @@ packs/bar: #[test] #[serial] fn test_update_with_experimental_parser() -> Result<(), Box> { - Command::cargo_bin("pks") - .unwrap() + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/simple_app") .arg("--debug") @@ -110,8 +109,7 @@ packs/bar: fn test_update_with_stale_violations() -> Result<(), Box> { common::set_up_fixtures(); - Command::cargo_bin("pks") - .unwrap() + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/contains_stale_violations") .arg("update") @@ -157,7 +155,7 @@ packs/bar: #[test] fn test_update_with_packs_first_app() -> Result<(), Box> { - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/simple_packs_first_app") .arg("update") @@ -205,7 +203,7 @@ fn test_update_with_strict_violations() -> anyhow::Result<()> { ); let _ignore = std::fs::remove_file(path); - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/contains_strict_violations") .arg("update") diff --git a/tests/validate_test.rs b/tests/validate_test.rs index 0820eb5..fe190f2 100644 --- a/tests/validate_test.rs +++ b/tests/validate_test.rs @@ -1,6 +1,6 @@ -use assert_cmd::prelude::*; +use assert_cmd::cargo::cargo_bin_cmd; use predicates::prelude::*; -use std::{error::Error, process::Command}; +use std::error::Error; mod common; @@ -14,8 +14,7 @@ The following groups of packages form a cycle: packs/foo, packs/bar", ); - Command::cargo_bin("pks") - .unwrap() + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/app_with_dependency_cycles") .arg("--debug") @@ -41,8 +40,7 @@ fn test_validate_layer() -> Result<(), Box> { "Invalid \'layer\' option in \'packs/foo/package.yml\'. `layer` must be one of the layers defined in `packwerk.yml`" ); - Command::cargo_bin("pks") - .unwrap() + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/app_with_layer_violations_in_yml") .arg("validate") @@ -58,7 +56,7 @@ fn test_validate_layer() -> Result<(), Box> { #[test] fn test_validate_with_referencing_unknown_pack() -> Result<(), Box> { - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/references_unknown_pack") .arg("--debug") diff --git a/tests/visibility_test.rs b/tests/visibility_test.rs index df43e8a..a8526b6 100644 --- a/tests/visibility_test.rs +++ b/tests/visibility_test.rs @@ -1,12 +1,12 @@ -use assert_cmd::prelude::*; -use std::{error::Error, process::Command}; +use assert_cmd::cargo::cargo_bin_cmd; +use std::error::Error; mod common; #[test] fn test_check_with_visibility_violation_template_overrides( ) -> Result<(), Box> { - let output = Command::cargo_bin("pks")? + let output = cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/visibility_violations_with_overrides") .arg("--debug") @@ -30,7 +30,7 @@ fn test_check_with_visibility_violation_template_overrides( #[test] fn test_check() -> Result<(), Box> { - let output = Command::cargo_bin("pks")? + let output = cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/visibility_violations") .arg("--debug") @@ -54,7 +54,7 @@ fn test_check() -> Result<(), Box> { #[test] fn test_check_disabled_enforce_visibility() -> Result<(), Box> { - Command::cargo_bin("pks")? + cargo_bin_cmd!("pks") .arg("--project-root") .arg("tests/fixtures/visibility_violations") .arg("--debug")