From 17f52840413fe857ff604d762cf91886a4a5e2ca Mon Sep 17 00:00:00 2001 From: luckyteagirl <290248872+luckyteagirl@users.noreply.github.com> Date: Wed, 25 Nov 2026 01:31:12 -0800 Subject: [PATCH] Scripts: validate DXIL in coverage gate sweeps (#2196) The gate compared validator_failed counts without asking the direct sweep to run the validator. Pass --validate and cover the spawned command with a regression test. A full 22,445-program sweep on the owned shader pack confirmed the baseline counts remain unchanged. --- scripts/coverage_gate.py | 6 +++--- scripts/test_coverage_gate.py | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/scripts/coverage_gate.py b/scripts/coverage_gate.py index e7ed84d66a..26cbf97d8a 100644 --- a/scripts/coverage_gate.py +++ b/scripts/coverage_gate.py @@ -1,8 +1,8 @@ #!/usr/bin/env python3 """Direct-DXIL coverage baseline and gate. -`xcl shaders --direct --sample 0 --json` sweeps every console program in a shader -pack through the direct translator and prints per-stage outcome counts. Run that sweep (or +`xcl shaders --direct --validate --sample 0 --json` sweeps every console program in a shader +pack through the direct translator and validator, then prints per-stage outcome counts. Run that sweep (or hand in its saved JSON) and compare the counts against a committed baseline: a stage that translated fewer programs than the baseline, or gained validator failures, panicked or timed out, is a coverage regression - the class of bug a sibling project lost 323 shader @@ -65,7 +65,7 @@ def main(argv=None): else: if not (args.xcl and args.rpf): ap.error("--xcl and --rpf are required unless --run-json is given") - cmd = [str(args.xcl), "shaders", str(args.rpf), "--direct", "--sample", "0", "--json"] + cmd = [str(args.xcl), "shaders", str(args.rpf), "--direct", "--validate", "--sample", "0", "--json"] if args.threads: cmd += ["--threads", str(args.threads)] proc = subprocess.run(cmd, capture_output=True, text=True) diff --git a/scripts/test_coverage_gate.py b/scripts/test_coverage_gate.py index 314e3916e8..6c28bde8a1 100644 --- a/scripts/test_coverage_gate.py +++ b/scripts/test_coverage_gate.py @@ -1,8 +1,10 @@ import json import unittest from pathlib import Path +from tempfile import TemporaryDirectory +from unittest.mock import patch -from coverage_gate import compare, sweep_json +from coverage_gate import compare, main, sweep_json STAGES = { "CS": {"total": 100, "translated": 95, "unsupported": 5, "validator_failed": 0, "panicked": 0, "timeout": 0}, @@ -58,6 +60,20 @@ def test_new_stage_is_a_note(self): self.assertEqual(notes, ["MS: new stage in the sweep"]) +class GateCommandTests(unittest.TestCase): + def test_gate_sweep_enables_validation(self): + with TemporaryDirectory() as directory, patch("coverage_gate.subprocess.run") as run_sweep: + root = Path(directory) + xcl, pack = root / "xcl.exe", root / "shaders.rpf" + xcl.touch() + pack.touch() + run_sweep.return_value.stdout = json.dumps({"stages": STAGES}) + run_sweep.return_value.stderr = "" + result = main(["--xcl", str(xcl), "--rpf", str(pack), "--update", "--baseline", str(root / "baseline.json")]) + self.assertEqual(result, 0) + self.assertIn("--validate", run_sweep.call_args.args[0]) + + class SweepJsonTests(unittest.TestCase): def test_takes_the_last_json_line(self): out = "some progress\n" + json.dumps({"stages": STAGES, "all": {}}) + "\n"