| 82 | } |
| 83 | |
| 84 | pub fn run_paths(&mut self, tests: &[PathBuf]) -> Result<()> { |
| 85 | for path in expand_paths(tests)? { |
| 86 | let contents = |
| 87 | std::fs::read_to_string(&path).context(format!("failed to read file: {}", path.to_string_lossy()))?; |
| 88 | |
| 89 | let file = TestFile { |
| 90 | contents: &contents, |
| 91 | name: path.to_string_lossy().to_string(), |
| 92 | parent: canonicalize(&path)?.to_string_lossy().to_string(), |
| 93 | }; |
| 94 | |
| 95 | self.run_file(file)?; |
| 96 | } |
| 97 | |
| 98 | self.print_errors(); |
| 99 | if self.failed() { |
| 100 | anstream::println!("{self}"); |
| 101 | Err(eyre!("failed one or more tests")) |
| 102 | } else { |
| 103 | anstream::println!("{self}"); |
| 104 | Ok(()) |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | pub fn set_log_level(level: log::LevelFilter) { |
| 109 | let _ = pretty_env_logger::formatted_builder().filter_level(level).try_init(); |