diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-07-04 03:20:23 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-07-04 16:58:29 +0900 |
| commit | 31f6ac69794361cdaee52cba0213a1b4da4932ac (patch) | |
| tree | 7cdc57124a13daea5c74ef03161098bb4664fa0c /crates/shirabe/tests/repository/platform_repository_test.rs | |
| parent | f7b0eee15f17a4fa5db717cda5ddc387f884afd0 (diff) | |
| download | php-shirabe-31f6ac69794361cdaee52cba0213a1b4da4932ac.tar.gz php-shirabe-31f6ac69794361cdaee52cba0213a1b4da4932ac.tar.zst php-shirabe-31f6ac69794361cdaee52cba0213a1b4da4932ac.zip | |
fix(event-dispatcher): avoid reentrant RefCell panics
Two related "already borrowed" panics reachable from
AutoloadGenerator::dump() (which holds the local-repository,
installation-manager, and config RefCells for the duration of its own
statement, per the temporary-lifetime-extension pattern fixed
separately in create_project_command.rs):
- ensure_bin_dir_is_in_path called config.borrow_mut() to read
"bin-dir", but Config::get only needs &self; use borrow() so it can
coexist with an outer borrow instead of conflicting with it.
- make_autoloader's real body needed composer_handle.borrow_mut() plus
the same local-repository/installation-manager RefCells the caller
already holds mutably, which cannot be made reentrant-safe without a
larger restructuring. Since all 3 call sites already discard its
return value, and its only effect (registering a Composer-generated
ClassLoader for autoloading during event-listener PHP execution) is
unobservable in this port — there's no embedded PHP interpreter to
register it into, and class_exists for user-defined classes is a
hardcoded-false shim so the caller's very next check always treats
the class as unavailable regardless — make it a genuine no-op.
This unblocks the post-autoload-dump event for any script listener
naming a PHP class (e.g. Illuminate\Foundation\ComposerScripts), which
every create-project/install run reaches once real packages get
installed.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests/repository/platform_repository_test.rs')
| -rw-r--r-- | crates/shirabe/tests/repository/platform_repository_test.rs | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/crates/shirabe/tests/repository/platform_repository_test.rs b/crates/shirabe/tests/repository/platform_repository_test.rs index 7d2a328..83edf63 100644 --- a/crates/shirabe/tests/repository/platform_repository_test.rs +++ b/crates/shirabe/tests/repository/platform_repository_test.rs @@ -55,17 +55,7 @@ fn constant_key(constant_name: &str, class: Option<&str>) -> String { .to_string() } -// All five tests below are fully ported but kept `#[ignore]`: every code path through -// `PlatformRepository::initialize()` reaches `XdebugHandler::get_skipped_version()`, -// which is an unrelated `todo!()` stub in `shirabe-external-packages`, so the tests -// panic before any assertion (Phase D: visible failure is acceptable, and the category -// brief permits leaving confidently-panicking tests ignored). The seam/mocks are in -// place so they will execute once that stub lands. - #[test] -#[ignore = "seam + HhvmDetector mock ported; execution panics at the unrelated \ - XdebugHandler::get_skipped_version() todo!() during initialize(), and the \ - default (real) Runtime also relies on PHP-runtime shim todo!()s"] fn test_hhvm_package() { let mut hhvm_detector = MockHhvmDetector::new(); hhvm_detector @@ -145,8 +135,6 @@ fn php_flavor_test_cases() -> Vec<( } #[test] -#[ignore = "seam + Runtime mock ported (hasConstant/getConstant/invoke/getExtensions); \ - execution panics at the unrelated XdebugHandler::get_skipped_version() todo!()"] fn test_php_version() { for (constants, packages, functions) in php_flavor_test_cases() { let constants_has = constants.clone(); @@ -209,8 +197,6 @@ fn test_php_version() { } #[test] -#[ignore = "seam + Runtime mock ported (invoke once + getConstant callback); \ - execution panics at the unrelated XdebugHandler::get_skipped_version() todo!()"] fn test_inet_pton_regression() { let mut runtime = MockRuntime::new(); // PHP: ->expects(self::once())->method('invoke')->with('inet_pton', ['::'])->willReturn(false). @@ -1627,10 +1613,10 @@ fn assert_package_links( } #[test] -#[ignore = "all 59 provideLibraryTestCases datasets ported faithfully; execution still \ - panics at the unrelated XdebugHandler::get_skipped_version() todo!() (and a few \ - cases additionally rely on the ResourceBundle/Imagick stub paths), so it stays \ - ignored"] +#[ignore = "all 59 provideLibraryTestCases datasets ported faithfully; several cases rely on \ + ResourceBundle/Imagick-derived extension info (e.g. lib-icu-cldr) that is not yet \ + modeled, so the generated package set diverges from PHP's (confirmed: fails with \ + an extension mismatch, not a panic), and it stays ignored"] fn test_library_information() { let extension_version = "100.200.300"; @@ -1803,8 +1789,6 @@ fn test_library_information() { } #[test] -#[ignore = "seam + Runtime mock ported (getConstant/getExtensions map); execution panics \ - at the unrelated XdebugHandler::get_skipped_version() todo!()"] fn test_composer_platform_version() { let constants: IndexMap<String, PhpMixed> = IndexMap::from([ ( |
