LCOV 文件在“SF:”处有奇怪的路径
我正在使用 googletest 测试我的 cpp 应用程序,这些部分运行得很好。 为了构建并启动单元测试,我运行了一个小型 Powershell Skript。
cmake -G "Unix Makefiles" -S . -B ${BUILD_PATH}
cmake --build $BUILD_PATH
Set-Location $BUILD_PATH
./UnitTests
CMakeLists.txt 如下所示:
cmake_minimum_required(VERSION 3.14)
project(exampleProject)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS --coverage)
# GoogleTest
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
enable_testing()
# Testsources
file(GLOB_RECURSE TEST_SOURCES "./test/*.cc")
# Linking
# Add here the "inc" and "src" folder from the features
include_directories(
"./Example/inc"
"./Example/src"
"./test/Example/mock"
)
add_executable(
unittests
${TEST_SOURCES}
)
target_link_libraries(
unittests
gtest_main
gmock_main
)
include(GoogleTest)
# Run
gtest_discover_tests(unittests)
我的 .sh 脚本中的以下代码行在 MacO 上完美运行。
lcov --directory ${TEST_SOURCE_PATH} --capture --output-file ${LCOV_PATH_INFO} -rc lcov_branch_coverage=1
我将在另一个 Powershell 脚本中使用此代码在 Windows 计算机上执行相同的操作:
$LCOV = "C:\ProgramData\chocolatey\lib\lcov\tools\bin\lcov"
perl $LCOV --capture --directory ${TEST_SOURCE_PATH} --output-file ${LCOV_PATH_INFO}
当我运行这些脚本时,.info 文件在 SF 标签处具有存储路径,例如: SF:C:\dev\exampleProject\build\test\CMakeFiles\unittests.dir\test\Example\C:/Strawberry/c/lib/gcc/x86_64-w64-mingw32/8.3.0/include/c++/ext/ alloc_traits.h
Powershell 的 geninfo 告诉我他无法打开这些文件,这是合乎逻辑的。
那么为什么我会变成这些奇怪的路径呢?
谢谢。最佳后卫 丹尼尔
我读了很多关于这个的东西,但我没有找到解决方案。
i am testing my cpp Application with googletest and these part runs very good.
To build and start the Unit-Tests i run a small Powershell Skript.
cmake -G "Unix Makefiles" -S . -B ${BUILD_PATH}
cmake --build $BUILD_PATH
Set-Location $BUILD_PATH
./UnitTests
The CMakeLists.txt looks like this:
cmake_minimum_required(VERSION 3.14)
project(exampleProject)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS --coverage)
# GoogleTest
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
enable_testing()
# Testsources
file(GLOB_RECURSE TEST_SOURCES "./test/*.cc")
# Linking
# Add here the "inc" and "src" folder from the features
include_directories(
"./Example/inc"
"./Example/src"
"./test/Example/mock"
)
add_executable(
unittests
${TEST_SOURCES}
)
target_link_libraries(
unittests
gtest_main
gmock_main
)
include(GoogleTest)
# Run
gtest_discover_tests(unittests)
The following Line of Code in my .sh Script works on MacOs perfectly.
lcov --directory ${TEST_SOURCE_PATH} --capture --output-file ${LCOV_PATH_INFO} -rc lcov_branch_coverage=1
The same i will do on the Windows Machine with this Code in a another Powershell Script:
$LCOV = "C:\ProgramData\chocolatey\lib\lcov\tools\bin\lcov"
perl $LCOV --capture --directory ${TEST_SOURCE_PATH} --output-file ${LCOV_PATH_INFO}
When i run these Script then the .info File has strage Path at the SF-Tag For Example:
SF:C:\dev\exampleProject\build\test\CMakeFiles\unittests.dir\test\Example\C:/Strawberry/c/lib/gcc/x86_64-w64-mingw32/8.3.0/include/c++/ext/alloc_traits.h
The geninfo at the Powershell says me that he cant open these Files, which is logical.
So why i became these stange Paths?
Thank you. Best Guards
Daniel
I read many stuff about this but i found no Solution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所以我找到了一个带有Powershell脚本的解决方案。
所以效果很好。
So I found a Solution with a Powershell Script.
lcov.info
file.So it works well.