diff options
Diffstat (limited to 'crates/shirabe/tests')
| -rw-r--r-- | crates/shirabe/tests/advisory/main.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/tests/application_test.rs | 2 | ||||
| -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 | ||||
| -rw-r--r-- | crates/shirabe/tests/common/bootstrap.rs | 19 | ||||
| -rw-r--r-- | crates/shirabe/tests/common/test_case.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/tests/dependency_resolver/main.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/tests/installer/main.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/tests/installer_test.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/tests/package/main.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/tests/repository/main.rs | 2 |
12 files changed, 55 insertions, 10 deletions
diff --git a/crates/shirabe/tests/advisory/main.rs b/crates/shirabe/tests/advisory/main.rs index 51b470e2..a2475f80 100644 --- a/crates/shirabe/tests/advisory/main.rs +++ b/crates/shirabe/tests/advisory/main.rs @@ -1,3 +1,5 @@ +#[path = "../common/bootstrap.rs"] +mod bootstrap; #[path = "../common/io_mock.rs"] mod io_mock; #[path = "../common/test_case.rs"] diff --git a/crates/shirabe/tests/application_test.rs b/crates/shirabe/tests/application_test.rs index 2bb2b68a..f4542964 100644 --- a/crates/shirabe/tests/application_test.rs +++ b/crates/shirabe/tests/application_test.rs @@ -5,6 +5,8 @@ // Symfony command-registry model), or a runtime define() of COMPOSER_DEV_WARNING_TIME, // remain unportable. +#[path = "common/bootstrap.rs"] +mod bootstrap; #[path = "common/test_case.rs"] mod test_case; 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": [ diff --git a/crates/shirabe/tests/common/bootstrap.rs b/crates/shirabe/tests/common/bootstrap.rs new file mode 100644 index 00000000..6e7cd32c --- /dev/null +++ b/crates/shirabe/tests/common/bootstrap.rs @@ -0,0 +1,19 @@ +//! ref: composer/tests/bootstrap.php + +use shirabe::util::platform::Platform; + +/// PHPUnit loads `bootstrap.php` once for the entire test run (see `composer/phpunit.xml.dist`'s +/// `bootstrap` attribute), so every PHP test implicitly gets `COMPOSER_TESTS_ARE_RUNNING=1` +/// before it runs. Without it, `Application::do_run` disables interactivity whenever stdin isn't +/// a tty (as it isn't under `cargo test`), so interactive `ApplicationTester` runs silently no-op +/// instead of consuming `set_inputs`. +/// +/// TODO(phase-d): this is only wired into `get_application_tester()` (used by the `command` test +/// binary) rather than into every test binary's `main.rs`, unlike PHPUnit's bootstrap which +/// covers the whole suite unconditionally. Call this from a shared entry point across all test +/// binaries once one exists. +pub fn bootstrap() { + Platform::put_env("COMPOSER_TESTS_ARE_RUNNING", "1"); + + // TODO(phase-d): port remaining bootstrap processes. +} diff --git a/crates/shirabe/tests/common/test_case.rs b/crates/shirabe/tests/common/test_case.rs index a8bcb6a8..91d890a9 100644 --- a/crates/shirabe/tests/common/test_case.rs +++ b/crates/shirabe/tests/common/test_case.rs @@ -259,6 +259,8 @@ pub fn create_composer_lock( /// ref: TestCase::getApplicationTester pub fn get_application_tester() -> ApplicationTester { + crate::bootstrap::bootstrap(); + let application = ApplicationHandle::new("Composer".to_string(), "".to_string()).unwrap(); application.set_catch_exceptions(false); ApplicationTester::new(application) diff --git a/crates/shirabe/tests/dependency_resolver/main.rs b/crates/shirabe/tests/dependency_resolver/main.rs index 7a129efc..0531f777 100644 --- a/crates/shirabe/tests/dependency_resolver/main.rs +++ b/crates/shirabe/tests/dependency_resolver/main.rs @@ -1,3 +1,5 @@ +#[path = "../common/bootstrap.rs"] +mod bootstrap; #[path = "../common/test_case.rs"] mod test_case; diff --git a/crates/shirabe/tests/installer/main.rs b/crates/shirabe/tests/installer/main.rs index b3641108..1b6f1804 100644 --- a/crates/shirabe/tests/installer/main.rs +++ b/crates/shirabe/tests/installer/main.rs @@ -1,5 +1,7 @@ #[path = "../common/async_runtime.rs"] mod async_runtime; +#[path = "../common/bootstrap.rs"] +mod bootstrap; #[path = "../common/io_mock.rs"] mod io_mock; #[path = "../common/test_case.rs"] diff --git a/crates/shirabe/tests/installer_test.rs b/crates/shirabe/tests/installer_test.rs index ba3c0e86..c9e0cf63 100644 --- a/crates/shirabe/tests/installer_test.rs +++ b/crates/shirabe/tests/installer_test.rs @@ -1,5 +1,7 @@ //! ref: composer/tests/Composer/Test/InstallerTest.php +#[path = "common/bootstrap.rs"] +mod bootstrap; #[path = "common/config_stub.rs"] mod config_stub; #[path = "common/test_case.rs"] diff --git a/crates/shirabe/tests/package/main.rs b/crates/shirabe/tests/package/main.rs index 7d841b40..1a606b3f 100644 --- a/crates/shirabe/tests/package/main.rs +++ b/crates/shirabe/tests/package/main.rs @@ -1,3 +1,5 @@ +#[path = "../common/bootstrap.rs"] +mod bootstrap; #[path = "../common/config_stub.rs"] mod config_stub; #[path = "../common/io_stub.rs"] diff --git a/crates/shirabe/tests/repository/main.rs b/crates/shirabe/tests/repository/main.rs index f5ecbc63..e86772e7 100644 --- a/crates/shirabe/tests/repository/main.rs +++ b/crates/shirabe/tests/repository/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"] |
