Parse test configuration from the specified test, comments starting with `;;!`.
(wat: &str, comment: &'static str)
| 227 | /// Parse test configuration from the specified test, comments starting with |
| 228 | /// `;;!`. |
| 229 | pub fn parse_test_config<T>(wat: &str, comment: &'static str) -> Result<T> |
| 230 | where |
| 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)] |