diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-02 08:55:56 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-02 08:55:56 +0900 |
| commit | 2c3373a7466c31f5cce7c2867c00a91afaa8e128 (patch) | |
| tree | 754c7da92def5d14fc425230f9db41c654897b4f /crates/shirabe/tests/io | |
| parent | 92f5c977b42d1322f3cebb260024179e1285b9d0 (diff) | |
| download | php-shirabe-2c3373a7466c31f5cce7c2867c00a91afaa8e128.tar.gz php-shirabe-2c3373a7466c31f5cce7c2867c00a91afaa8e128.tar.zst php-shirabe-2c3373a7466c31f5cce7c2867c00a91afaa8e128.zip | |
fix(io): propagate ask/select errors instead of panicking
IOInterface::ask/select now return anyhow::Result<PhpMixed>, and
ConsoleIO::ask_question forwards QuestionHelper errors (validator
failures, MissingInputException) instead of collapsing them with
.expect(). In PHP these exceptions propagate from QuestionHelper
through ConsoleIO to the caller, so callers such as UpdateCommand's
interactive package selection must be able to observe them; the
MissingInputException is wrapped with its concrete type preserved so
Application's ExceptionInterface downcast keeps working. All call
sites now propagate with `?` (Perforce::query_p4_user becomes
Result-returning: PHP declares it void but exceptions still escape),
and the previously ignored
test_interactive_mode_throws_if_no_package_entered passes.
ask_confirmation/ask_and_hide_answer still collapse errors; extending
propagation to them is left as TODO(phase-c) pending a decision.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests/io')
| -rw-r--r-- | crates/shirabe/tests/io/buffer_io_test.rs | 10 | ||||
| -rw-r--r-- | crates/shirabe/tests/io/console_io_test.rs | 6 | ||||
| -rw-r--r-- | crates/shirabe/tests/io/null_io_test.rs | 2 |
3 files changed, 12 insertions, 6 deletions
diff --git a/crates/shirabe/tests/io/buffer_io_test.rs b/crates/shirabe/tests/io/buffer_io_test.rs index 5bb18014..c33fd804 100644 --- a/crates/shirabe/tests/io/buffer_io_test.rs +++ b/crates/shirabe/tests/io/buffer_io_test.rs @@ -19,9 +19,11 @@ fn test_set_user_inputs() { assert!(!buffer_io.ask_confirmation("Now please say no!".to_string(), true)); assert_eq!( PhpMixed::String("default".to_string()), - buffer_io.ask( - "Empty string last".to_string(), - PhpMixed::String("default".to_string()) - ) + buffer_io + .ask( + "Empty string last".to_string(), + PhpMixed::String("default".to_string()) + ) + .unwrap() ); } diff --git a/crates/shirabe/tests/io/console_io_test.rs b/crates/shirabe/tests/io/console_io_test.rs index 03307e51..15e7100b 100644 --- a/crates/shirabe/tests/io/console_io_test.rs +++ b/crates/shirabe/tests/io/console_io_test.rs @@ -196,7 +196,9 @@ fn test_ask() { // PHP asserts QuestionHelper::ask receives a Question. Behaviorally, an interactive input whose // stream yields the answer makes ConsoleIO::ask return that answer. let (console_io, _output) = make_console_io_with_answer("answer\n"); - let result = console_io.ask("Why?".to_string(), PhpMixed::String("default".to_string())); + let result = console_io + .ask("Why?".to_string(), PhpMixed::String("default".to_string())) + .unwrap(); assert_eq!(PhpMixed::String("answer".to_string()), result); } @@ -247,7 +249,7 @@ fn test_select() { ); assert_eq!( PhpMixed::List(vec![PhpMixed::String("1".to_string())]), - result + result.unwrap() ); } diff --git a/crates/shirabe/tests/io/null_io_test.rs b/crates/shirabe/tests/io/null_io_test.rs index 1627e91f..ced598b9 100644 --- a/crates/shirabe/tests/io/null_io_test.rs +++ b/crates/shirabe/tests/io/null_io_test.rs @@ -45,6 +45,7 @@ fn test_ask() { assert_eq!( PhpMixed::String("foo".to_string()), io.ask("bar".to_string(), PhpMixed::String("foo".to_string())) + .unwrap() ); } @@ -88,5 +89,6 @@ fn test_select() { "foo".to_string(), true ) + .unwrap() ); } |
