aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/console
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-09 05:59:40 +0900
committernsfisis <nsfisis@gmail.com>2026-08-09 05:59:40 +0900
commitf3d60c7836da0d50d59a22cfd6e4692e3dc75581 (patch)
treeeafdc0bdd8a05b11e5a511d7ab4bb48a5e42609e /crates/shirabe/src/console
parenta6fc2831562fa83b8f20a3b8285b87102c1775d8 (diff)
downloadphp-shirabe-f3d60c7836da0d50d59a22cfd6e4692e3dc75581.tar.gz
php-shirabe-f3d60c7836da0d50d59a22cfd6e4692e3dc75581.tar.zst
php-shirabe-f3d60c7836da0d50d59a22cfd6e4692e3dc75581.zip
test(console): cover the dev build warning branch
The deadline is a constant baked in at build time, so PHP's define() of COMPOSER_DEV_WARNING_TIME cannot make Application take that branch. Application now holds the deadline in a field that __set_dev_warning_time overrides, letting testDevWarning run instead of staying ignored. The define() shim, whose only caller was that test, goes away with it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/console')
-rw-r--r--crates/shirabe/src/console/application.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/crates/shirabe/src/console/application.rs b/crates/shirabe/src/console/application.rs
index 16a67b72..bf1f3575 100644
--- a/crates/shirabe/src/console/application.rs
+++ b/crates/shirabe/src/console/application.rs
@@ -131,6 +131,9 @@ pub struct Application {
disable_scripts_by_default: bool,
/// Store the initial working directory at startup time
initial_working_directory: Option<String>,
+ /// For testing only: see [__set_dev_warning_time](Application::__set_dev_warning_time) for
+ /// details.
+ dev_warning_time: Option<i64>,
/// Self-reference used to hand commands their owning application (PHP's `$command->setApplication($this)`).
/// Set by `new_shared`; the run flow threads the upgraded `Rc` so command callbacks never
/// re-borrow the application while it is already borrowed.
@@ -193,6 +196,7 @@ impl Application {
disable_plugins_by_default: false,
disable_scripts_by_default: false,
initial_working_directory,
+ dev_warning_time: composer::COMPOSER_DEV_WARNING_TIME,
me: std::rc::Weak::new(),
};
if defined("SIGINT") && SignalRegistry::is_supported() {
@@ -2281,7 +2285,8 @@ impl ApplicationHandle {
io.write_error("<warning>Composer is operating slower than normal because you have Xdebug enabled. See https://getcomposer.org/xdebug</warning>");
}
- if let Some(dev_warning_time) = composer::COMPOSER_DEV_WARNING_TIME
+ let dev_warning_time = application.borrow().dev_warning_time;
+ if let Some(dev_warning_time) = dev_warning_time
&& command_name.as_deref() != Some("self-update")
&& command_name.as_deref() != Some("selfupdate")
&& time() > dev_warning_time
@@ -2570,6 +2575,12 @@ impl ApplicationHandle {
self.0.borrow_mut().set_catch_exceptions(boolean);
}
+ /// For testing only: simulating dynamically define COMPOSER_DEV_WARNING_TIME constant via
+ /// `define()` in PHP.
+ pub fn __set_dev_warning_time(&self, dev_warning_time: Option<i64>) {
+ self.0.borrow_mut().dev_warning_time = dev_warning_time;
+ }
+
/// For testing only: exposes the application as a Symfony base-application handle, the way
/// console commands receive it via `getApplication()`, so tests can build an
/// `ApplicationDescription` over it.