diff options
Diffstat (limited to 'meta-python/recipes-devtools/python/python3-gcovr/0001-Fix-parsing-of-gcov-metadata-601.patch')
| -rw-r--r-- | meta-python/recipes-devtools/python/python3-gcovr/0001-Fix-parsing-of-gcov-metadata-601.patch | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python3-gcovr/0001-Fix-parsing-of-gcov-metadata-601.patch b/meta-python/recipes-devtools/python/python3-gcovr/0001-Fix-parsing-of-gcov-metadata-601.patch new file mode 100644 index 0000000000..5530a39857 --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-gcovr/0001-Fix-parsing-of-gcov-metadata-601.patch | |||
| @@ -0,0 +1,84 @@ | |||
| 1 | From c4f53f28c4c537b75b5912a44083c41262807504 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: =?UTF-8?q?Michael=20F=C3=B6rderer?= <michael.foerderer@gmx.de> | ||
| 3 | Date: Sun, 3 Apr 2022 22:58:33 +0200 | ||
| 4 | Subject: [PATCH] Fix parsing of gcov metadata (#601) | ||
| 5 | |||
| 6 | gcc-11 has metadata line "-: 0:Source is newer than graph" which throws an error. | ||
| 7 | |||
| 8 | Upstream-Status: Backport [https://github.com/gcovr/gcovr/commit/7b6947bd4b6fd28a477606313fff3c13fcea8d3d] | ||
| 9 | |||
| 10 | Signed-off-by: Jasper Orschulko <jasper@fancydomain.eu> | ||
| 11 | --- | ||
| 12 | gcovr/gcov.py | 5 ++++- | ||
| 13 | gcovr/gcov_parser.py | 24 ++++++++++++++++++++---- | ||
| 14 | 2 files changed, 24 insertions(+), 5 deletions(-) | ||
| 15 | |||
| 16 | diff --git a/gcovr/gcov.py b/gcovr/gcov.py | ||
| 17 | index cc7a9af4..ff4cdb0b 100644 | ||
| 18 | --- a/gcovr/gcov.py | ||
| 19 | +++ b/gcovr/gcov.py | ||
| 20 | @@ -98,8 +98,11 @@ def process_gcov_data(data_fname, covdata, source_fname, options, currdir=None): | ||
| 21 | # Find the source file | ||
| 22 | # TODO: instead of heuristics, use "working directory" if available | ||
| 23 | metadata = parse_metadata(lines) | ||
| 24 | + source = metadata.get("Source") | ||
| 25 | + if source is None: | ||
| 26 | + raise RuntimeError("Unexpected value 'None' for metadata 'Source'.") | ||
| 27 | fname = guess_source_file_name( | ||
| 28 | - metadata["Source"].strip(), | ||
| 29 | + source, | ||
| 30 | data_fname, | ||
| 31 | source_fname, | ||
| 32 | root_dir=options.root_dir, | ||
| 33 | diff --git a/gcovr/gcov_parser.py b/gcovr/gcov_parser.py | ||
| 34 | index 391ecd78..523ea406 100644 | ||
| 35 | --- a/gcovr/gcov_parser.py | ||
| 36 | +++ b/gcovr/gcov_parser.py | ||
| 37 | @@ -121,7 +121,7 @@ class _MetadataLine(NamedTuple): | ||
| 38 | """A gcov line with metadata: ``-: 0:KEY:VALUE``""" | ||
| 39 | |||
| 40 | key: str | ||
| 41 | - value: str | ||
| 42 | + value: Optional[str] | ||
| 43 | |||
| 44 | |||
| 45 | class _BlockLine(NamedTuple): | ||
| 46 | @@ -214,7 +214,19 @@ def parse_metadata(lines: List[str]) -> Dict[str, str]: | ||
| 47 | ... -: 0:Foo:bar | ||
| 48 | ... -: 0:Key:123 | ||
| 49 | ... '''.splitlines()) | ||
| 50 | - {'Foo': 'bar', 'Key': '123'} | ||
| 51 | + Traceback (most recent call last): | ||
| 52 | + ... | ||
| 53 | + RuntimeError: Missing key 'Source' in metadata. GCOV data was >> | ||
| 54 | + -: 0:Foo:bar | ||
| 55 | + -: 0:Key:123<< End of GCOV data | ||
| 56 | + >>> parse_metadata('-: 0:Source: file \n -: 0:Foo: bar \n -: 0:Key: 123 '.splitlines()) | ||
| 57 | + {'Source': 'file', 'Foo': 'bar', 'Key': '123'} | ||
| 58 | + >>> parse_metadata(''' | ||
| 59 | + ... -: 0:Source:file | ||
| 60 | + ... -: 0:Foo:bar | ||
| 61 | + ... -: 0:Key | ||
| 62 | + ... '''.splitlines()) | ||
| 63 | + {'Source': 'file', 'Foo': 'bar', 'Key': None} | ||
| 64 | """ | ||
| 65 | collected = {} | ||
| 66 | for line in lines: | ||
| 67 | @@ -721,8 +733,12 @@ def _parse_line(line: str) -> _Line: | ||
| 68 | |||
| 69 | # METADATA (key, value) | ||
| 70 | if count_str == "-" and lineno == "0": | ||
| 71 | - key, value = source_code.split(":", 1) | ||
| 72 | - return _MetadataLine(key, value) | ||
| 73 | + if ":" in source_code: | ||
| 74 | + key, value = source_code.split(":", 1) | ||
| 75 | + return _MetadataLine(key, value.strip()) | ||
| 76 | + else: | ||
| 77 | + # Add a syntethic metadata with no value | ||
| 78 | + return _MetadataLine(source_code, None) | ||
| 79 | |||
| 80 | if count_str == "-": | ||
| 81 | count = 0 | ||
| 82 | -- | ||
| 83 | 2.41.0 | ||
| 84 | |||
