(tests: &mut Vec<WastTest>, path: &Path, config: &FindConfig)
| 80 | } |
| 81 | |
| 82 | fn add_tests(tests: &mut Vec<WastTest>, path: &Path, config: &FindConfig) -> Result<()> { |
| 83 | for entry in path.read_dir().context("failed to read directory")? { |
| 84 | let entry = entry.context("failed to read directory entry")?; |
| 85 | let path = entry.path(); |
| 86 | if entry |
| 87 | .file_type() |
| 88 | .context("failed to get file type")? |
| 89 | .is_dir() |
| 90 | { |
| 91 | add_tests(tests, &path, config).context("failed to read sub-directory")?; |
| 92 | continue; |
| 93 | } |
| 94 | |
| 95 | if path.extension().and_then(|s| s.to_str()) != Some("wast") { |
| 96 | continue; |
| 97 | } |
| 98 | |
| 99 | // These tests use `*.wast` directives not yet supported by Wasmtime, so |
| 100 | // wait for a `wasm-tools` update to ungate these. |
| 101 | if path.ends_with("spec_testsuite/custom/custom_annot.wast") |
| 102 | || path.ends_with("spec_testsuite/custom/branch_hint.wast") |
| 103 | || path.ends_with("spec_testsuite/custom/name_annot.wast") |
| 104 | { |
| 105 | continue; |
| 106 | } |
| 107 | |
| 108 | let contents = |
| 109 | fs::read_to_string(&path).with_context(|| format!("failed to read test: {path:?}"))?; |
| 110 | let config = match config { |
| 111 | FindConfig::InTest => parse_test_config(&contents, ";;!") |
| 112 | .with_context(|| format!("failed to parse test configuration: {path:?}"))?, |
| 113 | FindConfig::Infer(f) => f(&path), |
| 114 | }; |
| 115 | tests.push(WastTest { |
| 116 | path, |
| 117 | contents, |
| 118 | config, |
| 119 | }) |
| 120 | } |
| 121 | Ok(()) |
| 122 | } |
| 123 | |
| 124 | fn spec_test_config(test: &Path) -> TestConfig { |
| 125 | let mut ret = TestConfig::default(); |
no test coverage detected