首页 > 解决方案 > 为什么我的 kcov 命令的 outdir 总是空的?

问题描述

所以,我需要将 kcov 集成到我的 gitlab-ci 中,以查看测试可执行文件的代码覆盖率。kcov 的文档指出我需要运行“kcov /path/to/outdir ./myexec”以在 html 文件中生成报告。但是,即使命令成功,/path/to/outdir 仍然是空的,我不知道为什么,因为测试通过并且 kcov 没有返回错误

这是.gitlab-ci.yml:

 stage: coverage
 dependencies:
  - Build
 script:
 - mkdir build/test/kcov
 - cd build/test
 - kcov --include-path=../../src /kcov ./abuse-test
 - cd kcov
 - ls
 artifacts:
  paths:
    - TP3/build
    - TP3/src

我的测试执行程序是滥用测试,它是通过 cmake->make 生成的,位于名为 TP3->build->test->abuse-test 的文件夹中

ci 中控制台的输出如下:

  on igl601-runner3 5d2b3c01
Using Docker executor with image depot.dinf.usherbrooke.ca:4567/e19-igl601/eq09/image_tp3 ...
Pulling docker image depot.dinf.usherbrooke.ca:4567/e19-igl601/eq09/image_tp3 ...
Using docker image sha256:c2cf0a7c10687670c7b28ee23ac06899de88ebb0d86e142bfbf65171147fc167 for depot.dinf.usherbrooke.ca:4567/e19-igl601/eq09/image_tp3 ...
Running on runner-5d2b3c01-project-223-concurrent-0 via dinf-prj-16...
Fetching changes...
Removing TP3/build/
HEAD is now at b2e1277 Update .gitlab-ci.yml
From https://depot.dinf.usherbrooke.ca/e19-igl601/eq09
   b2e1277..7cf0af5  master     -> origin/master
Checking out 7cf0af56 as master...
Skipping Git submodules setup
Downloading artifacts for Build (8552)...
Downloading artifacts from coordinator... ok        id=8552 responseStatus=200 OK token=Pagxjp_C
$ cd TP3
$ mkdir build/test/kcov
$ cd build/test
$ kcov --include-path=../../src /kcov ./abuse-test
===============================================================================
All tests passed (3 assertions in 3 test cases)

$ cd kcov
$ ls
Uploading artifacts...
TP3/build: found 2839 matching files               
TP3/src: found 211 matching files                  
Uploading artifacts to coordinator... ok            id=8554 responseStatus=201 Created token=PxDHHjxf
Job succeeded

kcov 文档指出:“/path/to/outdir 将包含应用程序运行时连续生成的 lcov 样式的 HTML 输出”

然而,当我浏览文物时,我什么也没找到

标签: dockergitlab-cikcov

解决方案


嗨,看起来您正在指定/kcov为 outdir:

kcov --include-path=../../src /kcov ./abuse-test

由于您正在使用基于 *nix 的系统,这/意味着从文件系统的根目录开始的绝对路径。

cd kcov步骤假定一个相对路径(从当前目录向下),因为它缺少/.

所以我想将您的kcov命令更改为:

kcov --include-path=../../src kcov ./abuse-test

会解决你的问题。


推荐阅读