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/common | |
| 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/common')
| -rw-r--r-- | crates/shirabe/tests/common/bootstrap.rs | 19 | ||||
| -rw-r--r-- | crates/shirabe/tests/common/test_case.rs | 2 |
2 files changed, 21 insertions, 0 deletions
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) |
