Commit Graph

31 Commits

Author SHA1 Message Date
Dylan Baker e991c4d454 Use SPDX-License-Identifier consistently
This replaces all of the Apache blurbs at the start of each file with an
`# SPDX-License-Identifier: Apache-2.0` string. It also fixes existing
uses to be consistent in capitalization, and to be placed above any
copyright notices.

This removes nearly 3000 lines of boilerplate from the project (only
python files), which no developer cares to look at.

SPDX is in common use, particularly in the Linux kernel, and is the
recommended format for Meson's own `project(license: )` field
2023-12-13 15:19:21 -05:00
David Robillard 254abb999f Fix coverage with lcov 2.0 and uncovered subprojects
Version 2.0 of lcov triggers an error when an exclude pattern is unused.  This
can happen when the project has subprojects, but no code in them ends up
covered:

lcov: ERROR: 'exclude' pattern '/[...]/subprojects/*' is unused.
	(use "lcov --ignore-errors unused ..." to bypass this error)

So, simply do as it says.  Unused patterns doesn't seem problematic (or even
interesting) here, so I don't think there's any risk in simply turning this
off, which matches what happened with earlier versions of lcov anyway.
2023-12-06 23:54:42 +02:00
Nigel Kukard 2c4a1b6324 Add support for lcov 2.0
lcov 2.0 deprecates `--rc lcov_branch_coverage=1` for `--rc branch_coverage=1` and
gives an error when an exclude is used on a non existing directory.

I added a version check for lcov and removed the subprojects directory from the
exclusion list if it does not exist.

Fixes #11995
2023-10-08 23:13:06 -04:00
Jakob Widauer 07bd28732e Fix html coverage report generation when using clang on linux 2023-04-25 23:48:56 -04:00
Eli Schwartz 680b5ff819
treewide: add future annotations import 2023-02-01 17:01:30 -05:00
Alf Henrik Sauge 06bf9a5cda Fix purely white space issues reported by flake8 2022-08-26 17:12:40 -04:00
Eli Schwartz 1e4d4fce22 coverage: be clever and detect config files for gcovr/lcov
gcovr will read this file anyway, but if it exists we don't need to
assume that the project wishes to exclude subprojects/ -- they can
determine that themselves.

Fixes #3287
Closes #9761

lcov doesn't read the config file by default, but we can do the smart
thing here.

Fixes #4628
2022-05-06 22:55:37 +03:00
Eli Schwartz 0f0b1f22d2
coverage generator: obey the documentation and only generate supported outputs
We say:

> If version 4.2 or higher of the first is found, targets coverage-text,
> coverage-xml, coverage-sonarqube and coverage-html are generated.

But this is totally untrue. Make it true, by actually checking (and
not generating broken coverage commands when older versions of gcovr are
found).

Fixes #9505
2021-11-01 18:57:14 -04:00
Alois Wohlschlager 40d5a38d1b Escape path in exclude filter passed to gcovr
Gcovr interprets exclude filters, as passed to the -e option, as
regexes. Since we want to exclude a raw path, the argument must be
escaped.
2021-08-04 20:31:35 +02:00
Weston Schmidt 2e30b5a1e2 Add support for gcovr --sonarqube report
Sonarcloud.io only can read the sonarqube based report that gcovr can
produce.  This change enables support for this output in meson and
ninja.

