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"
|
anyhow = "1.0"
|
||||||
tempfile = "3.1.0"
|
tempfile = "3.1.0"
|
||||||
ostree-ext = { version = "0.7.0" }
|
ostree-ext = { version = "0.7.0" }
|
||||||
libtest-mimic = "0.3.0"
|
libtest-mimic = "0.5.0"
|
||||||
twoway = "0.2.1"
|
twoway = "0.2.1"
|
||||||
hyper = { version = "0.14", features = ["runtime", "http1", "http2", "tcp", "server"] }
|
hyper = { version = "0.14", features = ["runtime", "http1", "http2", "tcp", "server"] }
|
||||||
hyper-staticfile = "0.6.0"
|
hyper-staticfile = "0.6.0"
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
use anyhow::{bail, Result};
|
use anyhow::{bail, Result};
|
||||||
|
use libtest_mimic::Trial;
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
|
||||||
mod destructive;
|
mod destructive;
|
||||||
|
|
@ -49,26 +50,6 @@ enum NonDestructiveOpts {
|
||||||
Args(Vec<String>),
|
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<()> {
|
fn main() -> Result<()> {
|
||||||
// Ensure we're always in tempdir so we can rely on it globally.
|
// 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
|
// 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
|
// FIXME add method to parse subargs
|
||||||
let NonDestructiveOpts::Args(iter) = subopt;
|
let NonDestructiveOpts::Args(iter) = subopt;
|
||||||
let libtestargs = libtest_mimic::Arguments::from_iter(iter);
|
let libtestargs = libtest_mimic::Arguments::from_iter(iter);
|
||||||
let tests: Vec<_> = TESTS.iter().map(libtest_from_test).collect();
|
let tests: Vec<_> = TESTS
|
||||||
libtest_mimic::run_tests(&libtestargs, tests, run_test).exit();
|
.iter()
|
||||||
|
.map(|(name, fun)| Trial::test(*name, move || fun().map_err(Into::into)))
|
||||||
|
.collect();
|
||||||
|
libtest_mimic::run(&libtestargs, tests).exit();
|
||||||
}
|
}
|
||||||
Opt::RunDestructive { name } => {
|
Opt::RunDestructive { name } => {
|
||||||
if !std::path::Path::new(DESTRUCTIVE_TEST_STAMP).exists() {
|
if !std::path::Path::new(DESTRUCTIVE_TEST_STAMP).exists() {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ use hyper_staticfile::Static;
|
||||||
use tokio::runtime::Runtime;
|
use tokio::runtime::Runtime;
|
||||||
|
|
||||||
pub(crate) type TestFn = fn() -> Result<()>;
|
pub(crate) type TestFn = fn() -> Result<()>;
|
||||||
pub(crate) type TestImpl = libtest_mimic::Test<TestFn>;
|
|
||||||
|
|
||||||
/// Run command and assert that its stderr contains pat
|
/// Run command and assert that its stderr contains pat
|
||||||
pub(crate) fn cmd_fails_with<C: BorrowMut<Command>>(mut c: C, pat: &str) -> Result<()> {
|
pub(crate) fn cmd_fails_with<C: BorrowMut<Command>>(mut c: C, pat: &str) -> Result<()> {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue