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

Function parse_test_config

crates/test-util/src/wast.rs:229–243  ·  view source on GitHub ↗

Parse test configuration from the specified test, comments starting with `;;!`.

(wat: &str, comment: &'static str)

Source from the content-addressed store, hash-verified

227/// Parse test configuration from the specified test, comments starting with
228/// `;;!`.
229pub fn parse_test_config<T>(wat: &str, comment: &'static str) -> Result<T>
230where
231 T: DeserializeOwned,
232{
233 // The test config source is the leading lines of the WAT file that are
234 // prefixed with `;;!`.
235 let config_lines: Vec<_> = wat
236 .lines()
237 .take_while(|l| l.starts_with(comment))
238 .map(|l| &l[comment.len()..])
239 .collect();
240 let config_text = config_lines.join("\n");
241
242 toml::from_str(&config_text).context("failed to parse the test configuration")
243}
244
245/// A `*.wast` test with its path, contents, and configuration.
246#[derive(Clone)]

Callers 2

newMethod · 0.85
add_testsFunction · 0.85

Calls 5

collectMethod · 0.80
mapMethod · 0.45
lenMethod · 0.45
joinMethod · 0.45
contextMethod · 0.45

Tested by

no test coverage detected