mtest: prevent parse error with gtest protocol

Replace illegal characters when reading gtest generated xml file,
to prevent a ParseError and a stacktrace.

catch et.ParseError, just in case, to prevent stopping other tests
if the xml file was malformed.
pull/11729/head
Charles Brunet 2 years ago committed by Eli Schwartz
parent 523204f1f1
commit 70e2da0773
  1. 6
      mesonbuild/mtest.py

@ -1035,12 +1035,16 @@ class TestRunGTest(TestRunExitCode):
filename = os.path.join(self.test.workdir, filename) filename = os.path.join(self.test.workdir, filename)
try: try:
self.junit = et.parse(filename) with open(filename, 'r', encoding='utf8', errors='replace') as f:
self.junit = et.parse(f)
except FileNotFoundError: except FileNotFoundError:
# This can happen if the test fails to run or complete for some # This can happen if the test fails to run or complete for some
# reason, like the rpath for libgtest isn't properly set. ExitCode # reason, like the rpath for libgtest isn't properly set. ExitCode
# will handle the failure, don't generate a stacktrace. # will handle the failure, don't generate a stacktrace.
pass pass
except et.ParseError as e:
# ExitCode will handle the failure, don't generate a stacktrace.
mlog.error(f'Unable to parse {filename}: {e!s}')
super().complete() super().complete()

Loading…
Cancel
Save