Sha256: 1b754139bb45d23a114450d918287dd8ce6d5f942a8c0d0d8472213685da7c0a

Contents?: true

Size: 1.21 KB

Versions: 7

Compression:

Stored size: 1.21 KB

Contents

use std::fmt::Write;

fn main() {
    println!("cargo:rerun-if-changed=build.rs");
    println!("cargo:rerun-if-changed=isle_examples");

    let out_dir = std::path::PathBuf::from(
        std::env::var_os("OUT_DIR").expect("The OUT_DIR environment variable must be set"),
    );

    let mut out = String::new();

    emit_tests(&mut out, "isle_examples/pass", "run_pass");
    emit_tests(&mut out, "isle_examples/fail", "run_fail");
    emit_tests(&mut out, "isle_examples/link", "run_link");
    emit_tests(&mut out, "isle_examples/run", "run_run");

    let output = out_dir.join("isle_tests.rs");
    std::fs::write(output, out).unwrap();
}

fn emit_tests(out: &mut String, dir_name: &str, runner_func: &str) {
    for test_file in std::fs::read_dir(dir_name).unwrap() {
        let test_file = test_file.unwrap().file_name().into_string().unwrap();
        if !test_file.ends_with(".isle") {
            continue;
        }
        let test_file_base = test_file.replace(".isle", "");

        writeln!(out, "#[test]").unwrap();
        writeln!(out, "fn test_{runner_func}_{test_file_base}() {{").unwrap();
        writeln!(out, "    {runner_func}(\"{dir_name}/{test_file}\");").unwrap();
        writeln!(out, "}}").unwrap();
    }
}

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/cranelift-isle-0.116.0/build.rs
wasmtime-28.0.0 ./ext/cargo-vendor/cranelift-isle-0.115.0/build.rs
wasmtime-27.0.0 ./ext/cargo-vendor/cranelift-isle-0.114.0/build.rs
wasmtime-26.0.0 ./ext/cargo-vendor/cranelift-isle-0.113.0/build.rs
wasmtime-25.0.2 ./ext/cargo-vendor/cranelift-isle-0.112.2/build.rs
wasmtime-25.0.1 ./ext/cargo-vendor/cranelift-isle-0.112.1/build.rs
wasmtime-25.0.0 ./ext/cargo-vendor/cranelift-isle-0.112.0/build.rs