diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-19 23:00:38 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-19 23:00:38 +0900 |
| commit | adfa7c6b295521a6f8fdf4084993a80a8030e49b (patch) | |
| tree | 36d2bc1f717286d129bc7f15fba2d06e6887ad5f /crates/shirabe/src/console | |
| parent | fd733a87364b877d5e66b4973bd61b5379ec4d61 (diff) | |
| download | php-shirabe-adfa7c6b295521a6f8fdf4084993a80a8030e49b.tar.gz php-shirabe-adfa7c6b295521a6f8fdf4084993a80a8030e49b.tar.zst php-shirabe-adfa7c6b295521a6f8fdf4084993a80a8030e49b.zip | |
test(command): add basic smoke tests
Diffstat (limited to 'crates/shirabe/src/console')
| -rw-r--r-- | crates/shirabe/src/console/application.rs | 45 |
1 files changed, 14 insertions, 31 deletions
diff --git a/crates/shirabe/src/console/application.rs b/crates/shirabe/src/console/application.rs index 591114a..82aa03d 100644 --- a/crates/shirabe/src/console/application.rs +++ b/crates/shirabe/src/console/application.rs @@ -127,7 +127,6 @@ pub struct Application { version: String, command_loader: Option<Box<dyn CommandLoaderInterface>>, catch_exceptions: bool, - auto_exit: bool, definition: Option<std::rc::Rc<std::cell::RefCell<InputDefinition>>>, helper_set: Option<std::rc::Rc<std::cell::RefCell<HelperSet>>>, terminal: Terminal, @@ -201,7 +200,6 @@ impl Application { version, command_loader: None, catch_exceptions: true, - auto_exit: true, definition: None, helper_set: None, terminal: Terminal::new(), @@ -318,7 +316,7 @@ impl Application { application: &std::rc::Rc<std::cell::RefCell<Application>>, input: Option<std::rc::Rc<std::cell::RefCell<dyn InputInterface>>>, output: Option<std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>>, - ) -> anyhow::Result<i64> { + ) -> anyhow::Result<i32> { let output = match output { Some(output) => Some(output), None => Some( @@ -334,7 +332,7 @@ impl Application { application: &std::rc::Rc<std::cell::RefCell<Application>>, input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, - ) -> anyhow::Result<i64> { + ) -> anyhow::Result<i32> { application.borrow_mut().disable_plugins_by_default = input .borrow() .has_parameter_option(PhpMixed::from(vec!["--no-plugins"]), false); @@ -907,7 +905,7 @@ impl Application { } let mut start_time: Option<f64> = None; - let result_outcome: anyhow::Result<i64> = (|| -> anyhow::Result<i64> { + let result_outcome: anyhow::Result<i32> = (|| -> anyhow::Result<i32> { if input .borrow() .has_parameter_option(PhpMixed::from(vec!["--profile"]), false) @@ -921,7 +919,7 @@ impl Application { let _ = start_time.unwrap(); } - let result: i64 = Application::base_do_run(application, input.clone(), output.clone())?; + let result = Application::base_do_run(application, input.clone(), output.clone())?; if input .borrow() @@ -975,7 +973,7 @@ impl Application { ); } - Ok(see.get_code()) + Ok(see.get_code() as i32) } else { let mut ghe = GithubActionError::new(io.clone()); ghe.emit(&e.to_string(), None, None); @@ -1443,7 +1441,7 @@ impl Application { application: &std::rc::Rc<std::cell::RefCell<Application>>, input: Option<std::rc::Rc<std::cell::RefCell<dyn InputInterface>>>, output: Option<std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>>, - ) -> anyhow::Result<i64> { + ) -> anyhow::Result<i32> { if shirabe_php_shim::function_exists("putenv") { let (height, width) = { let app = application.borrow(); @@ -1479,7 +1477,7 @@ impl Application { this.render_throwable(e, output.clone()); }; - let result = (|| -> anyhow::Result<i64> { + let result = (|| -> anyhow::Result<i32> { application.borrow_mut().configure_io(&input, &output)?; let exit_code = Application::do_run(application, input.clone(), output.clone())?; @@ -1487,7 +1485,7 @@ impl Application { Ok(exit_code) })(); - let mut exit_code = match result { + let exit_code = match result { Ok(exit_code) => exit_code, Err(e) => { if !application.borrow().catch_exceptions { @@ -1512,14 +1510,6 @@ impl Application { // finally: handler restore. See TODO above; no-op here. - if application.borrow().auto_exit { - if exit_code > 255 { - exit_code = 255; - } - - shirabe_php_shim::exit(exit_code); - } - Ok(exit_code) } @@ -1528,7 +1518,7 @@ impl Application { application: &std::rc::Rc<std::cell::RefCell<Application>>, input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, - ) -> anyhow::Result<i64> { + ) -> anyhow::Result<i32> { if input.borrow().has_parameter_option( PhpMixed::from(vec