Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/coverage_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def main(argv=None):
cmd = [str(args.xcl), "shaders", str(args.rpf), "--direct", "--sample", "0", "--json"]
if args.threads:
cmd += ["--threads", str(args.threads)]
proc = subprocess.run(cmd, capture_output=True, text=True)
proc = subprocess.run(cmd, capture_output=True, encoding="utf-8")
try:
run = sweep_json(proc.stdout)
except ValueError as e:
Expand Down
21 changes: 21 additions & 0 deletions scripts/test_coverage_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,27 @@ def test_new_stage_is_a_note(self):


class SweepJsonTests(unittest.TestCase):
def test_live_sweep_decoding_ignores_system_encoding(self):
import subprocess
import tempfile
from unittest.mock import patch

from coverage_gate import main

report = run()
report["unsupported"] = [{"example": "\u0141.dxbc FSSM#0"}]
stdout = json.dumps(report, ensure_ascii=False).encode("utf-8")

def run_xcl(cmd, *, capture_output, text=None, encoding="cp1252"):
return subprocess.CompletedProcess(cmd, 0, stdout.decode(encoding), "")

with tempfile.TemporaryDirectory() as tmp:
baseline = Path(tmp) / "baseline.json"
baseline.write_text(json.dumps(run()), encoding="utf-8")
args = ["--xcl", "xcl", "--rpf", "pack.rpf", "--baseline", str(baseline)]
with patch("coverage_gate.subprocess.run", side_effect=run_xcl):
self.assertEqual(main(args), 0)

def test_takes_the_last_json_line(self):
out = "some progress\n" + json.dumps({"stages": STAGES, "all": {}}) + "\n"
self.assertEqual(sweep_json(out)["stages"], STAGES)
Expand Down
Loading