File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -406,6 +406,29 @@ pub fn assert_impl(
406406 id : String ,
407407 details : & Value ,
408408) {
409+ // Spot artificer
410+ let spot_artifact = || -> Option < Value > {
411+ if hit && !condition {
412+ let mut details = details. as_object ( ) ?. clone ( ) ;
413+ let artifact_path = details. get ( "artifact_path" ) ?. as_str ( ) ?;
414+ let artifact_dir = std:: env:: var ( crate :: internal:: ARTIFICER_DIR ) . ok ( ) ?;
415+ let nonce = format ! ( "{:016x}" , crate :: random:: get_random( ) ) ;
416+ let mut artificer = std:: fs:: OpenOptions :: new ( )
417+ . write ( true )
418+ . append ( true )
419+ . create ( true )
420+ . open ( std:: path:: Path :: new ( & artifact_dir) . join ( & nonce) ) . ok ( ) ?;
421+ use std:: io:: Write ;
422+ writeln ! ( artificer, "{artifact_path}" ) . ok ( ) ?;
423+ details. insert ( "artifact_id" . to_owned ( ) , Value :: String ( nonce) ) ;
424+ Some ( Value :: Object ( details) )
425+ } else {
426+ None
427+ }
428+ } ;
429+ let new_details = spot_artifact ( ) ;
430+ let details = new_details. as_ref ( ) . unwrap_or ( details) ;
431+
409432 let assertion = AssertionInfo :: new (
410433 assert_type,
411434 display_type,
Original file line number Diff line number Diff line change @@ -51,6 +51,8 @@ const SDK_VERSION: &str = env!("CARGO_PKG_VERSION");
5151
5252pub const LOCAL_OUTPUT : & str = "ANTITHESIS_SDK_LOCAL_OUTPUT" ;
5353
54+ pub const ARTIFICER_DIR : & str = "ANTITHESIS_ARTIFICER_DIR" ;
55+
5456#[ cfg( feature = "full" ) ]
5557fn get_handler ( ) -> Box < dyn LibHandler + Sync + Send > {
5658 match VoidstarHandler :: try_load ( ) {
You can’t perform that action at this time.
0 commit comments