diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2020-08-15 13:16:31 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2020-08-15 16:02:50 +0530 |
commit | f3c988c26b2efc07b551eaba654e319be2659606 (patch) | |
tree | a13bbe423f79a7ee4272166faf29313140ad386c | |
parent | ef326f85689412985dabe2dd1b4669178fc6f6b7 (diff) | |
download | meson-f3c988c26b2efc07b551eaba654e319be2659606.zip meson-f3c988c26b2efc07b551eaba654e319be2659606.tar.gz meson-f3c988c26b2efc07b551eaba654e319be2659606.tar.bz2 |
ninjabackend: Fix coverage rule generation
Without the parenthesis, the command evaluates to `[]` if
`use_llvm_cov` is `False`.
Also fix tests to actually check whether or not coverage reports are
generated.
Fixes https://github.com/mesonbuild/meson/issues/7553
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 2 | ||||
-rwxr-xr-x | run_unittests.py | 17 |
2 files changed, 18 insertions, 1 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 4b6c046..44ea714 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -986,7 +986,7 @@ int dummy; self.build.get_subproject_dir()), self.environment.get_build_dir(), self.environment.get_log_dir()] + - ['--use_llvm_cov'] if use_llvm_cov else []) + (['--use_llvm_cov'] if use_llvm_cov else [])) def generate_coverage_rules(self): e = NinjaBuildElement(self.all_outputs, 'meson-coverage', 'CUSTOM_COMMAND', 'PHONY') diff --git a/run_unittests.py b/run_unittests.py index 2372b45..fbeee80 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -4881,6 +4881,18 @@ recommended as it is not supported on some platforms''') m = get_data_pattern(command).search(md, pos=md_command_sections[command][0], endpos=md_command_sections[command][1]) self.assertIsNotNone(m, 'Command `{}` is missing placeholders for dynamic data. Doc file: `{}`'.format(command, doc_path)) + def _check_coverage_files(self, types=('text', 'xml', 'html')): + covdir = Path(self.builddir) / 'meson-logs' + files = [] + if 'text' in types: + files.append('coverage.txt') + if 'xml' in types: + files.append('coverage.xml') + if 'html' in types: + files.append('coveragereport/index.html') + for f in files: + self.assertTrue((covdir / f).is_file(), msg='{} is not a file'.format(f)) + def test_coverage(self): if mesonbuild.environment.detect_msys2_arch(): raise unittest.SkipTest('Skipped due to problems with coverage on MSYS2') @@ -4899,6 +4911,7 @@ recommended as it is not supported on some platforms''') self.build() self.run_tests() self.run_target('coverage') + self._check_coverage_files() def test_coverage_complex(self): if mesonbuild.environment.detect_msys2_arch(): @@ -4918,6 +4931,7 @@ recommended as it is not supported on some platforms''') self.build() self.run_tests() self.run_target('coverage') + self._check_coverage_files() def test_coverage_html(self): if mesonbuild.environment.detect_msys2_arch(): @@ -4937,6 +4951,7 @@ recommended as it is not supported on some platforms''') self.build() self.run_tests() self.run_target('coverage-html') + self._check_coverage_files(['html']) def test_coverage_text(self): if mesonbuild.environment.detect_msys2_arch(): @@ -4956,6 +4971,7 @@ recommended as it is not supported on some platforms''') self.build() self.run_tests() self.run_target('coverage-text') + self._check_coverage_files(['text']) def test_coverage_xml(self): if mesonbuild.environment.detect_msys2_arch(): @@ -4975,6 +4991,7 @@ recommended as it is not supported on some platforms''') self.build() self.run_tests() self.run_target('coverage-xml') + self._check_coverage_files(['xml']) def test_cross_file_constants(self): with temp_filename() as crossfile1, temp_filename() as crossfile2: |