diff options
author | Charles Brunet <charles.brunet@optelgroup.com> | 2023-04-20 08:46:10 -0400 |
---|---|---|
committer | Eli Schwartz <eschwartz93@gmail.com> | 2023-04-24 15:48:31 -0400 |
commit | 70e2da07737c6ed474ab5990ac32c3d4f7e88bd2 (patch) | |
tree | bb41994d346bdf619ad8c82a17c452fbf622db21 | |
parent | 523204f1f1529001388e4b10c5566c1eb18db4e8 (diff) | |
download | meson-70e2da07737c6ed474ab5990ac32c3d4f7e88bd2.tar.gz |
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.
-rw-r--r-- | mesonbuild/mtest.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py index f7cf77070..cbf1c193d 100644 --- a/mesonbuild/mtest.py +++ b/mesonbuild/mtest.py @@ -1035,12 +1035,16 @@ class TestRunGTest(TestRunExitCode): filename = os.path.join(self.test.workdir, filename) try: - self.junit = et.parse(filename) + with open(filename, 'r', encoding='utf8', errors='replace') as f: + self.junit = et.parse(f) except FileNotFoundError: # This can happen if the test fails to run or complete for some # reason, like the rpath for libgtest isn't properly set. ExitCode # will handle the failure, don't generate a stacktrace. 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() |