Skip to content

Commit

Permalink
use dyntest for tests/tests.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
tjjfvi committed May 28, 2024
1 parent d0261e0 commit 7b9e5a0
Show file tree
Hide file tree
Showing 76 changed files with 60 additions and 260 deletions.
212 changes: 8 additions & 204 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ hvm64-host = { path = "./host" }

[dev-dependencies]
insta = { version = "1.34.0", features = ["glob"] }
serial_test = "3.0.0"
dyntest = { path = "../dyntest" }

[features]
default = ["std"]
Expand All @@ -53,3 +53,7 @@ trace = ["hvm64-runtime/trace"]

[patch.crates-io]
highlight_error = { git = "https://github.com/tjjfvi/rust_highlight_error/", branch = "no_std" }

[[test]]
name = "tests"
harness = false
25 changes: 25 additions & 0 deletions tests/foo.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use dyntest::{dyntest, DynTester};
use std::fs;

dyntest!(test_examples, test_foo);

fn test_examples(t: &mut DynTester) {
for (name, path) in t.glob("{examples,tests/programs}/**/*.hvm") {
t.test(name, move || {
assert!(!fs::read_to_string(path).unwrap().is_empty());
});
}
}

fn test_foo(t: &mut DynTester) {
for file in ["a", "b", "c"] {
t.test(file, || test_file(file));
}
for file in ["abc", "xyz"] {
t.test(file, || test_file(file)).should_panic(true);
}
}

fn test_file(file: &str) {
assert_eq!(file.len(), 1);
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 7b9e5a0

Please sign in to comment.