From d4cdccb8de8758bd46a12283f8df90e020327b99 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Thu, 25 Jun 2026 15:24:55 +0900 Subject: test: port 70 perforce/repository/downloader/installer/dispatcher tests Port perforce (36), locker (10), composer_repository (7), installation_manager (6), file_downloader (5), and event_dispatcher (6) tests via the mock infra. Fix production porting bugs surfaced en route: BufferIO::get_output look-behind regex, ComposerRepository list-form package iteration and initialize dispatch, gethostname and spl_autoload_functions shims; add EventDispatcher get_listeners test seam. Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/shirabe-php-shim/src/net.rs | 9 ++++++++- crates/shirabe-php-shim/src/runtime.rs | 7 +++++-- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'crates/shirabe-php-shim') diff --git a/crates/shirabe-php-shim/src/net.rs b/crates/shirabe-php-shim/src/net.rs index 0ecf5cb..5632c83 100644 --- a/crates/shirabe-php-shim/src/net.rs +++ b/crates/shirabe-php-shim/src/net.rs @@ -1,7 +1,14 @@ use std::net::{IpAddr, SocketAddr, ToSocketAddrs}; pub fn gethostname() -> String { - todo!() + // PHP's gethostname() wraps gethostname(2). On Linux the kernel exposes the + // same value via /proc; fall back to the HOSTNAME env var, then to "localhost". + std::fs::read_to_string("/proc/sys/kernel/hostname") + .ok() + .map(|s| s.trim().to_string()) + .filter(|s| !s.is_empty()) + .or_else(|| std::env::var("HOSTNAME").ok().filter(|s| !s.is_empty())) + .unwrap_or_else(|| "localhost".to_string()) } // Resolves the first IPv4 address for the host name, mirroring PHP's gethostbyname diff --git a/crates/shirabe-php-shim/src/runtime.rs b/crates/shirabe-php-shim/src/runtime.rs index c1c5f61..73a4189 100644 --- a/crates/shirabe-php-shim/src/runtime.rs +++ b/crates/shirabe-php-shim/src/runtime.rs @@ -244,8 +244,11 @@ pub fn error_reporting(level: Option) -> i64 { } pub fn spl_autoload_functions() -> Vec { - // TODO(phase-d): see spl_autoload_register; no autoload registry exists. - todo!() + // In compiled Rust there is no runtime class-autoload registry, so no autoload functions are + // ever registered. Callers (e.g. EventDispatcher::do_dispatch, which diffs the registry before + // and after running listeners to re-order plugin-prepended autoloaders) therefore always + // observe an empty list. See spl_autoload_register/unregister, which remain unimplemented. + Vec::new() } pub fn version_compare(_v1: &str, _v2: &str, _op: &str) -> bool { -- cgit v1.3.1