rust/tests/run-make/doctests-junit/validate_junit.py
Oleksii Lozovskyi 2cc434863c rustdoc: Test --format=junit
Copied validate_junit.py from libtest-junit.

JUnit format works well in edition 2021, but is currently broken
in edition 2024 by the mergeable doctest report.
2025-12-13 16:31:02 +09:00

22 lines
712 B
Python
Executable file

#!/usr/bin/env python
# Trivial Python script that reads lines from stdin, and checks that each line
# is a well-formed XML document.
#
# This takes advantage of the fact that Python has a built-in XML parser,
# whereas doing the same check in Rust would require us to pull in an XML
# crate just for this relatively-minor test.
#
# If you're trying to remove Python scripts from the test suite, think twice
# before removing this one. You could do so, but it's probably not worth it.
import sys
import xml.etree.ElementTree as ET
# Read the entire output and try to decode it as XML.
junit = sys.stdin.read()
try:
ET.fromstring(junit)
except ET.ParseError:
print("Invalid xml: %r" % junit)
raise