vyre-conform 0.1.0

Conformance suite for vyre backends — proves byte-identical output to CPU reference
Documentation
use crate::spec::types::ParityFailure;
use std::fs;
use std::io::{self, Write};
use std::path::PathBuf;
use std::sync::atomic::{AtomicU64, Ordering};
use std::time::{SystemTime, UNIX_EPOCH};
#[cfg(loom)]
use loom::sync::Mutex as LoomMutex;
use super::hex::*;

/// Load regression files from a directory, tagging each with `tag`.
fn load_from_dir(dir: &std::path::Path, tag: &str) -> Vec<(String, Vec<u8>)> {
    let Ok(entries) = fs::read_dir(dir) else {
        return Vec::new();
    };
    let mut out = Vec::new();
    for entry in entries.flatten() {
        let path = entry.path();
        let label = match path.file_stem().and_then(|stem| stem.to_str()) {
            Some(stem) => stem.to_string(),
            None => "regression".to_string(),
        };
        match path.extension().and_then(|ext| ext.to_str()) {
            Some("json") => {
                if let Ok(text) = fs::read_to_string(&path) {
                    if let Ok(failure) = serde_json::from_str::<PersistedFailure>(&text) {
                        out.push((format!("regression:{tag}:{label}"), failure.input));
                    }
                }
            }
            Some("hex") => {
                if let Ok(text) = fs::read_to_string(&path) {
                    if let Ok(bytes) = decode_hex(text.trim()) {
                        out.push((format!("regression:{tag}:{label}"), bytes));
                    }
                }
            }
            Some("bin") => {
                if let Ok(bytes) = fs::read(&path) {
                    out.push((format!("regression:{tag}:{label}"), bytes));
                }
            }
            _ => continue,
        }
    }
    out.sort_by(|a, b| a.0.cmp(&b.0));
    out
}