Andrew Walbran | 13d5ebc | 2022-11-29 18:20:08 +0000 | [diff] [blame^] | 1 | //! Test runner. |
| 2 | |
| 3 | use core::ops::{Deref, FnOnce}; |
| 4 | use libtest_mimic::{Arguments, Failed, Trial}; |
| 5 | use std::env; |
| 6 | |
| 7 | /// Command-line arguments to ignore, because they are not supported by libtest-mimic. |
| 8 | const IGNORED_ARGS: [&str; 2] = ["-Zunstable-options", "--report-time"]; |
| 9 | |
| 10 | /// Runs all tests. |
| 11 | pub fn main(tests: Vec<Trial>) { |
| 12 | let args = Arguments::from_iter(env::args().filter(|arg| !IGNORED_ARGS.contains(&arg.deref()))); |
| 13 | libtest_mimic::run(&args, tests).exit(); |
| 14 | } |
| 15 | |
| 16 | /// Runs the given test. |
| 17 | pub fn run(test: impl FnOnce()) -> Result<(), Failed> { |
| 18 | test(); |
| 19 | Ok(()) |
| 20 | } |