Update to `libtest-mimic` 0.5.0
authorLukas Kalbertodt <lukas.kalbertodt@gmail.com>
Sat, 13 Aug 2022 14:14:23 +0000 (16:14 +0200)
committerLukas Kalbertodt <lukas.kalbertodt@gmail.com>
Sat, 13 Aug 2022 14:41:34 +0000 (16:41 +0200)
tests/inst/Cargo.toml
tests/inst/src/insttestmain.rs
tests/inst/src/test.rs

index e006dda1eefbc2fc9f3817da0d387ddc16f8db31..cc3f712af11cd52a812054228e6b11d2aeca0216 100644 (file)
@@ -21,7 +21,7 @@ sh-inline = "0.2.0"
 anyhow = "1.0"
 tempfile = "3.1.0"
 ostree-ext = { version = "0.7.0" }
-libtest-mimic = "0.3.0"
+libtest-mimic = "0.5.0"
 twoway = "0.2.1"
 hyper = { version = "0.14", features = ["runtime", "http1", "http2", "tcp", "server"] }
 hyper-staticfile = "0.6.0"
index 9d6d06b07ce040c7b74ecb4b18ce3235040d0037..e8a7acb960550f1baca8eeb4905c66d202a36726 100644 (file)
@@ -1,4 +1,5 @@
 use anyhow::{bail, Result};
+use libtest_mimic::Trial;
 use structopt::StructOpt;
 
 mod destructive;
@@ -49,26 +50,6 @@ enum NonDestructiveOpts {
     Args(Vec<String>),
 }
 
-fn libtest_from_test(t: &StaticTest) -> test::TestImpl {
-    libtest_mimic::Test {
-        name: t.0.into(),
-        kind: "".into(),
-        is_ignored: false,
-        is_bench: false,
-        data: t.1,
-    }
-}
-
-fn run_test(test: &test::TestImpl) -> libtest_mimic::Outcome {
-    if let Err(e) = (test.data)() {
-        libtest_mimic::Outcome::Failed {
-            msg: Some(e.to_string()),
-        }
-    } else {
-        libtest_mimic::Outcome::Passed
-    }
-}
-
 fn main() -> Result<()> {
     // Ensure we're always in tempdir so we can rely on it globally.
     // We use /var/tmp to ensure we have storage space in the destructive
@@ -100,8 +81,11 @@ fn main() -> Result<()> {
             // FIXME add method to parse subargs
             let NonDestructiveOpts::Args(iter) = subopt;
             let libtestargs = libtest_mimic::Arguments::from_iter(iter);
-            let tests: Vec<_> = TESTS.iter().map(libtest_from_test).collect();
-            libtest_mimic::run_tests(&libtestargs, tests, run_test).exit();
+            let tests: Vec<_> = TESTS
+                .iter()
+                .map(|(name, fun)| Trial::test(*name, move || fun().map_err(Into::into)))
+                .collect();
+            libtest_mimic::run(&libtestargs, tests).exit();
         }
         Opt::RunDestructive { name } => {
             if !std::path::Path::new(DESTRUCTIVE_TEST_STAMP).exists() {
index c18dbd2338c08e47b076a84ed722e4edb13a16af..bca85977b16429943374af7737a276368a244a67 100644 (file)
@@ -18,7 +18,6 @@ use hyper_staticfile::Static;
 use tokio::runtime::Runtime;
 
 pub(crate) type TestFn = fn() -> Result<()>;
-pub(crate) type TestImpl = libtest_mimic::Test<TestFn>;
 
 /// Run command and assert that its stderr contains pat
 pub(crate) fn cmd_fails_with<C: BorrowMut<Command>>(mut c: C, pat: &str) -> Result<()> {