diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-07-19 14:57:17 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-07-19 14:57:17 +0900 |
| commit | a3334ee267d3e905646bdb49c2edc8774ac8d966 (patch) | |
| tree | cd6a805445ea330f706dc96f8ed1b5a249d7661b /crates/shirabe/tests/command | |
| parent | 15c54ec439d0e718ae4aa81cc96c66b69ddfa4d1 (diff) | |
| download | php-shirabe-a3334ee267d3e905646bdb49c2edc8774ac8d966.tar.gz php-shirabe-a3334ee267d3e905646bdb49c2edc8774ac8d966.tar.zst php-shirabe-a3334ee267d3e905646bdb49c2edc8774ac8d966.zip | |
fix(test-harness): set COMPOSER_TESTS_ARE_RUNNING so interactive tests actually run
Without this, Application::do_run force-disabled interactivity whenever
stdin wasn't a tty (as under cargo test), so ApplicationTester runs with
set_inputs silently produced non-interactive default output instead of
consuming the answers, masking real behavior as several stale #[ignore]s
blaming already-implemented ProcessExecutor/Process todo!()s.
Port composer/tests/bootstrap.php's env setup into a bootstrap() helper
called from get_application_tester(), un-ignore the now-passing
init/update command tests, and update init_command_test's expected
schema-validation wording to match the jsonschema crate (already the
accepted wording per 541a8b4f, not an unported gap).
Diffstat (limited to 'crates/shirabe/tests/command')
| -rw-r--r-- | crates/shirabe/tests/command/init_command_test.rs | 21 | ||||
| -rw-r--r-- | crates/shirabe/tests/command/main.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/tests/command/update_command_test.rs | 7 |
3 files changed, 20 insertions, 10 deletions
diff --git a/crates/shirabe/tests/command/init_command_test.rs b/crates/shirabe/tests/command/init_command_test.rs index 32226f62..9c52dddd 100644 --- a/crates/shirabe/tests/command/init_command_test.rs +++ b/crates/shirabe/tests/command/init_command_test.rs @@ -400,9 +400,13 @@ fn run_invalid_data_provider() -> Vec<(InvalidExpectation, Vec<(PhpMixed, PhpMix ], ), // invalid stability argument + // + // WORDING NOTE: upstream asserts justinrainbow/json-schema package's message. Shirabe + // validates with the `jsonschema` crate instead, whose wording differs by design. See also + // composer_schema_test.rs. ( InvalidExpectation::StderrMatches( - r"minimum-stability\s+:\s+Does not have a value in the enumeration", + r#"minimum-stability\s*:\s*"bogus" is not one of "dev", "alpha" or 4 other candidates"#, ), vec![opt("--name", "test/pkg"), opt("--stability", "bogus")], ), @@ -424,8 +428,12 @@ fn run_invalid_data_provider() -> Vec<(InvalidExpectation, Vec<(PhpMixed, PhpMix ], ), // invalid homepage argument + // + // WORDING NOTE: upstream asserts justinrainbow/json-schema package's message. Shirabe + // validates with the `jsonschema` crate instead, whose wording differs by design. See also + // composer_schema_test.rs. ( - InvalidExpectation::StderrMatches(r"homepage\s*:\s*Invalid URL format"), + InvalidExpectation::StderrMatches(r#"homepage\s*:\s*"not-a-url" is not a "uri""#), vec![opt("--name", "test/pkg"), opt("--homepage", "not-a-url")], ), ] @@ -433,8 +441,6 @@ fn run_invalid_data_provider() -> Vec<(InvalidExpectation, Vec<(PhpMixed, PhpMix #[test] #[serial] -#[ignore = "drives InitCommand, which calls get_git_config -> ProcessExecutor::run_process; \ - that path is not ported (shim is_callable and Process::start/run are todo!())"] fn test_run_command_invalid() { set_up(); @@ -519,8 +525,6 @@ fn test_run_guess_name_from_dir_sanitizes_dir() { #[test] #[serial] -#[ignore = "drives InitCommand, which calls get_git_config -> ProcessExecutor::run_process; \ - that path is not ported (shim is_callable and Process::start/run are todo!())"] fn test_interactive_run() { set_up(); @@ -594,8 +598,9 @@ fn test_format_authors() { } #[test] -#[ignore = "calls get_git_config -> ProcessExecutor::run_process, which is not ported \ - (shim is_callable and Process::start/run are todo!())"] +#[ignore = "requires the host's global git config to have user.name/user.email set (Composer's \ + own CI runs `git config --global user.name/user.email` before the test suite); \ + fails in environments without that global config"] fn test_get_git_config() { set_up(); diff --git a/crates/shirabe/tests/command/main.rs b/crates/shirabe/tests/command/main.rs index 13efc0d6..e1edc6c7 100644 --- a/crates/shirabe/tests/command/main.rs +++ b/crates/shirabe/tests/command/main.rs @@ -1,3 +1,5 @@ +#[path = "../common/bootstrap.rs"] +mod bootstrap; #[path = "../common/config_stub.rs"] mod config_stub; #[path = "../common/http_downloader_mock.rs"] diff --git a/crates/shirabe/tests/command/update_command_test.rs b/crates/shirabe/tests/command/update_command_test.rs index b37127ab..866755bf 100644 --- a/crates/shirabe/tests/command/update_command_test.rs +++ b/crates/shirabe/tests/command/update_command_test.rs @@ -352,7 +352,6 @@ Lock file operations: 0 installs, 2 updates, 0 removals #[test] #[serial] -#[ignore = "interactive selection path unported: --interactive requires a TTY and errors with \"--interactive cannot be used in non-interactive terminals.\""] fn test_interactive_mode_throws_if_no_package_to_update() { let composer_json = serde_json::json!({ "repositories": { "packages": { "type": "package", "package": [ @@ -383,7 +382,11 @@ fn test_interactive_mode_throws_if_no_package_to_update() { #[test] #[serial] -#[ignore = "interactive selection path unported: --interactive requires a TTY and errors with \"--interactive cannot be used in non-interactive terminals.\""] +#[ignore = "ConsoleIO::ask_question panics via .expect() on any QuestionHelper validator error \ + instead of propagating it, so io.select()'s \"No package named ...\" validation \ + error can't reach app_tester.run() as an Err; fixing this needs IOInterface::ask()/ \ + select() to return anyhow::Result, which ripples through ~18 ask() and ~4 select() \ + call sites (see project_console_io_ask_select_panics memory)"] fn test_interactive_mode_throws_if_no_package_entered() { let composer_json = serde_json::json!({ "repositories": { "packages": { "type": "package", "package": [ |
