diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-15 08:56:04 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-15 08:56:04 +0900 |
| commit | b1f74fd83663d26e14f92300f452a3c997d93d62 (patch) | |
| tree | a930aee236c53e57fa13dc007ce30b60de272906 /crates/shirabe/tests/common | |
| parent | 2e40eaf6bf5c4bd8eedad597e4c3b19b5457421b (diff) | |
| download | php-shirabe-b1f74fd83663d26e14f92300f452a3c997d93d62.tar.gz php-shirabe-b1f74fd83663d26e14f92300f452a3c997d93d62.tar.zst php-shirabe-b1f74fd83663d26e14f92300f452a3c997d93d62.zip | |
fix(php-rpc): unpack the runtime bundle under the cache dir
A worker whose PHP cannot read the bundle out of the executable gets it
from an unpacked copy, which went to a directory derived from
XDG_CACHE_HOME alone. That ignored COMPOSER_CACHE_DIR, COMPOSER_HOME and
the cache-dir setting, and put the files outside the directory clear-cache
and the platform conventions cover. The callers now pass Composer's
configured cache directory down to base_path().
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests/common')
| -rw-r--r-- | crates/shirabe/tests/common/php_worker.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/crates/shirabe/tests/common/php_worker.rs b/crates/shirabe/tests/common/php_worker.rs index af1b6b44..b432cb4f 100644 --- a/crates/shirabe/tests/common/php_worker.rs +++ b/crates/shirabe/tests/common/php_worker.rs @@ -25,9 +25,14 @@ pub fn lock_php_worker() -> std::sync::MutexGuard<'static, ()> { } /// Requires the Composer PHP runtime's `vendor/autoload.php` into the worker, which is what makes -/// the real `Composer\` classes autoloadable there. +/// the real `Composer\` classes autoloadable there. A worker whose PHP cannot read the runtime out +/// of the test binary unpacks it under a cache directory of this test run, never the one the +/// developer's own Composer uses. pub fn load_composer_php_runtime() { - shirabe::event_dispatcher::EventDispatcher::__ensure_composer_php_runtime().unwrap(); + static CACHE: std::sync::OnceLock<tempfile::TempDir> = std::sync::OnceLock::new(); + let cache = CACHE.get_or_init(|| tempfile::tempdir().expect("no cache directory for the test")); + shirabe::event_dispatcher::EventDispatcher::__ensure_composer_php_runtime(cache.path()) + .unwrap(); } /// Calls a static method in the worker, panicking on either failure lane. |
