New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix verbose output when using existing gcov files #144

Merged
merged 1 commit into from Jan 7, 2018

Conversation

Projects
None yet
2 participants
@mayeut
Contributor

mayeut commented Sep 1, 2016

When gcovr is invoked with -v and -g switches, it fails with error:

    ....
    print('  source_fname '+source_fname)
TypeError: cannot concatenate 'str' and 'NoneType' objects

This patch disables printing of source_fname when source_fname is None

Fixes #143

@latk

Thank you for this excellent pull request! I love it that you added the test case to validate these changes 💯

I just have a few minor nitpicks that I'd like to see addressed before I merge…

foo(
0
)
;

This comment has been minimized.

@latk

latk Jan 7, 2018

Member

This fancy code layout is not relevant to the gcovr behaviour being tested: the -v option.

This comment has been minimized.

@mayeut

mayeut Jan 7, 2018

Contributor

c.f. updated README file => same cpp file as simple1 test

The second conditional in main() includes lines with
(, ) and ; characters. These need to be treated as
covered lines.

This comment has been minimized.

@latk

latk Jan 7, 2018

Member

This paragraph is misleading, because it is unrelated to the actual test. And the conditional doesn't contain any commas.

This comment has been minimized.

@mayeut

mayeut Jan 7, 2018

Contributor

README file updated to reflect actual content of this folder

@@ -526,7 +526,8 @@ def process_gcov_data(data_fname, covdata, source_fname, options):
print(' currdir '+currdir)
print(' gcov_fname '+data_fname)
print(' '+str(segments))
print(' source_fname '+source_fname)
if not source_fname is None:
print(' source_fname '+source_fname)

This comment has been minimized.

@latk

latk Jan 7, 2018

Member

PEP-8 suggests to write the conditional like if source_fname is not None. Let's use that for consistency.

Also, do you think print(' source_fname '+(source_fname if source_fname is not None else '(None)')) might be better? This makes it easier to see that the output is aligned, and makes it clearer that this field is explicitly empty. Or if we simply concatenate str(source_fname) rather than source_fname, we don't even need any conditionals.

This comment has been minimized.

@mayeut

mayeut Jan 7, 2018

Contributor

I went with str(source_fname) as suggested.

@mayeut mayeut force-pushed the mayeut:patch-verbose-existing branch from d1382d0 to bcf9c6e Jan 7, 2018

Fix verbose output when using existing gcov files
When gcovr is invoked with `-v` and `-g` switches, it fails with error:
```
    ....
    print('  source_fname '+source_fname)
TypeError: cannot concatenate 'str' and 'NoneType' objects
```
This patch disables printing of `source_fname` when `source_fname is None`

@mayeut mayeut force-pushed the mayeut:patch-verbose-existing branch from bcf9c6e to 95a3fcd Jan 7, 2018

@latk

latk approved these changes Jan 7, 2018

@latk latk merged commit 055d2ce into gcovr:master Jan 7, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@mayeut mayeut deleted the mayeut:patch-verbose-existing branch Jan 8, 2018

@latk latk removed the needs review label Jan 20, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment