| 28 | } |
| 29 | |
| 30 | pub fn run_paths(&mut self, tests: &[std::path::PathBuf]) -> Result<()> { |
| 31 | let mut files = Vec::new(); |
| 32 | for path in tests { |
| 33 | if path.is_dir() { |
| 34 | for entry in std::fs::read_dir(path)? { |
| 35 | let entry = entry?; |
| 36 | let path = entry.path(); |
| 37 | if path.extension().is_some_and(|ext| ext == "wast") { |
| 38 | files.push(path); |
| 39 | } |
| 40 | } |
| 41 | } else { |
| 42 | files.push(path.clone()); |
| 43 | } |
| 44 | } |
| 45 | files.sort(); |
| 46 | |
| 47 | let runner_files = files |
| 48 | .iter() |
| 49 | .map(|path| { |
| 50 | let contents = std::fs::read_to_string(path)?; |
| 51 | let name = path.to_string_lossy().into_owned(); |
| 52 | Ok((name, contents)) |
| 53 | }) |
| 54 | .collect::<Result<Vec<_>>>()?; |
| 55 | |
| 56 | self.runner.run_files(runner_files.iter().map(|(name, contents)| RunnerTestFile { |
| 57 | name: name.clone(), |
| 58 | parent: name.clone(), |
| 59 | contents, |
| 60 | })) |
| 61 | } |
| 62 | |
| 63 | pub fn run_files<'a>(&mut self, tests: impl IntoIterator<Item = wasm_testsuite::data::TestFile<'a>>) -> Result<()> { |
| 64 | self.runner.run_files(tests.into_iter().map(|file| RunnerTestFile { |