From a1326581a5bc23aadbcf9dd4541b8a8304f6bc95 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Fri, 18 Aug 2017 15:31:13 +0300 Subject: [PATCH] Fix coverage target breakage and add a test for it. --- ciimage/Dockerfile | 1 + mesonbuild/backend/ninjabackend.py | 2 +- run_unittests.py | 13 +++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ciimage/Dockerfile b/ciimage/Dockerfile index 3789e8dbe..0ed1e0172 100644 --- a/ciimage/Dockerfile +++ b/ciimage/Dockerfile @@ -10,4 +10,5 @@ RUN apt-get -y update && apt-get -y upgrade \ && apt-get -y install python3-pip libxml2-dev libxslt1-dev cmake libyaml-dev \ && apt-get -y install openmpi-bin libopenmpi-dev \ && apt-get -y install libvulkan-dev libpcap-dev \ +&& apt-get -y install gcovr lcov \ && python3 -m pip install hotdoc codecov diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 70fa9c14a..ec811cbae 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -626,7 +626,7 @@ int dummy; added_rule = True htmloutdir = os.path.join(self.environment.get_log_dir(), 'coveragereport') covinfo = os.path.join(self.environment.get_log_dir(), 'coverage.info') - phony_elem = NinjaBuildElement(self.all_outputs, 'coverage-html', 'phony', os.path.join(htmloutdir, 'index.html')) + phony_elem = NinjaBuildElement(self.all_outputs, 'meson-coverage-html', 'phony', os.path.join(htmloutdir, 'index.html')) phony_elem.write(outfile) # Alias that runs the target defined above self.create_target_alias('meson-coverage-html', outfile) diff --git a/run_unittests.py b/run_unittests.py index 666777df6..1fb1b4b62 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -1910,6 +1910,19 @@ class LinuxlikeTests(BasePlatformTests): for i in compdb: self.assertIn("-fsanitize=address", i["command"]) + def test_coverage(self): + if not shutil.which('gcovr'): + raise unittest.SkipTest('gcovr not found') + if not shutil.which('genhtml'): + raise unittest.SkipTest('genhtml not found') + if 'clang' in os.environ.get('CC', '') and os.environ.get('TRAVIS_OS_NAME', '') == 'linux': + raise unittest.SkipTest('Gcovr has a bug and does not work with Clang in the CI environment.') + testdir = os.path.join(self.common_test_dir, '1 trivial') + self.init(testdir, ['-Db_coverage=true']) + self.build() + self.run_tests() + self.run_target('coverage-html') + class LinuxArmCrossCompileTests(BasePlatformTests): ''' Tests that verify cross-compilation to Linux/ARM