vyre-conform 0.1.0

Conformance suite for vyre backends — proves byte-identical output to CPU reference
Documentation
use crate::generate::generators;
use crate::OpSpec;
use serde::{Deserialize, Serialize};
use std::collections::HashSet;
use std::fs;
use std::io;
use std::path::Path;
use super::util::*;

/// Replay goldens against the current CPU references.
///
/// Finds each golden's op by `id` (not version) and runs the current `cpu_fn`.
/// If the output differs from the frozen output, the mismatch is recorded as a
/// breaking change.
use super::{Golden, GoldenReport};
#[inline]
pub fn replay_goldens(goldens: &[Golden], specs: &[OpSpec]) -> GoldenReport {
    let mut report = GoldenReport {
        tested: goldens.len(),
        ..Default::default()
    };

    for golden in goldens {
        let Some(spec) = specs.iter().find(|s| s.id == golden.op_id) else {
            report.failures.push(GoldenMismatch {
                op_id: golden.op_id.clone(),
                spec_version: golden.spec_version,
                input_hash: sha256_hex(&golden.input),
                expected_output: golden.output.clone(),
                actual_output: Vec::new(),
            });
            continue;
        };

        let actual = (spec.cpu_fn)(&golden.input);
        if actual == golden.output {
            report.passed += 1;
        } else {
            report.failures.push(GoldenMismatch {
                op_id: golden.op_id.clone(),
                spec_version: golden.spec_version,
                input_hash: sha256_hex(&golden.input),
                expected_output: golden.output.clone(),
                actual_output: actual,
            });
        }
    }

    report
}