diff options
Diffstat (limited to 'crates/shirabe/tests')
| -rw-r--r-- | crates/shirabe/tests/common/bootstrap.rs | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/crates/shirabe/tests/common/bootstrap.rs b/crates/shirabe/tests/common/bootstrap.rs index 6e7cd32c..8b2a8aa0 100644 --- a/crates/shirabe/tests/common/bootstrap.rs +++ b/crates/shirabe/tests/common/bootstrap.rs @@ -10,10 +10,31 @@ use shirabe::util::platform::Platform; /// /// 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. +/// covers the whole suite unconditionally. Rust's libtest has no per-binary setup hook, so a true +/// equivalent needs either the `ctor` crate (new dependency, user decision) or wiring a call into +/// every shared fixture constructor. pub fn bootstrap() { - Platform::put_env("COMPOSER_TESTS_ARE_RUNNING", "1"); + static ONCE: std::sync::Once = std::sync::Once::new(); + ONCE.call_once(|| { + // PHP: error_reporting(E_ALL) has no counterpart here. - // TODO(phase-d): port remaining bootstrap processes. + // PHP: date_default_timezone_set(@date_default_timezone_get()); + shirabe_php_shim::date_default_timezone_set(&shirabe_php_shim::date_default_timezone_get()); + + // PHP: require src/bootstrap.php and refresh vendor/composer/InstalledVersions.php. + // TODO(phase-d): port remaining bootstrap processes (the src/bootstrap.php include and + // the InstalledVersions refresh are PHP autoload mechanics with no Rust counterpart yet). + + Platform::put_env("COMPOSER_TESTS_ARE_RUNNING", "1"); + + // ensure Windows color support detection does not attempt to use colors + // as this is dependent on env vars and not actual stream capabilities, see + // https://github.com/composer/composer/issues/11598 + Platform::put_env("NO_COLOR", "1"); + + // symfony/phpunit-bridge sets some default env vars which we do not need polluting the test env + Platform::clear_env("COMPOSER"); + Platform::clear_env("COMPOSER_VENDOR_DIR"); + Platform::clear_env("COMPOSER_BIN_DIR"); + }); } |
