8000 Make gcovr return -1 · Issue #716 · gcovr/gcovr · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Make gcovr return -1 #716

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

Closed
MartinDelille opened this issue Feb 15, 2023 · 7 comments · Fixed by #718
Closed

Make gcovr return -1 #716

MartinDelille opened this issue Feb 15, 2023 · 7 comments · Fixed by #718

Comments

@MartinDelille
Copy link

I wondered if it is possible to return an error code when such warning occurs:

(WARNING) GCOV produced the following errors processing /path/to/file.gcda: 
  /path/to/file.gcno: No such file or directory 
  (gcovr could not infer a working directory that resolved it.)

It currently fails silently.

@Spacetown
Copy link
Member
Spacetown commented Feb 15, 2023

@latk Here I need your advice. I'm not sure but I think a error would be better here maybe with an option to turn into warning. If the configuration is correct, this error should never ocure.

@MartinDelille
Copy link
Author

I would say it is an error for sure!

@latk
Copy link
Member
latk commented Feb 16, 2023

Gcovr has always ignored gcov errors (with this warning). When no gcov invocation works for a given input file, I'd agree that a hard error should be raised, instead of skipping that file.

Especially on large projects, there can be value in continuing with partial data. But especially in CI settings, warnings would go entirely unnoticed. Thus, I think errors that can be easily downgraded to warnings are sensible, just like we're treating unrecognized syntax in gcov files.

@Spacetown
Copy link
Member

@MartinDelille Can you check the behavior with the branch in the linked PR?

@MartinDelille
Copy link
Author

I'm using gcovr via pip so I wonder how to use a development branch since I'm not a python developer. I cloned the repo and checked out the branch so now what is the command line equivalent to running the local version of gcovr ?

@Spacetown
Copy link
Member

Run pip install git+https://github.com/Spacetown/gcovr.git@abort_on_processing_gcov_errors to install it directly from the git branch of my fork..

@MartinDelille
Copy link
Author

Here is my output:

$ gcovr --print-summary
(ERROR) GCOV produced the following errors processing /Users/martindelille/dev/tests/coverage-test/main.gcda:
	/Users/martindelille/dev/tests/coverage-test/main.gcno: No such file or directory

	(gcovr could not infer a working directory that resolved it.)
To ignore this error use option --gcov-ignore-errors=no_working_dir_found.
Traceback (most recent call last):
  File "/Users/martindelille/.pyenv/versions/3.10.9/lib/python3.10/site-packages/gcovr/workers.py", line 78, in worker
    work(*args, **kwargs)
  File "/Users/martindelille/.pyenv/versions/3.10.9/lib/python3.10/site-packages/gcovr/gcov.py", line 351, in process_datafile
    raise RuntimeError(errors_output)
RuntimeError: GCOV produced the following errors processing /Users/martindelille/dev/tests/coverage-test/main.gcda:
	/Users/martindelille/dev/tests/coverage-test/main.gcno: No such file or directory

	(gcovr could not infer a working directory that resolved it.)
To ignore this error use option --gcov-ignore-errors=no_working_dir_found.
Traceback (most recent call last):
  File "/Users/martindelille/.pyenv/versions/3.10.9/lib/python3.10/site-packages/gcovr/workers.py", line 78, in worker
    work(*args, **kwargs)
  File "/Users/martindelille/.pyenv/versions/3.10.9/lib/python3.10/site-packages/gcovr/gcov.py", line 351, in process_datafile
    raise RuntimeError(errors_output)
RuntimeError: GCOV produced the following errors processing /Users/martindelille/dev/tests/coverage-test/main.gcda:
	/Users/martindelille/dev/tests/coverage-test/main.gcno: No such file or directory

	(gcovr could not infer a working directory that resolved it.)
To ignore this error use option --gcov-ignore-errors=no_working_dir_found.
(ERROR) Uncaught EXCEPTION
Traceback (most recent call last):
  File "/Users/martindelille/.pyenv/versions/3.10.9/bin/gcovr", line 33, in <module>
    sys.exit(load_entry_point('gcovr==5.2', 'console_scripts', 'gcovr')())
  File "/Users/martindelille/.pyenv/versions/3.10.9/lib/python3.10/site-packages/gcovr/__main__.py", line 338, in main
    covdata = collect_coverage_from_gcov(options)
  File "/Users/martindelille/.pyenv/versions/3.10.9/lib/python3.10/site-packages/gcovr/__main__.py", line 390, in collect_coverage_from_gcov
    with Workers(
  File "/Users/martindelille/.pyenv/versions/3.10.9/lib/python3.10/site-packages/gcovr/workers.py", line 171, in __exit__
    self.wait()
  File "/Users/martindelille/.pyenv/versions/3.10.9/lib/python3.10/site-packages/gcovr/workers.py", line 162, in wait
    raise self.exceptions[0][1]
  File "/Users/martindelille/.pyenv/versions/3.10.9/lib/python3.10/site-packages/gcovr/__main__.py", line 397, in collect_coverage_from_gcov
    contexts = pool.wait()
  File "/Users/martindelille/.pyenv/versions/3.10.9/lib/python3.10/site-packages/gcovr/workers.py", line 162, in wait
    raise self.exceptions[0][1]
  File "/Users/martindelille/.pyenv/versions/3.10.9/lib/python3.10/site-packages/gcovr/workers.py", line 78, in worker
    work(*args, **kwargs)
  File "/Users/martindelille/.pyenv/versions/3.10.9/lib/python3.10/site-packages/gcovr/gcov.py", line 351, in process_datafile
    raise RuntimeError(errors_output)
RuntimeError: GCOV produced the following errors processing /Users/martindelille/dev/tests/coverage-test/main.gcda:
	/Users/martindelille/dev/tests/coverage-test/main.gcno: No such file or directory

	(gcovr could not infer a working directory that resolved it.)
To ignore this error use option --gcov-ignore-errors=no_working_dir_found.

Looks good to me!

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

Successfully merging a pull request may close this issue.

3 participants
0