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
3 changes: 2 additions & 1 deletion scripts/coverage_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

def sweep_json(stdout):
"""The report line of `xcl shaders --direct --json` output (the last JSON line)."""
for line in reversed(stdout.splitlines()):
# Unicode line separators can occur inside JSON strings, including program names.
for line in reversed(stdout.split("\n")):
line = line.strip()
if line.startswith("{"):
return json.loads(line)
Expand Down
8 changes: 8 additions & 0 deletions scripts/test_coverage_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ 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)

def test_unicode_line_separators_in_report_strings(self):
for separator in ("\u0085", "\u2028", "\u2029"):
with self.subTest(separator=repr(separator)):
report = run()
report["unsupported"] = [{"example": f"dir{separator}name.dxbc FSSM#0"}]
out = "progress\r\n" + json.dumps(report, ensure_ascii=False) + "\r\n"
self.assertEqual(sweep_json(out), report)

def test_raises_without_a_report(self):
with self.assertRaises(ValueError):
sweep_json("no json here")
Expand Down
Loading