MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / add_tests

Function add_tests

crates/test-util/src/wast.rs:82–122  ·  view source on GitHub ↗
(tests: &mut Vec<WastTest>, path: &Path, config: &FindConfig)

Source from the content-addressed store, hash-verified

80}
81
82fn 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
124fn spec_test_config(test: &Path) -> TestConfig {
125 let mut ret = TestConfig::default();

Callers 1

find_testsFunction · 0.85

Calls 10

read_to_stringFunction · 0.85
parse_test_configFunction · 0.85
OkFunction · 0.85
is_dirMethod · 0.80
to_strMethod · 0.80
with_contextMethod · 0.80
fFunction · 0.50
contextMethod · 0.45
pathMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected