mirror of
https://github.com/ostreedev/ostree.git
synced 2025-03-16 10:50:43 +03:00
Merge pull request #2688 from LukasKalbertodt/main
Update to `libtest-mimic` 0.5.0
This commit is contained in:
commit
4471c252a9
@ -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"
|
||||
|
@ -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() {
|
||||
|
@ -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<()> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user