为什么gcov不报告我的单元测试覆盖的任何行? [英] Why doesn't gcov report any lines being covered by my unit tests?

查看:290
本文介绍了为什么gcov不报告我的单元测试覆盖的任何行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在10.6上使用Xcode 3.2,发布版本的gcov和默认的GCC编译器(版本4.2.1)。我创建了一个依赖的Cocoa单元测试包,它被注入到我的应用程序,并遵循Apple的文档设置gcov测试版本配置 - 基于未启用任何编译器优化的Debug配置。

I am using Xcode 3.2 on 10.6, with the shipped version of gcov and default GCC compiler (both version 4.2.1). I have created a dependent Cocoa unit test bundle which is injected into my app, and followed Apple's documentation on setting up a gcov-instrumented build configuration - based on the Debug configuration which doesn't have any compiler optimisations enabled.

当我使用这种Gcov-instrumented配置来构建测试包,应用程序启动并且测试被注入并运行。此外,覆盖率统计文件还生成于:

When I build the test bundle with this 'Gcov-instrumented' configuration, the app launches and the tests are injected and run. Also the coverage statistics files are generated at:


build /< AppTarget> .build / Gcov-instrumented / < AppTarget> .build / Objects-normal / x86_64 /< object> .gcda

build / ; AppTarget> .build / Gcov-instrumented /< AppTarget> .build / Objects-normal / x86_64 /< object> .gcno

到目前为止很好。我知道测试真正运行,因为如果我插入失败,那么测试套件失败,如预期。不幸的是,gcov报告没有对象的行被测试覆盖!每行都报告为0覆盖。我在这里搜索和在苹果邮件列表存档,并找不到有类似问题的任何人。我希望我错过了一些东西 - 但是是什么?

So far so good. I know the tests are really being run because if I insert failures then the test suite fails as expected. Unfortunately, gcov reports that no lines of the objects have been covered by the tests! Every line is reported as 0 coverage. I've searched here and at the Apple mailing list archives, and can't find anyone with a similar problem. I expect I'm missing something - but what is it?

推荐答案

我绊倒了一段很长的幸运时间,那里是主要工作在我的主要项目。通过大多数工作,我的意思是我能够得到覆盖显示,但有一点疼痛比10.5。我不得不积极地删除覆盖文件和重建,以获得任何更新,例如。即使在我的勉强工作状态,编译器/运行时似乎不愿意覆盖现有的覆盖数据文件。

I have been running into this problem intermittently. I stumbled into a good length of lucky time where it was "mostly working" in my main project. By mostly working I mean I was able to get coverage to show up, but with a little more pain than on 10.5. I had to aggressively delete the coverage files and rebuild in order to get any updates, for instance. Even in my "barely working" state, the compiler/runtime doesn't seem willing to overwrite an existing coverage data file.

我想我偶然发现工作场景。 Voodoo肯定不太理想:

I think I've stumbled back on to a working scenario. Voodoo for sure, and less than ideal:


  1. 确保SDK为10.6。

  2. 确保部署设置为gcc 4.0(!)。

  3. 对项目进行完全清理。

  4. 重建。

  1. Make sure the SDK is 10.6.
  2. Make sure the deployment is set to gcc 4.0 (!).
  3. Do a full clean of the project.
  4. Rebuild.

这是否能获得预期的保障数据?

Does this get you the expected coverage data?

授予,我希望能够生成使用gcc 4.2或LLVM编译器工作的覆盖文件,但是目前这似乎让我比以前的工作负担更少。

Granted, I would expect to be able to generate coverage files that work using gcc 4.2 or one of the LLVM compilers, but for the moment this seems to have me slightly less crippled than before.

另一个线索:当我观察覆盖率数据(使用Google的封面故事),我会收到以下警告:

Another clue: when I observe the coverage data (using Google's Cover Story), I get warnings like:


/BUILDRESULTS/MarsEdit.build/Code Coverage / MarsEditDataModelTests.build / Objects-normal / i386 / MEDataItem.gcno:version'400A' 402 *'

/BUILDRESULTS/MarsEdit.build/Code Coverage/MarsEditDataModelTests.build/Objects-normal/i386/MEDataItem.gcno:version '400A', prefer '402*'

但是覆盖率信息仍然显示。所以看起来它在旧的覆盖格式版本,但如果我使用较新的编译器(4.2),可能会生成较新的格式 .gcno 文件,0%覆盖问题困扰我,因为它和Graham。

But the coverage information is still presented. So it seems it's balking at an older coverage format version, but if I use the newer compiler (4.2) which would presumably generate the newer format .gcno files, the 0% coverage problem plagues me as it does Graham.

这篇关于为什么gcov不报告我的单元测试覆盖的任何行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