aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/package
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-22 23:42:07 +0900
committernsfisis <nsfisis@gmail.com>2026-06-22 23:42:07 +0900
commit5ab5f3b316798c1411ce8e6a7f5b091fda93589c (patch)
treec7669f94f5d9bd9adc07bc1aab3f14cfdec1ae5f /crates/shirabe/src/package
parentb291e714bc739262140323e08fe2fb9e91e00ee7 (diff)
downloadphp-shirabe-5ab5f3b316798c1411ce8e6a7f5b091fda93589c.tar.gz
php-shirabe-5ab5f3b316798c1411ce8e6a7f5b091fda93589c.tar.zst
php-shirabe-5ab5f3b316798c1411ce8e6a7f5b091fda93589c.zip
test: port previously-ignored Composer tests via __ test hatches
Re-evaluate the reason'd #[ignore] tests under the Phase D criterion: a test is unportable ONLY if the APIs/types needed to WRITE it do not exist. A test that compiles but panics at runtime (todo!() body, a regex the regex crate cannot compile) or fails at runtime (incomplete or incorrect impl behavior) is portable -- it is written in full and marked with a reason-less #[ignore]. About 120 test functions move from reason'd #[ignore] to reason-less #[ignore] (the ported-but-not-yet-passing signal). Impl crates gain only additive __ test hatches (init_command, pool, file_downloader, package handle link setters, artifact/path repository, repository manager, svn); no existing logic changes. Tests whose required APIs genuinely do not exist (mock/reflection harness, ApplicationTester, solve() discarding SolverProblemsException, a script::Event that cannot be passed as an originating event) keep their reason'd #[ignore]. cargo check -p shirabe --tests passes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/package')
-rw-r--r--crates/shirabe/src/package/handle.rs102
1 files changed, 102 insertions, 0 deletions
diff --git a/crates/shirabe/src/package/handle.rs b/crates/shirabe/src/package/handle.rs
index 5df4fc0..303983a 100644
--- a/crates/shirabe/src/package/handle.rs
+++ b/crates/shirabe/src/package/handle.rs
@@ -67,6 +67,17 @@ impl AnyPackage {
}
}
+ /// For testing only: reach the base `Package` of a real package variant.
+ /// Crate-private; the public `__set_*` test hatches are built on top of it.
+ pub(crate) fn as_package_mut(&mut self) -> Option<&mut Package> {
+ match self {
+ Self::Package(p) => Some(p),
+ Self::CompletePackage(p) => Some(&mut p.inner),
+ Self::RootPackage(p) => Some(&mut p.inner.inner),
+ _ => None,
+ }
+ }
+
pub fn as_root_package_interface(&self) -> Option<&dyn RootPackageInterface> {
match self {
Self::RootPackage(p) => Some(p),
@@ -1119,6 +1130,97 @@ macro_rules! impl_root_package_interface_handle {
};
}
+macro_rules! impl_real_package_test_setters {
+ ($Handle:ty) => {
+ impl $Handle {
+ /// For testing only: mirrors PHP `Package::setRequires`.
+ pub fn __set_requires(
+ &self,
+ requires: indexmap::IndexMap<String, crate::package::Link>,
+ ) {
+ self.0
+ .borrow_mut()
+ .as_package_mut()
+ .expect("real package handle invariant")
+ .set_requires(requires);
+ }
+
+ /// For testing only: mirrors PHP `Package::setDevRequires`.
+ pub fn __set_dev_requires(
+ &self,
+ dev_requires: indexmap::IndexMap<String, crate::package::Link>,
+ ) {
+ self.0
+ .borrow_mut()
+ .as_package_mut()
+ .expect("real package handle invariant")
+ .set_dev_requires(dev_requires);
+ }
+
+ /// For testing only: mirrors PHP `Package::setConflicts`.
+ pub fn __set_conflicts(
+ &self,
+ conflicts: indexmap::IndexMap<String, crate::package::Link>,
+ ) {
+ self.0
+ .borrow_mut()
+ .as_package_mut()
+ .expect("real package handle invariant")
+ .set_conflicts(conflicts);
+ }
+
+ /// For testing only: mirrors PHP `Package::setProvides`.
+ pub fn __set_provides(
+ &self,
+ provides: indexmap::IndexMap<String, crate::package::Link>,
+ ) {
+ self.0
+ .borrow_mut()
+ .as_package_mut()
+ .expect("real package handle invariant")
+ .set_provides(provides);
+ }
+
+ /// For testing only: mirrors PHP `Package::setReplaces`.
+ pub fn __set_replaces(
+ &self,
+ replaces: indexmap::IndexMap<String, crate::package::Link>,
+ ) {
+ self.0
+ .borrow_mut()
+ .as_package_mut()
+ .expect("real package handle invariant")
+ .set_replaces(replaces);
+ }
+
+ /// For testing only: mirrors PHP `Package::setExtra`.
+ pub fn __set_extra(
+ &self,
+ extra: indexmap::IndexMap<String, shirabe_php_shim::PhpMixed>,
+ ) {
+ self.0
+ .borrow_mut()
+ .as_package_mut()
+ .expect("real package handle invariant")
+ .set_extra(extra);
+ }
+
+ /// For testing only: mirrors PHP `Package::setType`.
+ pub fn __set_type(&self, r#type: String) {
+ self.0
+ .borrow_mut()
+ .as_package_mut()
+ .expect("real package handle invariant")
+ .set_type(r#type);
+ }
+ }
+ };
+}
+
+impl_real_package_test_setters!(PackageHandle);
+impl_real_package_test_setters!(CompletePackageHandle);
+impl_real_package_test_setters!(RootPackageHandle);
+
macro_rules! impl_handle_common {
($Handle:ty) => {
impl $Handle {