Skip to content

Commit 2b2084d

Browse files
test: black box
1 parent 5aa8b16 commit 2b2084d

3 files changed

Lines changed: 42 additions & 25 deletions

File tree

‎Cargo.lock‎

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎crates/vm/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ unicode-normalization = "0.1"
3131
[dev-dependencies]
3232
divan = "0.1.21"
3333
trybuild = "1"
34+
test_each_file = "0.3"
Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)