diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-22 02:09:59 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-22 02:09:59 +0900 |
| commit | 822d9a872807a92a5337ee8b7bab96dc9845cdbb (patch) | |
| tree | 4931365df5978caffade69cad2154718a9076f66 /crates/shirabe/tests/package/version | |
| parent | f691b864b687f251c3b266e8cff2774d730567ba (diff) | |
| download | php-shirabe-822d9a872807a92a5337ee8b7bab96dc9845cdbb.tar.gz php-shirabe-822d9a872807a92a5337ee8b7bab96dc9845cdbb.tar.zst php-shirabe-822d9a872807a92a5337ee8b7bab96dc9845cdbb.zip | |
test: port more test cases
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests/package/version')
| -rw-r--r-- | crates/shirabe/tests/package/version/version_guesser_test.rs | 59 | ||||
| -rw-r--r-- | crates/shirabe/tests/package/version/version_selector_test.rs | 26 |
2 files changed, 56 insertions, 29 deletions
diff --git a/crates/shirabe/tests/package/version/version_guesser_test.rs b/crates/shirabe/tests/package/version/version_guesser_test.rs index 75d4ae0..76cd672 100644 --- a/crates/shirabe/tests/package/version/version_guesser_test.rs +++ b/crates/shirabe/tests/package/version/version_guesser_test.rs @@ -1,5 +1,13 @@ //! ref: composer/tests/Composer/Test/Package/Version/VersionGuesserTest.php +use std::cell::RefCell; +use std::rc::Rc; + +use shirabe::config::Config; +use shirabe::package::version::{VersionGuesser, VersionParser}; +use shirabe::util::platform::Platform; +use shirabe::util::process_executor::ProcessExecutor; + #[allow(dead_code)] fn set_up() { // Resets GitUtil's cached `version` static via ReflectionProperty; the static is not @@ -23,94 +31,113 @@ impl Drop for TearDown { // These drive VersionGuesser with a mocked ProcessExecutor feeding git/hg command output; // mocking is not available here. +#[ignore = "requires getProcessExecutorMock with expects() command expectations; no ProcessExecutorMock mocking infrastructure exists"] #[test] -#[ignore = "mocks a ProcessExecutor feeding git/hg output to drive VersionGuesser; mocking is not available"] fn test_hg_guess_version_returns_data() { todo!() } +#[ignore = "requires getProcessExecutorMock with expects() command expectations; no ProcessExecutorMock mocking infrastructure exists"] #[test] -#[ignore = "mocks a ProcessExecutor feeding git/hg output to drive VersionGuesser; mocking is not available"] fn test_guess_version_returns_data() { todo!() } +#[ignore = "requires getProcessExecutorMock with expects() command expectations; no ProcessExecutorMock mocking infrastructure exists"] #[test] -#[ignore = "mocks a ProcessExecutor feeding git/hg output to drive VersionGuesser; mocking is not available"] fn test_guess_version_does_not_see_custom_default_branch_as_non_feature_branch() { todo!() } +#[ignore = "requires getProcessExecutorMock with expects() command expectations; no ProcessExecutorMock mocking infrastructure exists"] #[test] -#[ignore = "mocks a ProcessExecutor feeding git/hg output to drive VersionGuesser; mocking is not available"] fn test_guess_version_reads_and_respects_non_feature_branches_configuration_for_arbitrary_naming() { todo!() } +#[ignore = "requires getProcessExecutorMock with expects() command expectations; no ProcessExecutorMock mocking infrastructure exists"] #[test] -#[ignore = "mocks a ProcessExecutor feeding git/hg output to drive VersionGuesser; mocking is not available"] fn test_guess_version_reads_and_respects_non_feature_branches_configuration_for_arbitrary_naming_regex() { todo!() } +#[ignore = "requires getProcessExecutorMock with expects() command expectations; no ProcessExecutorMock mocking infrastructure exists"] #[test] -#[ignore = "mocks a ProcessExecutor feeding git/hg output to drive VersionGuesser; mocking is not available"] fn test_guess_version_reads_and_respects_non_feature_branches_configuration_for_arbitrary_naming_when_on_non_feature_branch() { todo!() } +#[ignore = "requires getProcessExecutorMock with expects() command expectations; no ProcessExecutorMock mocking infrastructure exists"] #[test] -#[ignore = "mocks a ProcessExecutor feeding git/hg output to drive VersionGuesser; mocking is not available"] fn test_detached_head_becomes_dev_hash() { todo!() } +#[ignore = "requires getProcessExecutorMock with expects() command expectations; no ProcessExecutorMock mocking infrastructure exists"] #[test] -#[ignore = "mocks a ProcessExecutor feeding git/hg output to drive VersionGuesser; mocking is not available"] fn test_detached_fetch_head_becomes_dev_hash_git2() { todo!() } +#[ignore = "requires getProcessExecutorMock with expects() command expectations; no ProcessExecutorMock mocking infrastructure exists"] #[test] -#[ignore = "mocks a ProcessExecutor feeding git/hg output to drive VersionGuesser; mocking is not available"] fn test_detached_commit_head_becomes_dev_hash_git2() { todo!() } +#[ignore = "requires getProcessExecutorMock with expects() command expectations; no ProcessExecutorMock mocking infrastructure exists"] #[test] -#[ignore = "mocks a ProcessExecutor feeding git/hg output to drive VersionGuesser; mocking is not available"] fn test_tag_becomes_version() { todo!() } +#[ignore = "requires getProcessExecutorMock with expects() command expectations; no ProcessExecutorMock mocking infrastructure exists"] #[test] -#[ignore = "mocks a ProcessExecutor feeding git/hg output to drive VersionGuesser; mocking is not available"] fn test_tag_becomes_pretty_version() { todo!() } +#[ignore = "requires getProcessExecutorMock with expects() command expectations; no ProcessExecutorMock mocking infrastructure exists"] #[test] -#[ignore = "mocks a ProcessExecutor feeding git/hg output to drive VersionGuesser; mocking is not available"] fn test_invalid_tag_becomes_version() { todo!() } +#[ignore = "requires getProcessExecutorMock with expects() command expectations; no ProcessExecutorMock mocking infrastructure exists"] #[test] -#[ignore = "mocks a ProcessExecutor feeding git/hg output to drive VersionGuesser; mocking is not available"] fn test_numeric_branches_show_nicely() { todo!() } +#[ignore = "requires getProcessExecutorMock with expects() command expectations; no ProcessExecutorMock mocking infrastructure exists"] #[test] -#[ignore = "mocks a ProcessExecutor feeding git/hg output to drive VersionGuesser; mocking is not available"] fn test_remote_branches_are_selected() { todo!() } +#[ignore] #[test] -#[ignore = "mocks a ProcessExecutor feeding git/hg output to drive VersionGuesser; mocking is not available"] fn test_get_root_version_from_env() { - todo!() + // @dataProvider rootEnvVersionsProvider + let root_env_versions: Vec<(&str, &str)> = vec![ + ("1.0-dev", "1.0.x-dev"), + ("1.0.x-dev", "1.0.x-dev"), + ("1-dev", "1.x-dev"), + ("1.x-dev", "1.x-dev"), + ("1.0.0", "1.0.0"), + ]; + + for (env, expected_version) in root_env_versions { + Platform::put_env("COMPOSER_ROOT_VERSION", env); + let config = Rc::new(RefCell::new(Config::new(true, None))); + let process = Rc::new(RefCell::new(ProcessExecutor::new(None))); + let guesser = VersionGuesser::new(config, process, VersionParser::new(), None); + assert_eq!( + expected_version, + guesser.get_root_version_from_env().unwrap() + ); + Platform::clear_env("COMPOSER_ROOT_VERSION"); + } } diff --git a/crates/shirabe/tests/package/version/version_selector_test.rs b/crates/shirabe/tests/package/version/version_selector_test.rs index fd426ce..fa288cd 100644 --- a/crates/shirabe/tests/package/version/version_selector_test.rs +++ b/crates/shirabe/tests/package/version/version_selector_test.rs @@ -3,79 +3,79 @@ // VersionSelector ranks candidate packages whose versions/constraints are parsed through a // look-around regex the regex crate cannot compile; the setup also mocks a repository. #[test] -#[ignore = "not yet ported (VersionSelector over a mocked repository; constraint parsing uses a look-around regex)"] +#[ignore = "requires mocking RepositorySet::find_packages to return fixed package objects; RepositorySet is a concrete struct with no injectable/overridable find_packages"] fn test_latest_version_is_returned() { todo!() } #[test] -#[ignore = "not yet ported (VersionSelector over a mocked repository; constraint parsing uses a look-around regex)"] +#[ignore = "requires mocking RepositorySet::find_packages to return fixed package objects; RepositorySet is a concrete struct with no injectable/overridable find_packages"] fn test_latest_version_is_returned_that_matches_php_requirements() { todo!() } #[test] -#[ignore = "not yet ported (VersionSelector over a mocked repository; constraint parsing uses a look-around regex)"] +#[ignore = "requires mocking RepositorySet::find_packages to return fixed package objects; RepositorySet is a concrete struct with no injectable/overridable find_packages"] fn test_latest_version_is_returned_that_matches_ext_requirements() { todo!() } #[test] -#[ignore = "not yet ported (VersionSelector over a mocked repository; constraint parsing uses a look-around regex)"] +#[ignore = "requires mocking RepositorySet::find_packages to return fixed package objects; RepositorySet is a concrete struct with no injectable/overridable find_packages"] fn test_latest_version_is_returned_that_matches_platform_ext() { todo!() } #[test] -#[ignore = "not yet ported (VersionSelector over a mocked repository; constraint parsing uses a look-around regex)"] +#[ignore = "requires mocking RepositorySet::find_packages to return fixed package objects; RepositorySet is a concrete struct with no injectable/overridable find_packages"] fn test_latest_version_is_returned_that_matches_composer_requirements() { todo!() } #[test] -#[ignore = "not yet ported (VersionSelector over a mocked repository; constraint parsing uses a look-around regex)"] +#[ignore = "requires mocking RepositorySet::find_packages to return fixed package objects; RepositorySet is a concrete struct with no injectable/overridable find_packages"] fn test_most_stable_version_is_returned() { todo!() } #[test] -#[ignore = "not yet ported (VersionSelector over a mocked repository; constraint parsing uses a look-around regex)"] +#[ignore = "requires mocking RepositorySet::find_packages with willReturnOnConsecutiveCalls; RepositorySet is a concrete struct with no injectable/overridable find_packages"] fn test_most_stable_version_is_returned_regardless_of_order() { todo!() } #[test] -#[ignore = "not yet ported (VersionSelector over a mocked repository; constraint parsing uses a look-around regex)"] +#[ignore = "requires mocking RepositorySet::find_packages to return fixed package objects; RepositorySet is a concrete struct with no injectable/overridable find_packages"] fn test_highest_version_is_returned() { todo!() } #[test] -#[ignore = "not yet ported (VersionSelector over a mocked repository; constraint parsing uses a look-around regex)"] +#[ignore = "requires mocking RepositorySet::find_packages to return fixed package objects; RepositorySet is a concrete struct with no injectable/overridable find_packages"] fn test_highest_version_matching_stability_is_returned() { todo!() } #[test] -#[ignore = "not yet ported (VersionSelector over a mocked repository; constraint parsing uses a look-around regex)"] +#[ignore = "requires mocking RepositorySet::find_packages to return fixed package objects; RepositorySet is a concrete struct with no injectable/overridable find_packages"] fn test_most_stable_unstable_version_is_returned() { todo!() } #[test] -#[ignore = "not yet ported (VersionSelector over a mocked repository; constraint parsing uses a look-around regex)"] +#[ignore = "requires mocking RepositorySet::find_packages to return fixed package objects; RepositorySet is a concrete struct with no injectable/overridable find_packages"] fn test_default_branch_alias_is_never_returned() { todo!() } #[test] -#[ignore = "not yet ported (VersionSelector over a mocked repository; constraint parsing uses a look-around regex)"] +#[ignore = "requires mocking RepositorySet::find_packages to return an empty list; RepositorySet is a concrete struct with no injectable/overridable find_packages"] fn test_false_returned_on_no_packages() { todo!() } #[test] -#[ignore = "not yet ported (VersionSelector over a mocked repository; constraint parsing uses a look-around regex)"] +#[ignore = "branch-alias cases need Package::set_extra, exposed only on RootPackageHandle, not on the PackageHandle/PackageInterfaceHandle passed to find_recommended_require_version"] fn test_find_recommended_require_version() { todo!() } |
