Skip to content
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

Code coverage error with Catch2 #16

Open
petsal96 opened this issue Jan 12, 2025 · 1 comment
Open

Code coverage error with Catch2 #16

petsal96 opened this issue Jan 12, 2025 · 1 comment

Comments

@petsal96
Copy link

Hello,

I get the following error when trying to run the coverage target (output from GitHub actions build after creating a new respository from the template):

...
[ 98%] Built target UnitTestFoo
[ 98%] Built target UnitTestBar
[100%] Running gcovr to produce HTML code coverage report.
Test project /home/runner/work/UdemyCpp/UdemyCpp/build
    Start 1: factorial1
1/4 Test #1: factorial1 .......................   Passed    0.01 sec
    Start 2: helloworld1
2/4 Test #2: helloworld1 ......................   Passed    0.01 sec
    Start 3: sum1
3/4 Test #3: sum1 .............................   Passed    0.01 sec
    Start 4: branch1
4/4 Test #4: branch1 ..........................   Passed    0.01 sec

100% tests passed, 0 tests failed out of 4

Total Test time (real) =   0.12 sec
(INFO) Reading coverage data...

(ERROR) GCOV produced the following errors processing /home/runner/work/UdemyCpp/UdemyCpp/build/_deps/catch2-build/src/CMakeFiles/Catch2.dir/catch2/internal/catch_leak_detector.cpp.gcda:
	In directory /home/runner/work/UdemyCpp/UdemyCpp/build/_deps/catch2-build/src/CMakeFiles/Catch2.dir/catch2/internal/.:
Cannot open source file src/catch2/internal/catch_leak_detector.cpp

	In directory /home/runner/work/UdemyCpp/UdemyCpp/build/.:
Cannot open source file src/catch2/internal/catch_leak_detector.cpp

	In directory /home/runner/work/UdemyCpp/UdemyCpp:
Cannot open source file src/catch2/internal/catch_leak_detector.cpp

	(gcovr could not infer a working directory that resolved it.)
To ignore this error use option --gcov-ignore-errors=no_working_dir_found.
Error: (ERROR) GCOV produced the following errors processing /home/runner/work/UdemyCpp/UdemyCpp/build/_deps/catch2-build/src/CMakeFiles/Catch2.dir/catch2/internal/catch_leak_detector.cpp.gcda:
	In directory /home/runner/work/UdemyCpp/UdemyCpp/build/_deps/catch2-build/src/CMakeFiles/Catch2.dir/catch2/internal/.:
Cannot open source file src/catch2/internal/catch_leak_detector.cpp

	In directory /home/runner/work/UdemyCpp/UdemyCpp/build/.:
Cannot open source file src/catch2/internal/catch_leak_detector.cpp

	In directory /home/runner/work/UdemyCpp/UdemyCpp:
Cannot open source file src/catch2/internal/catch_leak_detector.cpp

	(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 "/home/runner/.local/lib/python3.12/site-packages/gcovr/formats/gcov/workers.py", line 81, in worker
    work(*args, **kwargs)
  File "/home/runner/.local/lib/python3.12/site-packages/gcovr/formats/gcov/read.py", line 597, in process_datafile
    raise RuntimeError(errors_output)
RuntimeError: GCOV produced the following errors processing /home/runner/work/UdemyCpp/UdemyCpp/build/_deps/catch2-build/src/CMakeFiles/Catch2.dir/catch2/internal/catch_leak_detector.cpp.gcda:
	In directory /home/runner/work/UdemyCpp/UdemyCpp/build/_deps/catch2-build/src/CMakeFiles/Catch2.dir/catch2/internal/.:
Cannot open source file src/catch2/internal/catch_leak_detector.cpp

	In directory /home/runner/work/UdemyCpp/UdemyCpp/build/.:
Cannot open source file src/catch2/internal/catch_leak_detector.cpp

	In directory /home/runner/work/UdemyCpp/UdemyCpp:
Cannot open source file src/catch2/internal/catch_leak_detector.cpp

	(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 "/home/runner/.local/lib/python3.12/site-packages/gcovr/formats/gcov/workers.py", line 81, in worker
    work(*args, **kwargs)
  File "/home/runner/.local/lib/python3.12/site-packages/gcovr/formats/gcov/read.py", line 597, in process_datafile
    raise RuntimeError(errors_output)
RuntimeError: GCOV produced the following errors processing /home/runner/work/UdemyCpp/UdemyCpp/build/_deps/catch2-build/src/CMakeFiles/Catch2.dir/catch2/internal/catch_leak_detector.cpp.gcda:
	In directory /home/runner/work/UdemyCpp/UdemyCpp/build/_deps/catch2-build/src/CMakeFiles/Catch2.dir/catch2/internal/.:
Cannot open source file src/catch2/internal/catch_leak_detector.cpp

	In directory /home/runner/work/UdemyCpp/UdemyCpp/build/.:
Cannot open source file src/catch2/internal/catch_leak_detector.cpp

	In directory /home/runner/work/UdemyCpp/UdemyCpp:
Cannot open source file src/catch2/internal/catch_leak_detector.cpp

	(gcovr could not infer a working directory that resolved it.)
To ignore this error use option --gcov-ignore-errors=no_working_dir_found.
(ERROR) Error occurred while reading reports:
Traceback (most recent call last):
  File "/home/runner/.local/lib/python3.12/site-packages/gcovr/__main__.py", line 358, in main
    covdata: CovData = gcovr_formats.read_reports(options)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/.local/lib/python3.12/site-packages/gcovr/formats/__init__.py", line 85, in read_reports
    covdata = GcovHandler(options).read_report()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/.local/lib/python3.12/site-packages/gcovr/formats/gcov/__init__.py", line 215, in read_report
    return read_report(self.options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/.local/lib/python3.12/site-packages/gcovr/formats/gcov/read.py", line 96, in read_report
    with Workers(
  File "/home/runner/.local/lib/python3.12/site-packages/gcovr/formats/gcov/workers.py", line 177, in __exit__
    self.wait()
  File "/home/runner/.local/lib/python3.12/site-packages/gcovr/formats/gcov/workers.py", line 168, in wait
    raise self.exceptions[0][1]
  File "/home/runner/.local/lib/python3.12/site-packages/gcovr/formats/gcov/read.py", line 103, in read_report
    contexts = pool.wait()
               ^^^^^^^^^^^
  File "/home/runner/.local/lib/python3.12/site-packages/gcovr/formats/gcov/workers.py", line 168, in wait
    raise self.exceptions[0][1]
  File "/home/runner/.local/lib/python3.12/site-packages/gcovr/formats/gcov/workers.py", line 81, in worker
    work(*args, **kwargs)
  File "/home/runner/.local/lib/python3.12/site-packages/gcovr/formats/gcov/read.py", line 597, in process_datafile
    raise RuntimeError(errors_output)
RuntimeError: GCOV produced the following errors processing /home/runner/work/UdemyCpp/UdemyCpp/build/_deps/catch2-build/src/CMakeFiles/Catch2.dir/catch2/internal/catch_leak_detector.cpp.gcda:
	In directory /home/runner/work/UdemyCpp/UdemyCpp/build/_deps/catch2-build/src/CMakeFiles/Catch2.dir/catch2/internal/.:
Cannot open source file src/catch2/internal/catch_leak_detector.cpp

	In directory /home/runner/work/UdemyCpp/UdemyCpp/build/.:
Cannot open source file src/catch2/internal/catch_leak_detector.cpp

	In directory /home/runner/work/UdemyCpp/UdemyCpp:
Cannot open source file src/catch2/internal/catch_leak_detector.cpp

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

GCOV produced the following errors processing /home/runner/work/UdemyCpp/UdemyCpp/build/_deps/catch2-build/src/CMakeFiles/Catch2.dir/catch2/internal/catch_leak_detector.cpp.gcda:
	In directory /home/runner/work/UdemyCpp/UdemyCpp/build/_deps/catch2-build/src/CMakeFiles/Catch2.dir/catch2/internal/.:
Cannot open source file src/catch2/internal/catch_leak_detector.cpp

	In directory /home/runner/work/UdemyCpp/UdemyCpp/build/.:
Cannot open source file src/catch2/internal/catch_leak_detector.cpp

	In directory /home/runner/work/UdemyCpp/UdemyCpp:
Cannot open source file src/catch2/internal/catch_leak_detector.cpp

	(gcovr could not infer a working directory that resolved it.)
To ignore this error use option --gcov-ignore-errors=no_working_dir_found.
Error: (ERROR) Error occurred while reading reports:
Traceback (most recent call last):
  File "/home/runner/.local/lib/python3.12/site-packages/gcovr/__main__.py", line 358, in main
    covdata: CovData = gcovr_formats.read_reports(options)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/.local/lib/python3.12/site-packages/gcovr/formats/__init__.py", line 85, in read_reports
    covdata = GcovHandler(options).read_report()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/.local/lib/python3.12/site-packages/gcovr/formats/gcov/__init__.py", line 215, in read_report
    return read_report(self.options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/.local/lib/python3.12/site-packages/gcovr/formats/gcov/read.py", line 96, in read_report
    with Workers(
  File "/home/runner/.local/lib/python3.12/site-packages/gcovr/formats/gcov/workers.py", line 177, in __exit__
    self.wait()
  File "/home/runner/.local/lib/python3.12/site-packages/gcovr/formats/gcov/workers.py", line 168, in wait
    raise self.exceptions[0][1]
  File "/home/runner/.local/lib/python3.12/site-packages/gcovr/formats/gcov/read.py", line 103, in read_report
    contexts = pool.wait()
               ^^^^^^^^^^^
  File "/home/runner/.local/lib/python3.12/site-packages/gcovr/formats/gcov/workers.py", line 168, in wait
    raise self.exceptions[0][1]
  File "/home/runner/.local/lib/python3.12/site-packages/gcovr/formats/gcov/workers.py", line 81, in worker
    work(*args, **kwargs)
  File "/home/runner/.local/lib/python3.12/site-packages/gcovr/formats/gcov/read.py", line 597, in process_datafile
    raise RuntimeError(errors_output)
RuntimeError: GCOV produced the following errors processing /home/runner/work/UdemyCpp/UdemyCpp/build/_deps/catch2-build/src/CMakeFiles/Catch2.dir/catch2/internal/catch_leak_detector.cpp.gcda:
	In directory /home/runner/work/UdemyCpp/UdemyCpp/build/_deps/catch2-build/src/CMakeFiles/Catch2.dir/catch2/internal/.:
Cannot open source file src/catch2/internal/catch_leak_detector.cpp

	In directory /home/runner/work/UdemyCpp/UdemyCpp/build/.:
Cannot open source file src/catch2/internal/catch_leak_detector.cpp

	In directory /home/runner/work/UdemyCpp/UdemyCpp:
Cannot open source file src/catch2/internal/catch_leak_detector.cpp

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

GCOV produced the following errors processing /home/runner/work/UdemyCpp/UdemyCpp/build/_deps/catch2-build/src/CMakeFiles/Catch2.dir/catch2/internal/catch_leak_detector.cpp.gcda:
	In directory /home/runner/work/UdemyCpp/UdemyCpp/build/_deps/catch2-build/src/CMakeFiles/Catch2.dir/catch2/internal/.:
Cannot open source file src/catch2/internal/catch_leak_detector.cpp

	In directory /home/runner/work/UdemyCpp/UdemyCpp/build/.:
Cannot open source file src/catch2/internal/catch_leak_detector.cpp

	In directory /home/runner/work/UdemyCpp/UdemyCpp:
Cannot open source file src/catch2/internal/catch_leak_detector.cpp

	(gcovr could not infer a working directory that resolved it.)
To ignore this error use option --gcov-ignore-errors=no_working_dir_found.
gmake[3]: *** [tests/CMakeFiles/coverage.dir/build.make:74: tests/CMakeFiles/coverage] Error 64
gmake[2]: *** [CMakeFiles/Makefile2:[157](https://github.com/petsal96/UdemyCpp/actions/runs/12634610098/job/35202720831#step:7:158)4: tests/CMakeFiles/coverage.dir/all] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:[158](https://github.com/petsal96/UdemyCpp/actions/runs/12634610098/job/35202720831#step:7:159)1: tests/CMakeFiles/coverage.dir/rule] Error 2
gmake: *** [Makefile:660: coverage] Error 2
Error: Process completed with exit code 2.
@franneck94
Copy link
Owner

Hi, the error log suggest to add this flag to the gcov exectuion:

--gcov-ignore-errors=no_working_dir_found

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

No branches or pull requests

2 participants