Signed-off-by: Weston Schmidt <Weston_Schmidt@alumni.purdue.edu>
2021-07-23 22:15:00 +03:00
Daniel Mensinger 3e396b3782
fix: Always explicitly set encoding for text files (fixes #8263) 2021-06-29 11:28:08 +02:00
Eli Schwartz 6a0fabc647
mass rewrite of string formatting to use f-strings everywhere
performed by running "pyupgrade --py36-plus" and committing the results
2021-03-04 17:16:11 -05:00
Daniel Mensinger a4f4379c44
typing: fully annotate scripts 2020-09-08 20:15:56 +02:00
Cary Converse a198e5d191 coverage: llvm-cov support 2020-06-17 23:02:50 -04:00
Richard Kjerstadius 48ee6a6148 Add gcovr 4.2 support
The out-of-source build syntax for gcovr 4.2 is different compared to
previous versions and therefore an update was needed. In researching the
most appropriate solution it was found that any gcovr version older than
3.3 always resulted in 0% coverage. Because of this, rather than adding
an additional layer of logic, some already existing logic was modified
to ensure correct syntax for the new version, while versions older than
3.3 are flagged as not supported.

Closes mesonbuild#5089.
2019-04-24 20:05:21 +02:00
William A. Kennington III 61d462706a coverage: Also remove source_root prefixes
The code our projects care about verifying coverage for mostly lives in
the source_root with the exception of the generated source files in
build_root. This change cleans up the output so we don't have prefixed
paths on our source files anymore.
2018-12-16 20:24:05 +02:00
Mohammed Sadiq 41a98d0fdd coverage: Print summary after gcovr html generation
summary from stdout is often used by Automated builds to show build details

The --print-summary option was added to gcovr in v3.2, since html output
was added only in 3.1, limitting support to 3.2 won’t be a big deal.

--print-summary is not enabled for text/xml report generation as it will
result in meson not supporting any gcovr version less than 3.2.
2018-12-02 19:47:42 +02:00
Mohammed Sadiq 25fef3d1fa coverage: fix lcov branch coverage generation
lcov branch coverage are disabled by default.  So branch
coverage has to be enabled for every stage to make them work.

Fixes https://github.com/mesonbuild/meson/issues/4319
2018-10-09 22:43:27 +03:00
Joel Klinghed b2ffb6b565 Generate coveragereport directory for gcovr html target 2018-03-19 21:52:34 +01:00
Joel Klinghed 8bad2d9827 Exclude subprojects when doing coverage
Restore subproject exclusion for the html coverage report that existed
in the ninja backend legacy target.

Also exclude subprojects for the gcovr generated reports.
2018-03-19 21:52:34 +01:00
Joel Klinghed 79bb1df04f Use standalone coverage script for legacy targets
ninja coverage -> generate all possible reports (text, xml, html)
                  depending on gcovr and/or lcov/genhtml availability.
ninja coverage-html -> generate only html report
ninja coverage-xml -> generate only xml report
ninja coverage-text -> generate only text report

Make all targets phony, the old legacy rules where just annoying as
you would have to remove the old report before being able to generate
a new one.

ninja coverage succeeds if it can generate at least one report.
ninja coverage-* only succeeds if it can generate the requested report
2018-03-19 21:52:34 +01:00
Joel Klinghed 4e1b229b37 fixup! Allow gcovr >= 3.1 to be used to generate html coverage report
Rename gcovr_3_1 to gcovr_new_rootdir
2018-03-12 22:19:53 +01:00
Joel Klinghed ed8197207e fixup! Fix coverage-xml and coverage-text targets for gcovr >= 3.1
Rename gcovr_3_1 to gcovr_new_rootdir
2018-03-12 22:18:26 +01:00
Joel Klinghed 6266089866 Allow gcovr >= 3.1 to be used to generate html coverage report
Modern gcovr includes html generation support so if lcov and
genhtml are not available fallback to gcovr.

Kept lcov and genhtml as default so to not surprise existing
users of coverage-html with the different output of gcovr.

gcovr added html support in 3.0 but as there already is a test
for 3.1 because of the changes to -r/--rootdir I opted to only
allow html generation for >= 3.1 to keep things simple.
2018-02-27 21:58:05 +01:00
Joel Klinghed da01770261 Fix coverage-xml and coverage-text targets for gcovr >= 3.1
In gcovr 3.1 the -r/--rootdir argument changed meaning causing
reports generated with gcovr 3.1 to not find the source files
and look for *.gcda in the whole source tree rather than the
build dir.

So, detect gcovr version and if 3.1 give build_root to -r instead
of source_root.
2018-02-27 21:48:42 +01:00
Henk van der Laan 0e07f1a896 Remove all files outside the source directory from the coverage report
Cuurently, a set of directories is filtered out from the output based on
the location of system includes on most common linux distro's. This
commit does away with the blacklist and implements a whitelist approach:
only the files inside the source root are shown.
2018-02-08 00:39:37 +02:00
Félix Piédallu 5f3c282e6e Echo coverage report uris after generation. Fixes #2805. 2018-01-30 06:35:03 +11:00
snsmac 2b12d3b20f Exclude llvm/clang lib headers from test coverage
Excludes the /usr/lib/llvm-*/include/ directory from coverage.
This directory is used on Ubuntu for the libclang-dev packages
2017-12-17 13:26:40 +02:00
Stefan Sonski 462813f8f1 Exclude system sources from test coverage
Exclude /usr/src/ from code coverage, this is included for e.g. gtest/gmock.
2017-08-11 00:39:59 +03:00
Jussi Pakkanen 95f8cb93b3 Strip system directories and show coverage for files not executed at all. Closes #1721. 2017-05-13 23:30:54 +03:00
Jussi Pakkanen 111e3df45d Moved coverage commands to a standalone script. 2017-05-13 22:54:08 +03:00