From ec1bfeefb3de9b106e4433baf33096f355ed52e3 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Wed, 6 Jan 2021 13:49:44 -0800 Subject: [PATCH] fix tests --- crates/wiggle/tests/errors.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/crates/wiggle/tests/errors.rs b/crates/wiggle/tests/errors.rs index a550da35bd..4252962469 100644 --- a/crates/wiggle/tests/errors.rs +++ b/crates/wiggle/tests/errors.rs @@ -34,7 +34,7 @@ mod convert_just_errno { /// When the `errors` mapping in witx is non-empty, we need to impl the /// types::UserErrorConversion trait that wiggle generates from that mapping. impl<'a> types::UserErrorConversion for WasiCtx<'a> { - fn errno_from_rich_error(&self, e: RichError) -> Result { + fn errno_from_rich_error(&self, e: RichError) -> Result { // WasiCtx can collect a Vec log so we can test this. We're // logging the Display impl that `thiserror::Error` provides us. self.log.borrow_mut().push(e.to_string()); @@ -115,8 +115,9 @@ mod convert_multiple_error_types { TooMuchCoffee(usize), } - // Just like the other error, except that we have a second errno type: - // trivial function. + // Just like the prior test, except that we have a second errno type. This should mean there + // are two functions in UserErrorConversion. + // Additionally, test that the function "baz" marked noreturn always returns a wiggle::Trap. wiggle::from_witx!({ witx_literal: " (typename $errno (enum u8 $ok $invalid_arg $picket_line)) @@ -127,7 +128,10 @@ mod convert_multiple_error_types { (result $err $errno)) (@interface func (export \"bar\") (param $drink u32) - (result $err $errno2))) + (result $err $errno2)) + (@interface func (export \"baz\") + (param $drink u32) + (@witx noreturn))) ", ctx: WasiCtx, errors: { errno => RichError, errno2 => AnotherRichError }, @@ -159,13 +163,13 @@ mod convert_multiple_error_types { // each member of the `errors` mapping. // Bodies elided. impl<'a> types::UserErrorConversion for WasiCtx<'a> { - fn errno_from_rich_error(&self, _e: RichError) -> Result { + fn errno_from_rich_error(&self, _e: RichError) -> Result { unimplemented!() } fn errno2_from_another_rich_error( &self, _e: AnotherRichError, - ) -> Result { + ) -> Result { unimplemented!() } } @@ -178,5 +182,8 @@ mod convert_multiple_error_types { fn bar(&self, _: u32) -> Result<(), AnotherRichError> { unimplemented!() } + fn baz(&self, _: u32) -> wiggle::Trap { + unimplemented!() + } } }