From fd6f963829a54439ecfffd43d41deaec71e0265c Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 11 Jul 2026 18:20:08 +0000 Subject: [PATCH] phase3: diff-test resolves {out}-templated binary; CI gates cjson MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit diff-test standalone (just gates / CI target-gates) passed the now- templated build.binary into golden replay verbatim — literal {out}. It now builds the current tree to targets//gates-build and tests that, with a --binary override. CI's target-gates-no-net job gains clang/cmake, fetches+gates the cjson C target (clang build -> Unity/ CTest -> golden replay) alongside tokei. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01EcKPWQ3MQD4NdEHwar96u2 --- .github/workflows/ci.yml | 8 +++++++- crates/diff-test/src/main.rs | 28 ++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 48fad2d..5229460 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,18 +25,24 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 + - name: Toolchains for C/C++ targets + run: sudo apt-get update -qq && sudo apt-get install -y -qq clang cmake - name: Fetch pinned targets run: | sh targets/fetch.sh comrak sh targets/fetch.sh tokei + sh targets/fetch.sh cjson - name: Generate + verify pinned corpora run: | sh corpora/comrak/gen-corpus.sh sh corpora/tokei/gen-corpus.sh + sh corpora/cjson/gen-corpus.sh - name: Build tokei baseline run: cargo build --release --manifest-path targets/tokei/workspace/Cargo.toml - - name: Gates (corpus pin -> upstream tests -> golden replay) + - name: Gates — tokei (Rust; corpus pin -> upstream tests -> golden replay) run: cargo run -p diff-test -- tokei + - name: Gates — cjson (C; clang build -> Unity/CTest -> golden replay) + run: cargo run -p diff-test -- cjson - name: Bench workload inside no-network container run: | docker run --rm --network=none \ diff --git a/crates/diff-test/src/main.rs b/crates/diff-test/src/main.rs index 8dc5f77..fb7b165 100644 --- a/crates/diff-test/src/main.rs +++ b/crates/diff-test/src/main.rs @@ -5,7 +5,7 @@ use anyhow::Result; use clap::Parser; use diff_test::orchestrate::run_core_gates; -use diff_test::target::TargetSpec; +use diff_test::target::{subst_out, TargetSpec}; use diff_test::{all_passed, GateOutcome}; use std::path::PathBuf; @@ -17,13 +17,37 @@ struct Cli { /// Repository root (defaults to current directory). #[arg(long, default_value = ".")] root: PathBuf, + /// Binary to test in golden replay. If omitted, the current working + /// tree is built to targets//gates-build and that is tested. + #[arg(long)] + binary: Option, } fn main() -> Result<()> { let cli = Cli::parse(); let root = cli.root.canonicalize()?; let spec = TargetSpec::load(&root, &cli.target)?; - let results = run_core_gates(&root, &spec, &spec.build.binary)?; + // build.binary is an {out}-templated path now; resolve it to a real + // binary either from --binary or by building the current tree into an + // isolation dir (so `just gates` tests what's on disk, self-contained). + let binary = match &cli.binary { + Some(b) => b.clone(), + None => { + let out = root + .join(format!("targets/{}/gates-build", cli.target)) + .to_string_lossy() + .into_owned(); + println!("building current tree for gates -> {out}"); + let status = std::process::Command::new("sh") + .arg("-c") + .arg(subst_out(&spec.build.baseline, &out)) + .current_dir(&root) + .status()?; + anyhow::ensure!(status.success(), "gates build failed"); + subst_out(&spec.build.binary, &out) + } + }; + let results = run_core_gates(&root, &spec, &binary)?; for (layer, outcome) in &results { match outcome { GateOutcome::Passed => println!("{layer:?}: PASS"),