icedwright-probe 0.1.4

What an iced app links for icedwright: semantic annotations, typed test ids and named tasks, all pass-through unless a feature turns them on
Documentation
//! The probe's compile-time guarantees. Cases in `tests/compile_fail/` hold in every feature
//! set and run under each; cases in `tests/compile_fail/control/` need the `control` feature
//! and cases in `tests/compile_fail/remote/` the `remote` feature.
//! A case whose name starts with `pass_` must compile.

use std::path::{Path, PathBuf};

fn cases(dir: &Path) -> std::io::Result<Vec<PathBuf>> {
    let mut cases: Vec<PathBuf> = std::fs::read_dir(dir)?
        .map(|entry| entry.map(|e| e.path()))
        .collect::<Result<_, _>>()?;
    cases.retain(|path| path.extension().is_some_and(|ext| ext == "rs"));
    cases.sort();
    Ok(cases)
}

#[test]
fn compile_fail() -> std::io::Result<()> {
    let mut all = cases(Path::new("tests/compile_fail"))?;
    if cfg!(feature = "control") {
        all.extend(cases(Path::new("tests/compile_fail/control"))?);
    }
    if cfg!(feature = "remote") {
        all.extend(cases(Path::new("tests/compile_fail/remote"))?);
    }

    let tests = trybuild::TestCases::new();
    for case in &all {
        let is_pass = case
            .file_name()
            .and_then(|name| name.to_str())
            .is_some_and(|name| name.starts_with("pass_"));
        if is_pass {
            tests.pass(case);
        } else {
            tests.compile_fail(case);
        }
    }
    Ok(())
}