@@ -153,35 +153,38 @@ fn files(root: &Path, output: &mut Vec<PathBuf>) {
153153 }
154154}
155155
156- #[ test]
157- fn existing_black_box_scripts_run_on_rust_vm ( ) {
156+ test_each_file:: test_each_path! {
157+ for [ "mira" ] in "./tests" as black_box => black_box
158+ }
159+
160+ fn black_box ( path : [ & Path ; 1 ] ) {
161+ let path = path[ 0 ] . to_owned ( ) ;
162+ let is_huge = path
163+ . file_name ( )
164+ . unwrap ( )
165+ . to_string_lossy ( )
166+ . contains ( "_huge." ) ;
158167 std:: thread:: Builder :: new ( )
159168 . name ( "mira-compat" . into ( ) )
160169 . stack_size ( 16 * 1024 * 1024 )
161- . spawn ( run_existing_black_box_scripts)
170+ . spawn ( move || {
171+ let context = context ( ) ;
172+ let options = RunOptions {
173+ timeout : if is_huge {
174+ Duration :: from_secs ( 120 )
175+ } else {
176+ Duration :: from_secs ( 10 )
177+ } ,
178+ ..RunOptions :: default ( )
179+ } ;
180+ let source = fs:: read_to_string ( & path) . unwrap ( ) ;
181+ let script =
182+ compile ( & source) . unwrap_or_else ( |error| panic ! ( "{}: {error:?}" , path. display( ) ) ) ;
183+ script
184+ . run_with ( & context, & options)
185+ . unwrap_or_else ( |error| panic ! ( "{}: {error:?}" , path. display( ) ) ) ;
186+ } )
162187 . unwrap ( )
163188 . join ( )
164189 . unwrap ( ) ;
165190}
166-
167- fn run_existing_black_box_scripts ( ) {
168- let root = Path :: new ( env ! ( "CARGO_MANIFEST_DIR" ) ) . join ( "../../tests" ) ;
169- let mut scripts = Vec :: new ( ) ;
170- files ( & root, & mut scripts) ;
171- scripts. sort ( ) ;
172- let context = context ( ) ;
173- let options = RunOptions {
174- timeout : Duration :: from_secs ( 60 ) ,
175- checkpoint_interval : 100 ,
176- max_call_depth : 256 ,
177- ..RunOptions :: default ( )
178- } ;
179- for path in scripts {
180- let source = fs:: read_to_string ( & path) . unwrap ( ) ;
181- let script =
182- compile ( & source) . unwrap_or_else ( |error| panic ! ( "{}: {error:?}" , path. display( ) ) ) ;
183- script
184- . run_with ( & context, & options)
185- . unwrap_or_else ( |error| panic ! ( "{}: {error:?}" , path. display( ) ) ) ;
186- }
187- }
0 commit comments