From e98823e599eb375b30037cc714710e3309d927d1 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 27 Jun 2026 17:21:00 +0900 Subject: test: port Composer tests unblocked by mockall, add seams Port 11 categories of previously-ignored Composer tests now reachable with the mockall crate: DownloadManager, VCS/Perforce/File downloaders, VersionSelector, PlatformRepository, Auditor, installer/FilesystemRepository, RootPackageLoader, util auth/http, commands, and Cache. Extract test seams additively on concrete structs as *Interface traits (Runtime, HhvmDetector, VersionGuesser, RepositorySet, Perforce, BinaryInstaller) plus mock-field seams (Cache, Filesystem); consumers take trait objects. Mocks are defined locally in the test crates via mockall::mock!, since automock-generated mocks are cfg(test)-gated and invisible across the integration-test boundary. dataProviders are ported in full; tests blocked by unported shims stay #[ignore] with documented reasons rather than reduced or weakened. Fix product bugs surfaced by the ports: - util/github: use the exception code, not the HTTP status, for 401/403 - advisory: serialize empty audit maps as [] to match PHP json_encode - repository/filesystem and downloader/file: fix RefCell double-borrow panics Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/shirabe/src/installer/binary_installer.rs | 28 ++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'crates/shirabe/src/installer/binary_installer.rs') diff --git a/crates/shirabe/src/installer/binary_installer.rs b/crates/shirabe/src/installer/binary_installer.rs index a76f69e..ea73f6f 100644 --- a/crates/shirabe/src/installer/binary_installer.rs +++ b/crates/shirabe/src/installer/binary_installer.rs @@ -17,6 +17,34 @@ use crate::util::Platform; use crate::util::ProcessExecutor; use crate::util::Silencer; +/// Seam over the BinaryInstaller methods reached through LibraryInstaller, so tests can inject a +/// recording double. Composer has no PHP `BinaryInstallerInterface`; this exists only to allow the +/// `LibraryInstaller` collaborator to be mocked the way PHPUnit mocks the concrete class. +pub trait BinaryInstallerInterface: std::fmt::Debug { + fn install_binaries( + &mut self, + package: PackageInterfaceHandle, + install_path: &str, + warn_on_overwrite: bool, + ); + fn remove_binaries(&mut self, package: PackageInterfaceHandle); +} + +impl BinaryInstallerInterface for BinaryInstaller { + fn install_binaries( + &mut self, + package: PackageInterfaceHandle, + install_path: &str, + warn_on_overwrite: bool, + ) { + BinaryInstaller::install_binaries(self, package, install_path, warn_on_overwrite); + } + + fn remove_binaries(&mut self, package: PackageInterfaceHandle) { + BinaryInstaller::remove_binaries(self, package); + } +} + /// Utility to handle installation of package "bin"/binaries #[derive(Debug)] pub struct BinaryInstaller { -- cgit v1.3.1