coveralls-cmake icon indicating copy to clipboard operation
coveralls-cmake copied to clipboard

Fix relative paths

Open konserw opened this issue 7 years ago • 5 comments

In case of cucumber-cpp project sometimes ${GCOV_SRC_PATH} is not an absolute path, for example: ^/include/cucumber-cpp/internal/drivers/GTestDriver.hpp gmock/src/gmock/googletest/include/gtest/gtest.h This fix is sufficient for cucumber-cpp, but I'm not sure if it covers all possible paths.

konserw avatar Mar 31 '17 14:03 konserw

Hello,

Just so I understand you correctly. How I understand this:

The original code:

	#
	# /path/to/project/root/build/#path#to#project#root#subdir#the_file.c.gcov
	# ->
	# /path/to/project/root/subdir/the_file.c
	get_source_path_from_gcov_filename(GCOV_SRC_PATH ${GCOV_FILE})

So instead of something like this:

/path/to/project/root/build/#path#to#project#root#subdir#the_file.c.gcov

you get this?:

/path/to/project/root/build/^subdir#the_file.c.gcov
`` 

It would be nice to get an example of some exact output you're getting from your debug messages so I understand the problem exactly.

JoakimSoderberg avatar Apr 02 '17 20:04 JoakimSoderberg

It was a long time since I looked at this code so I'm trying to refresh my mind a bit.

https://github.com/konserw/coveralls-cmake/blob/4849cfab90578818bdd1e34619c52b1dc323dea2/cmake/CoverallsGenerateGcov.cmake#L154-L174

#
# This macro converts from the full path format gcov outputs:
#
#    /path/to/project/root/build/#path#to#project#root#subdir#the_file.c.gcov
#
# to the original source file path the .gcov is for:
#
#   /path/to/project/root/subdir/the_file.c
#
macro(get_source_path_from_gcov_filename _SRC_FILENAME _GCOV_FILENAME)

	# /path/to/project/root/build/#path#to#project#root#subdir#the_file.c.gcov
	# ->
	# #path#to#project#root#subdir#the_file.c.gcov
	get_filename_component(_GCOV_FILENAME_WEXT ${_GCOV_FILENAME} NAME)

	# #path#to#project#root#subdir#the_file.c.gcov -> /path/to/project/root/subdir/the_file.c
	string(REGEX REPLACE "\\.gcov$" "" SRC_FILENAME_TMP ${_GCOV_FILENAME_WEXT})
	string(REGEX REPLACE "\#" "/" SRC_FILENAME_TMP ${SRC_FILENAME_TMP})
	set(${_SRC_FILENAME} "${SRC_FILENAME_TMP}")
endmacro()

Because I'm wondering it this would belong better in this macro maybe?

JoakimSoderberg avatar Apr 02 '17 21:04 JoakimSoderberg

Forgot to thank you for the patch, just want to understand the issue before I merge so nothing gets broken :)

JoakimSoderberg avatar Apr 02 '17 21:04 JoakimSoderberg

Now I've pushed most of my changes. Let me know if you want it all.

konserw avatar Apr 05 '17 20:04 konserw

@konserw ok, good that you pushed the latest.

It would be nice with your exact debug output so I can see exactly what you are getting when you are building.

And maybe the version of gcov that is producing this form? So that I can test myself with the same project, and can test a few scenarios if this breaks or not (for example using a non-standard build dir as I mentioned)

JoakimSoderberg avatar Apr 06 '17 16:04 JoakimSoderberg