Update github.com git:// SRC_URIs
[AGL/meta-agl-demo.git] / recipes-test / gcovr / gcovr / 0001-add-gcov-filter-source-errors-option.patch
1 Add option to filter gcov source errors
2
3 Add "--gcov-filter-source-errors" to apply filters to the source
4 files in the errors from gcov.  If all source files in the errors
5 are filtered, then the error is ignored so that the file will be
6 processed.  This enables the usecase of running on a target where
7 only the source tree for a binary is available, but not all of the
8 external source headers are.
9
10 Upstream-Status: pending
11
12 Signed-off-by: Scott Murray <scott.murray@konsulko.com>
13
14 diff --git a/gcovr/configuration.py b/gcovr/configuration.py
15 index 1356097..083532c 100644
16 --- a/gcovr/configuration.py
17 +++ b/gcovr/configuration.py
18 @@ -915,6 +915,14 @@ GCOVR_CONFIG_OPTIONS = [
19               "Default: {default!s}.",
20          action="store_true",
21      ),
22 +    GcovrConfigOption(
23 +        "gcov_filter_source_errors", ['--gcov-filter-source-errors'],
24 +        group="gcov_options",
25 +        help="Apply filters to missing source file errors in GCOV files "
26 +             "instead of exiting with an error. "
27 +             "Default: {default!s}.",
28 +        action="store_true",
29 +    ),
30      GcovrConfigOption(
31          "objdir", ['--object-directory'],
32          group="gcov_options",
33 diff --git a/gcovr/gcov.py b/gcovr/gcov.py
34 index de79215..171d68d 100644
35 --- a/gcovr/gcov.py
36 +++ b/gcovr/gcov.py
37 @@ -667,11 +667,27 @@ def run_gcov_and_process_files(
38              chdir=chdir,
39              tempdir=tempdir)
40  
41 +    skip = False
42      if source_re.search(err):
43 -        # gcov tossed errors: try the next potential_wd
44 -        error(err)
45 -        done = False
46 -    else:
47 +        ignore = False
48 +        if options.gcov_filter_source_errors:
49 +            # Check if errors are all from source that is filtered
50 +            ignore = True
51 +            for line in err.splitlines():
52 +                src_fname = line.split()[-1]
53 +                filtered, excluded = apply_filter_include_exclude(
54 +                    src_fname, options.filter, options.exclude)
55 +                if not (filtered or excluded):
56 +                    ignore = False
57 +                    break
58 +
59 +        if not ignore:
60 +            # gcov tossed errors: try the next potential_wd
61 +            error(err)
62 +            skip = True
63 +
64 +    done = False
65 +    if not skip:
66          # Process *.gcov files
67          for fname in active_gcov_files:
68              process_gcov_data(fname, covdata, abs_filename, options)