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/version_guesser_test.rs | |
| 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/version_guesser_test.rs')
| -rw-r--r-- | crates/shirabe/tests/package/version/version_guesser_test.rs | 59 |
1 files changed, 43 insertions, 16 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"); + } } |
