Skip to main content

test_generator/
processors.rs

1//! Here we define the processors usable for each test generator
2use crate::{Test, Testsuite, extract_name};
3use std::path::PathBuf;
4
5/// Given a Testsuite and a path, process the path in case is a wast
6/// file.
7pub fn wast_processor(_out: &mut Testsuite, p: PathBuf) -> Option<Test> {
8    let ext = p.extension()?;
9    // Only look at wast files.
10    if ext != "wast" {
11        return None;
12    }
13
14    // Ignore files starting with `.`, which could be editor temporary files
15    if p.file_stem()?.to_str()?.starts_with('.') {
16        return None;
17    }
18
19    let testname = extract_name(&p);
20
21    // The implementation of `run_wast` lives in /tests/spectest.rs
22    let body = format!("crate::run_wast(config, r#\"{}\"#)", p.display());
23
24    Some(Test {
25        name: testname,
26        body,
27    })
28}