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 @@ -61,7 +61,7 @@ def main(argv=None):
ap.add_argument("--update", action="store_true", help="write the baseline from the sweep and exit 0")
args = ap.parse_args(argv)
if args.run_json:
run = json.loads(args.run_json.read_text(encoding="utf-8"))
run = json.loads(args.run_json.read_bytes())
else:
if not (args.xcl and args.rpf):
ap.error("--xcl and --rpf are required unless --run-json is given")
Expand Down
27 changes: 27 additions & 0 deletions scripts/test_coverage_saved_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from contextlib import redirect_stdout
from io import StringIO
import json
from pathlib import Path
import tempfile
import unittest

from coverage_gate import main


class SavedReportTests(unittest.TestCase):
def test_run_json_accepts_byte_order_marks(self):
counts = {"total": 1, "translated": 1, "unsupported": 0, "validator_failed": 0, "panicked": 0, "timeout": 0}
report = json.dumps({"stages": {"CS": counts}})
with tempfile.TemporaryDirectory() as tmp:
baseline = Path(tmp) / "baseline.json"
sweep = Path(tmp) / "sweep.json"
baseline.write_text(report, encoding="utf-8")
for encoding in ("utf-8", "utf-8-sig", "utf-16"):
with self.subTest(encoding=encoding), redirect_stdout(StringIO()) as out:
sweep.write_text(report, encoding=encoding)
self.assertEqual(main(["--baseline", str(baseline), "--run-json", str(sweep)]), 0)
self.assertIn("coverage gate: no regressions", out.getvalue())


if __name__ == "__main__":
unittest.main()
Loading