diff options
Diffstat (limited to 'crates/shirabe/tests')
| -rw-r--r-- | crates/shirabe/tests/all_functional_test.rs | 12 | ||||
| -rw-r--r-- | crates/shirabe/tests/command/base_dependency_command_test.rs | 10 | ||||
| -rw-r--r-- | crates/shirabe/tests/command/install_command_test.rs | 4 | ||||
| -rw-r--r-- | crates/shirabe/tests/command/remove_command_test.rs | 18 | ||||
| -rw-r--r-- | crates/shirabe/tests/command/require_command_test.rs | 12 | ||||
| -rw-r--r-- | crates/shirabe/tests/command/show_command_test.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/tests/command/update_command_test.rs | 4 | ||||
| -rw-r--r-- | crates/shirabe/tests/installer_test.rs | 19 | ||||
| -rw-r--r-- | crates/shirabe/tests/json/json_file_test.rs | 4 | ||||
| -rw-r--r-- | crates/shirabe/tests/util/bitbucket_test.rs | 2 |
10 files changed, 56 insertions, 31 deletions
diff --git a/crates/shirabe/tests/all_functional_test.rs b/crates/shirabe/tests/all_functional_test.rs index 9879bca4..9f750717 100644 --- a/crates/shirabe/tests/all_functional_test.rs +++ b/crates/shirabe/tests/all_functional_test.rs @@ -125,6 +125,15 @@ fn clean_output(output: &str) -> String { String::from_utf8_lossy(&processed).into_owned() } +/// The fixtures come from Composer's tree and name the `composer` binary in the hints they expect +/// on stdout; Shirabe prints its own name there. +fn rename_binary_in_expected_output(expected: &str) -> String { + regex::Regex::new(r"\bcomposer (?P<cmd>config|fund|suggest|update)\b") + .unwrap() + .replace_all(expected, "shirabe $cmd") + .into_owned() +} + /// ref: the inline `--EXPECT--` matcher in AllFunctionalTest::testIntegration. Literal byte /// comparison, except `%regex%` spans in `expected` are matched as `{regex}` against the remaining /// output and consume whatever they match. @@ -216,9 +225,10 @@ fn run_integration(test_filename: &str) { let raw_output = String::from_utf8_lossy(&proc.stdout).into_owned(); if let Some(expected) = test_data.get("EXPECT") { + let expected = rename_binary_in_expected_output(expected); let output = clean_output(&raw_output); let output = output.trim(); - expect_matches(expected, output); + expect_matches(&expected, output); } if let Some(expect_regex) = test_data.get("EXPECT-REGEX") { assert!(preg_match(expect_regex, &clean_output(&raw_output)).is_some()); diff --git a/crates/shirabe/tests/command/base_dependency_command_test.rs b/crates/shirabe/tests/command/base_dependency_command_test.rs index 41aeec56..da9a51e7 100644 --- a/crates/shirabe/tests/command/base_dependency_command_test.rs +++ b/crates/shirabe/tests/command/base_dependency_command_test.rs @@ -240,7 +240,7 @@ fn test_exception_when_package_was_not_found_in_project() { #[test] #[serial] fn test_warning_when_dependencies_are_not_installed() { - let expected_warning_message = "<warning>No dependencies installed. Try running composer install or update, or use --locked.</warning>"; + let expected_warning_message = "<warning>No dependencies installed. Try running shirabe install or update, or use --locked.</warning>"; // caseProvider let cases: Vec<(&str, Vec<(&str, InputValue)>)> = vec![ @@ -469,7 +469,7 @@ fn test_why_not_command_outputs() { "3.*", "Package \"vendor1/package1\" could not be found with constraint \"3.*\", results below will most likely be incomplete.\n\ __root__ - requires vendor1/package1 (1.*)\n\ - Not finding what you were looking for? Try calling `composer require \"vendor1/package1:3.*\" --dry-run` to get another view on the problem.", + Not finding what you were looking for? Try calling `shirabe require \"vendor1/package1:3.*\" --dry-run` to get another view on the problem.", 1, ), ( @@ -477,20 +477,20 @@ fn test_why_not_command_outputs() { "^1.4", "Package \"vendor1/package1\" could not be found with constraint \"^1.4\", results below will most likely be incomplete.\n\ There is no installed package depending on \"vendor1/package1\" in versions not matching ^1.4\n\ - Not finding what you were looking for? Try calling `composer require \"vendor1/package1:^1.4\" --dry-run` to get another view on the problem.", + Not finding what you were looking for? Try calling `shirabe require \"vendor1/package1:^1.4\" --dry-run` to get another view on the problem.", 0, ), ( "vendor1/package1", "^1.3", - "Package \"vendor1/package1\" 1.3.0 is already installed! To find out why, run `composer why vendor1/package1`", + "Package \"vendor1/package1\" 1.3.0 is already installed! To find out why, run `shirabe why vendor1/package1`", 0, ), ( "vendor2/package3", "1.5.0", "vendor2/package2 1.0.0 requires vendor2/package3 (1.4.*)\n\ - Not finding what you were looking for? Try calling `composer update \"vendor2/package3:1.5.0\" --dry-run` to get another view on the problem.", + Not finding what you were looking for? Try calling `shirabe update \"vendor2/package3:1.5.0\" --dry-run` to get another view on the problem.", 1, ), ( diff --git a/crates/shirabe/tests/command/install_command_test.rs b/crates/shirabe/tests/command/install_command_test.rs index 11afd464..abf489ab 100644 --- a/crates/shirabe/tests/command/install_command_test.rs +++ b/crates/shirabe/tests/command/install_command_test.rs @@ -50,13 +50,13 @@ Generating autoload files"#, "packages", InputValue::Array(vec!["vendor/package".to_string()]), )], - r#"Invalid argument vendor/package. Use "composer require vendor/package" instead to add packages to your composer.json."#, + r#"Invalid argument vendor/package. Use "shirabe require vendor/package" instead to add packages to your composer.json."#, ), ( "it writes an error when no-install flag is passed", serde_json::json!({ "repositories": [] }), vec![("--no-install", InputValue::from(true))], - r#"Invalid option "--no-install". Use "composer update --no-install" instead if you are trying to update the composer.lock file."#, + r#"Invalid option "--no-install". Use "shirabe update --no-install" instead if you are trying to update the composer.lock file."#, ), ] } diff --git a/crates/shirabe/tests/command/remove_command_test.rs b/crates/shirabe/tests/command/remove_command_test.rs index 377d78c0..a36043e0 100644 --- a/crates/shirabe/tests/command/remove_command_test.rs +++ b/crates/shirabe/tests/command/remove_command_test.rs @@ -306,7 +306,7 @@ fn test_remove_unused_package() { assert!( app_tester .get_display() - .contains("Running composer update not/req"), + .contains("Running shirabe update not/req"), "got: {}", app_tester.get_display() ); @@ -373,7 +373,7 @@ fn test_remove_package_by_name() { display ); assert!( - trimmed.contains("Running composer update root/req"), + trimmed.contains("Running shirabe update root/req"), "got: {}", display ); @@ -455,7 +455,7 @@ fn test_remove_package_by_name_with_dry_run() { display ); assert!( - trimmed.contains("Running composer update root/req"), + trimmed.contains("Running shirabe update root/req"), "got: {}", display ); @@ -649,7 +649,7 @@ fn test_remove_packages_by_vendor() { display ); assert!( - display.contains("Running composer update root/*"), + display.contains("Running shirabe update root/*"), "got: {}", display ); @@ -723,7 +723,7 @@ fn test_remove_packages_by_vendor_with_dry_run() { assert_eq!(SUCCESS, app_tester.get_status_code()); assert_eq!( "./composer.json has been updated -Running composer update root/* +Running shirabe update root/* Loading composer repositories with package information Updating dependencies Lock file operations: 0 installs, 0 updates, 2 removals @@ -843,7 +843,7 @@ fn test_package_still_present_error_when_no_install_flag_used() { assert!(display.contains("Writing lock file"), "got: {}", display); assert!( display.contains( - "Removal failed, root/req is still present, it may be required by another package. See `composer why root/req`" + "Removal failed, root/req is still present, it may be required by another package. See `shirabe why root/req`" ), "got: {}", display @@ -956,16 +956,16 @@ fn test_update_inherited_dependencies_flag_is_passed_to_post_remove_installer() // 'update with all dependencies' run_update_inherited_dependencies_flag_case( "--update-with-all-dependencies", - "Running composer update root/req --with-all-dependencies", + "Running shirabe update root/req --with-all-dependencies", ); // 'with all dependencies' run_update_inherited_dependencies_flag_case( "--with-all-dependencies", - "Running composer update root/req --with-all-dependencies", + "Running shirabe update root/req --with-all-dependencies", ); // 'no update with dependencies' run_update_inherited_dependencies_flag_case( "--no-update-with-dependencies", - "Running composer update root/req --with-dependencies", + "Running shirabe update root/req --with-dependencies", ); } diff --git a/crates/shirabe/tests/command/require_command_test.rs b/crates/shirabe/tests/command/require_command_test.rs index a4f3bb9c..897d8d2f 100644 --- a/crates/shirabe/tests/command/require_command_test.rs +++ b/crates/shirabe/tests/command/require_command_test.rs @@ -99,7 +99,7 @@ fn test_require_warns_if_resolved_to_feature_branch() { assert_eq!( "./composer.json has been updated -Running composer update required/pkg +Running shirabe update required/pkg Loading composer repositories with package information Updating dependencies Lock file operations: 2 installs, 0 updates, 0 removals @@ -138,7 +138,7 @@ fn provide_require() -> Vec<( vec![("packages", InputValue::Array(vec!["required/pkg".to_string()]))], "<warning>Cannot use required/pkg's latest version 1.2.0 as it requires ext-foobar ^1 which is missing from your platform. ./composer.json has been updated -Running composer update required/pkg +Running shirabe update required/pkg Loading composer repositories with package information Updating dependencies Lock file operations: 1 install, 0 updates, 0 removals @@ -165,7 +165,7 @@ Using version ^1.0 for required/pkg", "<warning>Cannot use required/pkg's latest version 1.2.0 as it requires ext-foobar ^1 which is missing from your platform. <warning>Cannot use required/pkg 1.1.0 as it requires ext-foobar ^1 which is missing from your platform. ./composer.json has been updated -Running composer update required/pkg +Running shirabe update required/pkg Loading composer repositories with package information Updating dependencies Dependency resolution completed in %d seconds @@ -190,7 +190,7 @@ Using version ^1.0 for required/pkg", ], "<warning>Cannot use required/pkg's latest version 1.1.0 as it requires php ^20 which is not satisfied by your platform. ./composer.json has been updated -Running composer update required/pkg +Running shirabe update required/pkg Loading composer repositories with package information Updating dependencies Lock file operations: 1 install, 0 updates, 0 removals @@ -229,7 +229,7 @@ Using version ^1.0 for required/pkg ("--no-install", InputValue::from(true)), ], "./composer.json has been updated -Running composer update required/pkg +Running shirabe update required/pkg Loading composer repositories with package information Updating dependencies Lock file operations: 2 installs, 0 updates, 0 removals @@ -251,7 +251,7 @@ Using version ^1.1 for required/pkg", ("--fixed", InputValue::from(true)), ], "./composer.json has been updated -Running composer update required/pkg +Running shirabe update required/pkg Loading composer repositories with package information Updating dependencies Lock file operations: 1 install, 0 updates, 0 removals diff --git a/crates/shirabe/tests/command/show_command_test.rs b/crates/shirabe/tests/command/show_command_test.rs index 3834b016..a35f6500 100644 --- a/crates/shirabe/tests/command/show_command_test.rs +++ b/crates/shirabe/tests/command/show_command_test.rs @@ -1105,7 +1105,7 @@ fn test_not_installed_error() { app_tester .get_display() .trim() - .contains("No dependencies installed. Try running composer install or update."), + .contains("No dependencies installed. Try running shirabe install or update."), "Should show error message when no dependencies are installed" ); } diff --git a/crates/shirabe/tests/command/update_command_test.rs b/crates/shirabe/tests/command/update_command_test.rs index 6fe8f927..e4d3cb71 100644 --- a/crates/shirabe/tests/command/update_command_test.rs +++ b/crates/shirabe/tests/command/update_command_test.rs @@ -148,7 +148,7 @@ Your requirements could not be resolved to an installable set of packages. root_dep_and_transitive_dep(), vec![("--with", InputValue::Array(vec!["root/req:^2".to_string()]))], "The temporary constraint \"^2\" for \"root/req\" must be a subset of the constraint in your composer.json (1.*) -Run `composer require root/req` or `composer require root/req:^2` instead to replace the constraint", +Run `shirabe require root/req` or `shirabe require root/req:^2` instead to replace the constraint", false, ), ( @@ -166,7 +166,7 @@ Package operations: 2 installs, 0 updates, 0 removals - Installing root/req (1.0.0) Bumping dependencies <warning>Warning: Bumping dependency constraints is not recommended for libraries as it will narrow down your dependencies and may cause problems for your users.</warning> -<warning>If your package is not a library, you can explicitly specify the \"type\" by using \"composer config type project\".</warning> +<warning>If your package is not a library, you can explicitly specify the \"type\" by using \"shirabe config type project\".</warning> <warning>Alternatively you can use --bump-after-update=dev to only bump dependencies within \"require-dev\".</warning> No requirements to update in ./composer.json.", true, diff --git a/crates/shirabe/tests/installer_test.rs b/crates/shirabe/tests/installer_test.rs index 922fbd45..597f8b86 100644 --- a/crates/shirabe/tests/installer_test.rs +++ b/crates/shirabe/tests/installer_test.rs @@ -569,6 +569,15 @@ struct IntegrationCase { expect_result: ExpectResult, } +/// The fixtures come from Composer's tree and name the `composer` binary in the hints they expect +/// on stdout; Shirabe prints its own name there. +fn rename_binary_in_expected_output(expected: String) -> String { + regex::Regex::new(r"\bcomposer (?P<cmd>config|fund|suggest|update)\b") + .unwrap() + .replace_all(&expected, "shirabe $cmd") + .into_owned() +} + fn fixtures_dir(path: &str) -> std::path::PathBuf { std::path::Path::new(env!("CARGO_MANIFEST_DIR")) .join("../../composer/tests/Composer/Test/Fixtures") @@ -752,8 +761,14 @@ fn load_integration_tests(path: &str) -> Vec<IntegrationCase> { .filter(|s| !s.is_empty()) .map(|s| serde_json::from_str(s).unwrap()); - let expect_output = test_data.get("EXPECT-OUTPUT").cloned(); - let expect_output_optimized = test_data.get("EXPECT-OUTPUT-OPTIMIZED").cloned(); + let expect_output = test_data + .get("EXPECT-OUTPUT") + .cloned() + .map(rename_binary_in_expected_output); + let expect_output_optimized = test_data + .get("EXPECT-OUTPUT-OPTIMIZED") + .cloned() + .map(rename_binary_in_expected_output); let expect = test_data["EXPECT"].clone(); let expect_result = diff --git a/crates/shirabe/tests/json/json_file_test.rs b/crates/shirabe/tests/json/json_file_test.rs index 490571ec..62476619 100644 --- a/crates/shirabe/tests/json/json_file_test.rs +++ b/crates/shirabe/tests/json/json_file_test.rs @@ -469,7 +469,7 @@ fn merge_conflict_simple_data() -> PhpMixed { data.insert( "content-hash".to_string(), PhpMixed::String( - "VCS merge conflict detected. Please run `composer update --lock`.".to_string(), + "VCS merge conflict detected. Please run `shirabe update --lock`.".to_string(), ), ); data.insert("packages".to_string(), PhpMixed::List(vec![])); @@ -542,7 +542,7 @@ fn test_composer_lock_file_merge_conflict_extended() { let json = JsonFile::parse_json(Some(&data), Some("/path/to/composer.lock")).unwrap(); assert_eq!( - "VCS merge conflict detected. Please run `composer update --lock`.", + "VCS merge conflict detected. Please run `shirabe update --lock`.", json.as_array() .unwrap() .get("content-hash") diff --git a/crates/shirabe/tests/util/bitbucket_test.rs b/crates/shirabe/tests/util/bitbucket_test.rs index 19641fed..c6b3f619 100644 --- a/crates/shirabe/tests/util/bitbucket_test.rs +++ b/crates/shirabe/tests/util/bitbucket_test.rs @@ -388,7 +388,7 @@ fn test_request_access_token_with_username_and_password_with_unauthorized_respon Expectation::auth(ORIGIN, USERNAME, Some(PASSWORD.to_string())), Expectation::text("Invalid OAuth consumer provided."), Expectation::text( - "You can also add it manually later by using \"composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>\"", + "You can also add it manually later by using \"shirabe config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>\"", ), ], true, |
