diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2020-04-22 12:25:49 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2020-04-23 13:26:01 -0700 |
commit | 7b7f93a09f90c93d94e4a78ddc1dd766f05bf4a9 (patch) | |
tree | 506a32461fce0b777f627ec069bab542e48d27cb /run_unittests.py | |
parent | 0c3bb15357419d3cc7a453da25b349a9c34e391d (diff) | |
download | meson-7b7f93a09f90c93d94e4a78ddc1dd766f05bf4a9.zip meson-7b7f93a09f90c93d94e4a78ddc1dd766f05bf4a9.tar.gz meson-7b7f93a09f90c93d94e4a78ddc1dd766f05bf4a9.tar.bz2 |
mtest: Generate a JUnit xml result file
JUnit is pretty ubiquitous, lots of services and results viewers
understand it, in particular gitlab and jenkins know how to consume
JUnit xml. This means projects using CI services can have their test
results consumed automatically.
Fixes: #6972
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-x | run_unittests.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/run_unittests.py b/run_unittests.py index 831e53f..da898a3 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -4617,6 +4617,31 @@ recommended as it is not supported on some platforms''') out = self.build() self.assertNotIn('Project configured', out) + def _test_junit(self, case: str) -> None: + try: + import lxml.etree as et + except ImportError: + raise unittest.SkipTest('lxml required, but not found.') + + schema = et.XMLSchema(et.parse(str(Path(__file__).parent / 'data' / 'schema.xsd'))) + + testdir = os.path.join(self.common_test_dir, case) + self.init(testdir) + self.run_tests() + + junit = et.parse(str(Path(self.builddir) / 'meson-logs' / 'testlog.junit.xml')) + try: + schema.assertValid(junit) + except et.DocumentInvalid as e: + self.fail(e.error_log) + + def test_junit_valid_tap(self): + self._test_junit('213 tap tests') + + def test_junit_valid_exitcode(self): + self._test_junit('44 test args') + + class FailureTests(BasePlatformTests): ''' Tests that test failure conditions. Build files here should be dynamically |