Add ignorabletest test harness.
This is a custom test harness which allows tests to be ignored at
runtime based on arbitrary conditions.
Bug: 260692911
Test: Ran apkdmverity and devicemapper tests with this harness
Change-Id: Ibafef988b8114ac54db569435bd854ea5b78ed2b
diff --git a/libs/ignorabletest/src/runner.rs b/libs/ignorabletest/src/runner.rs
new file mode 100644
index 0000000..e1b14e0
--- /dev/null
+++ b/libs/ignorabletest/src/runner.rs
@@ -0,0 +1,20 @@
+//! Test runner.
+
+use core::ops::{Deref, FnOnce};
+use libtest_mimic::{Arguments, Failed, Trial};
+use std::env;
+
+/// Command-line arguments to ignore, because they are not supported by libtest-mimic.
+const IGNORED_ARGS: [&str; 2] = ["-Zunstable-options", "--report-time"];
+
+/// Runs all tests.
+pub fn main(tests: Vec<Trial>) {
+ let args = Arguments::from_iter(env::args().filter(|arg| !IGNORED_ARGS.contains(&arg.deref())));
+ libtest_mimic::run(&args, tests).exit();
+}
+
+/// Runs the given test.
+pub fn run(test: impl FnOnce()) -> Result<(), Failed> {
+ test();
+ Ok(())
+}