From 02b162347c63b4caf45cc64bade3780b506f262b Mon Sep 17 00:00:00 2001 From: Lukas Kalbertodt Date: Sat, 13 Aug 2022 16:14:23 +0200 Subject: [PATCH] Update to `libtest-mimic` 0.5.0 --- tests/inst/Cargo.toml | 2 +- tests/inst/src/insttestmain.rs | 28 ++++++---------------------- tests/inst/src/test.rs | 1 - 3 files changed, 7 insertions(+), 24 deletions(-) diff --git a/tests/inst/Cargo.toml b/tests/inst/Cargo.toml index e006dda1..cc3f712a 100644 --- a/tests/inst/Cargo.toml +++ b/tests/inst/Cargo.toml @@ -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" diff --git a/tests/inst/src/insttestmain.rs b/tests/inst/src/insttestmain.rs index 9d6d06b0..e8a7acb9 100644 --- a/tests/inst/src/insttestmain.rs +++ b/tests/inst/src/insttestmain.rs @@ -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), } -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() { diff --git a/tests/inst/src/test.rs b/tests/inst/src/test.rs index c18dbd23..bca85977 100644 --- a/tests/inst/src/test.rs +++ b/tests/inst/src/test.rs @@ -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; /// Run command and assert that its stderr contains pat pub(crate) fn cmd_fails_with>(mut c: C, pat: &str) -> Result<()> {