-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Support Dafny tests on test models for Rust #460
Merged
Merged
Changes from 50 commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
2ffb98d
Progress
robin-aws 0710246
Progress
robin-aws 323a1e5
Update package layout, most of the wrapped client impl
robin-aws 644af7c
Successfully run and panicking!
robin-aws 3f28cf7
tests passing
robin-aws e3ce7ea
Makefile updates
robin-aws ff1fcd6
Better tests file layout
robin-aws aa7f02e
Don’t let polymorph delete implementation_from_dafny.rs
robin-aws 0d1f49a
Formatting
robin-aws 3fccf32
Update commit
robin-aws 6de828d
update copy of runtime
robin-aws 9aec1d1
Don’t patch stdlib implementation_from_dafny.rs any more
robin-aws 8911f81
Stop patching implementation_from_dafny.rs
robin-aws ac34eff
Fix SimpleBoolean
robin-aws 9a99345
Much simpler Boolean fix
robin-aws 3b7da6c
Add UpcastObject<Any> for Unhandled
robin-aws 59aaed2
Replace most uses of UpcastTo
robin-aws 3449728
Fix the rest
robin-aws af7138d
Don’t check in implementation_from_dafny.rs any more
robin-aws 40b4d93
Missing sealed_unhandled.rs change
robin-aws bcbbbdc
Ignore implementation_from_dafny.rs
robin-aws 636b83b
Tweak ignore
robin-aws 1740711
UpcastObject impl for SimpleResourceWrapper
robin-aws 1521617
Update patch files
robin-aws c902dcd
Formatting
robin-aws ec0e074
Merge branch 'robin-aws/use-tip-of-dafny-feat-rust' of github.com:smi…
robin-aws 92649e1
Don’t check in implementation_from_dafny.rs any more
robin-aws 63f9c3b
Mostly fix things up post-merge
robin-aws a3eee3f
Fix file layout
robin-aws 536f73a
Merge branch 'main-1.x' of github.com:smithy-lang/smithy-dafny into r…
robin-aws b8ab362
update patch file
robin-aws 42ab115
Add tests_from_dafny.rs so we can patch
robin-aws d880bde
Remove wrong file
robin-aws a8f1580
Patch test files as well for now
robin-aws fc033db
Undo dafny_impl change
robin-aws c4d3b28
Update patch
robin-aws 1833dbb
Makefile fixes
robin-aws 7c490e1
update patch
robin-aws 08c8af8
Formatting
robin-aws dbf1849
Fix StandardLibrary
robin-aws 9d7f307
remove tokio
robin-aws dc638a4
update patch
robin-aws 7f0fde8
Unused import
robin-aws 6e6635b
stdlib Makefile fix
robin-aws 44bd953
Makefile comment
robin-aws ad467d0
Fix issue with stdlib patch not applying
robin-aws a815731
Partial change to put async back
robin-aws 5ef3220
Working but messy as hell
robin-aws 222c264
Update patch file
robin-aws 7c06d32
Moved wrapped client into src, guarded by wrapped-client feature
robin-aws 5a1e67d
Cleanup
robin-aws e729474
Update patch file
robin-aws af0663b
Clean up wrapped client code
robin-aws 6bccce8
update patch files
robin-aws 69ba357
Fix patch
robin-aws File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
...mpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod client; |
118 changes: 118 additions & 0 deletions
118
TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped/client.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
use tokio::runtime::Runtime; | ||
|
||
pub struct Client { | ||
wrapped: crate::client::Client, | ||
|
||
/// A `current_thread` runtime for executing operations on the | ||
/// asynchronous client in a blocking manner. | ||
rt: Runtime | ||
} | ||
|
||
impl dafny_runtime::UpcastObject<dyn std::any::Any> for Client { | ||
::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); | ||
} | ||
|
||
impl Client { | ||
pub fn from_conf(config: &::std::rc::Rc< | ||
::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, | ||
>) -> ::std::rc::Rc<::simple_boolean_dafny::r#_Wrappers_Compile::Result< | ||
::dafny_runtime::Object<dyn ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient>, | ||
::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error> | ||
>> { | ||
let rt_result = tokio::runtime::Builder::new_current_thread() | ||
.enable_all() | ||
.build(); | ||
if rt_result.is_err() { | ||
return ::std::rc::Rc::new(to_opaque_error_result(rt_result.err().unwrap())); | ||
} | ||
let rt = rt_result.unwrap(); | ||
let result = crate::client::Client::from_conf( | ||
crate::conversions::simple_boolean_config::_simple_boolean_config::from_dafny( | ||
config.clone(), | ||
), | ||
); | ||
match result { | ||
Err(error) => { | ||
let error_obj: ::dafny_runtime::Object<dyn::std::any::Any> = | ||
::dafny_runtime::Object(Some(::std::rc::Rc::new( | ||
::std::cell::UnsafeCell::new(error), | ||
))); | ||
::std::rc::Rc::new( | ||
::simple_boolean_dafny::_Wrappers_Compile::Result::Failure { | ||
error: ::std::rc::Rc::new( | ||
::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { | ||
obj: error_obj, | ||
}, | ||
), | ||
}, | ||
) | ||
} | ||
Ok(client) => { | ||
let wrap = crate::wrapped::client::Client { | ||
wrapped: client.clone(), | ||
rt | ||
}; | ||
let inner: ::std::rc::Rc<::std::cell::UnsafeCell<dyn ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient>> | ||
= ::std::rc::Rc::new(::std::cell::UnsafeCell::new(wrap)); | ||
|
||
::std::rc::Rc::new( | ||
::simple_boolean_dafny::_Wrappers_Compile::Result::Success { | ||
value: ::dafny_runtime::Object(Some(inner)), | ||
}, | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
fn to_opaque_error_result(error: std::io::Error) -> ::simple_boolean_dafny::r#_Wrappers_Compile::Result< | ||
::dafny_runtime::Object<dyn ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient>, | ||
::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error> | ||
> { | ||
let error_obj: ::dafny_runtime::Object<dyn::std::any::Any> = | ||
::dafny_runtime::Object(Some(::std::rc::Rc::new( | ||
::std::cell::UnsafeCell::new(error), | ||
))); | ||
simple_boolean_dafny::_Wrappers_Compile::Result::Failure { | ||
error: ::std::rc::Rc::new( | ||
::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { | ||
obj: error_obj, | ||
}, | ||
), | ||
} | ||
} | ||
|
||
impl ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient | ||
for Client | ||
{ | ||
fn GetBoolean( | ||
&mut self, | ||
input: &std::rc::Rc< | ||
::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, | ||
>, | ||
) -> std::rc::Rc< | ||
::simple_boolean_dafny::r#_Wrappers_Compile::Result< | ||
std::rc::Rc< | ||
::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, | ||
>, | ||
std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error>, | ||
>, | ||
>{ | ||
let inner_input = | ||
crate::conversions::get_boolean::_get_boolean_input::from_dafny(input.clone()); | ||
let result = self.rt.block_on(crate::operation::get_boolean::GetBoolean::send(&self.wrapped, inner_input)); | ||
match result { | ||
Err(error) => ::std::rc::Rc::new( | ||
::simple_boolean_dafny::_Wrappers_Compile::Result::Failure { | ||
error: crate::conversions::get_boolean::to_dafny_error(error), | ||
}, | ||
), | ||
Ok(client) => ::std::rc::Rc::new( | ||
::simple_boolean_dafny::_Wrappers_Compile::Result::Success { | ||
value: crate::conversions::get_boolean::_get_boolean_output::to_dafny(client), | ||
}, | ||
), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use crate::tests_from_dafny::*; | ||
|
||
impl r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default { | ||
pub fn WrappedSimpleBoolean(config: &::std::rc::Rc< | ||
::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, | ||
>) -> ::std::rc::Rc<::simple_boolean_dafny::r#_Wrappers_Compile::Result< | ||
::dafny_runtime::Object<dyn ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient>, | ||
::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error> | ||
>>{ | ||
crate::wrapped::client::Client::from_conf(config) | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error handling code in here is all over the map, please help me use some cleaner idioms :) I can't use
?
in general sincer#_Wrappers_Compile::Result
is not a RustResult
, but perhaps we can useResult.map_err
somehow?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did the best I could with this. :)