问题
Using gcovr 3.2 I am trying to generate a code coverage report for a set unit tests that I have developed and run using Xcode 5.0.
I have successfully configured Xcode to generate the .gcda files following the execution of the tests and I am able to view the results using CoverStory.
However, when I try to generate a report using gcovr nothing is generated. With the verbose switch on I can see that it scans the directory for the gcda/gcno files and finds the one I'm expecting it to. I've tried various switches and putting the files in different directories without any luck.
A similar question was asked here Gcovr generates coverage data for 0 files but no solution has been posted. I have provided more detail in the hope I get a response.
This is the output I get.
$ ls
t1-map.d t1-map.dia t1-map.gcda t1-map.gcno t1-map.o
$ gcovr -v -r .
Scanning directory . for gcda/gcno files...
Found 2 files (and will process 1)
Running gcov: 'gcov /Users/Test/temp/coverage/t1-map.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory /Users/Test/temp/coverage' in '/Users/Test/temp/coverage'
Parsing coverage data for file /Users/Test/dev/boost/boost/system/error_code.hpp
Filtering coverage data for file /Users/Test/dev/boost/boost/system/error_code.hpp
Parsing coverage data for file /Users/Test/dev/boost/boost/system/system_error.hpp
Filtering coverage data for file /Users/Test/dev/boost/boost/system/system_error.hpp
Parsing coverage data for file /Users/Test/dev/analysis-pipeline/analysis-services/src/t1-map.cpp
Filtering coverage data for file /Users/Test/dev/analysis-pipeline/analysis-services/src/t1-map.cpp
Parsing coverage data for file /Users/Test/dev/boost/boost/variant/variant.hpp
Filtering coverage data for file /Users/Test/dev/boost/boost/variant/variant.hpp
Parsing coverage data for file /Users/Test/dev/boost/boost/aligned_storage.hpp
Filtering coverage data for file /Users/Test/dev/boost/boost/aligned_storage.hpp
Parsing coverage data for file /Users/Test/dev/boost/boost/variant/static_visitor.hpp
Filtering coverage data for file /Users/Test/dev/boost/boost/variant/static_visitor.hpp
Parsing coverage data for file /Users/Test/dev/boost/boost/variant/detail/visitation_impl.hpp
Filtering coverage data for file /Users/Test/dev/boost/boost/variant/detail/visitation_impl.hpp
Parsing coverage data for file /Users/Test/dev/boost/boost/variant/detail/cast_storage.hpp
Filtering coverage data for file /Users/Test/dev/boost/boost/variant/detail/cast_storage.hpp
Parsing coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/memory
Filtering coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/memory
Parsing coverage data for file /Users/Test/dev/boost/boost/variant/detail/initializer.hpp
Filtering coverage data for file /Users/Test/dev/boost/boost/variant/detail/initializer.hpp
Parsing coverage data for file /Users/Test/dev/analysis-pipeline/common/include/common/lm-fitter.inl
Filtering coverage data for file /Users/Test/dev/analysis-pipeline/common/include/common/lm-fitter.inl
Parsing coverage data for file /Users/Test/development/software/utilities/include/utilities/numerical-recipes/utilities.h
Filtering coverage data for file /Users/Test/development/software/utilities/include/utilities/numerical-recipes/utilities.h
Parsing coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/iosfwd
Filtering coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/iosfwd
Parsing coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/sstream
Filtering coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/sstream
Parsing coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/string
Filtering coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/string
Parsing coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/streambuf
Filtering coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/streambuf
Parsing coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/algorithm
Filtering coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/algorithm
Parsing coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/type_traits
Filtering coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/type_traits
Parsing coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/iterator
Filtering coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/iterator
Parsing coverage data for file /Users/Test/dev/boost/boost/log/utility/formatting_ostream.hpp
Filtering coverage data for file /Users/Test/dev/boost/boost/log/utility/formatting_ostream.hpp
Parsing coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/ios
Filtering coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/ios
Parsing coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/__locale
Filtering coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/__locale
Parsing coverage data for file /Users/Test/dev/boost/boost/log/detail/attachable_sstream_buf.hpp
Filtering coverage data for file /Users/Test/dev/boost/boost/log/detail/attachable_sstream_buf.hpp
Parsing coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/ostream
Filtering coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/ostream
Parsing coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/locale
Filtering coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/locale
Parsing coverage data for file /Users/Test/development/software/utilities/include/utilities/numerical-recipes/mrqmin.inl
Filtering coverage data for file /Users/Test/development/software/utilities/include/utilities/numerical-recipes/mrqmin.inl
Parsing coverage data for file /Users/Test/development/software/utilities/include/utilities/numerical-recipes/mrqcof.inl
Filtering coverage data for file /Users/Test/development/software/utilities/include/utilities/numerical-recipes/mrqcof.inl
Parsing coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/cmath
Filtering coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/cmath
Parsing coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/vector
Filtering coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/vector
Parsing coverage data for file /Users/Test/dev/boost/boost/log/utility/string_literal.hpp
Filtering coverage data for file /Users/Test/dev/boost/boost/log/utility/string_literal.hpp
Parsing coverage data for file /Users/Test/dev/boost/boost/variant/get.hpp
Filtering coverage data for file /Users/Test/dev/boost/boost/variant/get.hpp
Parsing coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/exception
Filtering coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/exception
Parsing coverage data for file /Users/Test/dev/boost/boost/throw_exception.hpp
Filtering coverage data for file /Users/Test/dev/boost/boost/throw_exception.hpp
Parsing coverage data for file /Users/Test/dev/boost/boost/exception/exception.hpp
Filtering coverage data for file /Users/Test/dev/boost/boost/exception/exception.hpp
Parsing coverage data for file /Users/Test/dev/boost/boost/utility/addressof.hpp
Filtering coverage data for file /Users/Test/dev/boost/boost/utility/addressof.hpp
Parsing coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/__split_buffer
Filtering coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/__split_buffer
Parsing coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/limits
Filtering coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/limits
Parsing coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/typeinfo
Filtering coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/typeinfo
Parsing coverage data for file /Users/Test/dev/boost/boost/log/sources/record_ostream.hpp
Filtering coverage data for file /Users/Test/dev/boost/boost/log/sources/record_ostream.hpp
Parsing coverage data for file /Users/Test/dev/boost/boost/move/utility.hpp
Filtering coverage data for file /Users/Test/dev/boost/boost/move/utility.hpp
Parsing coverage data for file /Users/Test/dev/boost/boost/log/sources/basic_logger.hpp
Filtering coverage data for file /Users/Test/dev/boost/boost/log/sources/basic_logger.hpp
Parsing coverage data for file /Users/Test/dev/boost/boost/log/core/core.hpp
Filtering coverage data for file /Users/Test/dev/boost/boost/log/core/core.hpp
Parsing coverage data for file /Users/Test/dev/boost/boost/smart_ptr/shared_ptr.hpp
Filtering coverage data for file /Users/Test/dev/boost/boost/smart_ptr/shared_ptr.hpp
Parsing coverage data for file /Users/Test/dev/boost/boost/log/detail/locks.hpp
Filtering coverage data for file /Users/Test/dev/boost/boost/log/detail/locks.hpp
Parsing coverage data for file /Users/Test/dev/boost/boost/log/core/record.hpp
Filtering coverage data for file /Users/Test/dev/boost/boost/log/core/record.hpp
Parsing coverage data for file /Users/Test/dev/boost/boost/log/sources/threading_models.hpp
Filtering coverage data for file /Users/Test/dev/boost/boost/log/sources/threading_models.hpp
Parsing coverage data for file /Users/Test/dev/boost/boost/log/detail/light_rw_mutex.hpp
Filtering coverage data for file /Users/Test/dev/boost/boost/log/detail/light_rw_mutex.hpp
Parsing coverage data for file /Users/Test/dev/boost/boost/log/sources/severity_feature.hpp
Filtering coverage data for file /Users/Test/dev/boost/boost/log/sources/severity_feature.hpp
Parsing coverage data for file /Users/Test/dev/boost/boost/parameter/keyword.hpp
Filtering coverage data for file /Users/Test/dev/boost/boost/parameter/keyword.hpp
Parsing coverage data for file /Users/Test/dev/boost/boost/parameter/aux_/default.hpp
Filtering coverage data for file /Users/Test/dev/boost/boost/parameter/aux_/default.hpp
Parsing coverage data for file /Users/Test/dev/boost/boost/parameter/aux_/tagged_argument.hpp
Filtering coverage data for file /Users/Test/dev/boost/boost/parameter/aux_/tagged_argument.hpp
Parsing coverage data for file /Users/Test/dev/boost/boost/log/attributes/named_scope.hpp
Filtering coverage data for file /Users/Test/dev/boost/boost/log/attributes/named_scope.hpp
Parsing coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/stdexcept
Filtering coverage data for file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/stdexcept
Gathered coveraged data for 0 files
------------------------------------------------------------------------------
GCC Code Coverage Report
Directory: .
------------------------------------------------------------------------------
File Lines Exec Cover Missing
------------------------------------------------------------------------------
------------------------------------------------------------------------------
TOTAL 0 0 --%
------------------------------------------------------------------------------
回答1:
For anyone that might be interested I figured it out eventually.
From the directory /Users/Test/development I entered the following command:
gcovr --html --html-details -o output-file-name.html -v -g -k -r ~/development/ .
The source files are located in various directories under '~/development/'. It would appear that in my earlier attempts the source files could not be found.
回答2:
Check this post
GCOVR giving empty results zero percent in MAC
来源:https://stackoverflow.com/questions/25403165/cant-get-gcovr-to-generate-coverage-data