我已成功设置了一个autotools项目,其中测试使用仪器进行编译,因此我可以获得测试覆盖率报告。
我可以在成功进行'make check'后在源目录中运行lcov来获取报告。
我现在面临的问题是我要自动执行此步骤。我想将此添加到'make check'或将其作为单独的目标'make check-coverage'。理想情况下,我想解析结果,如果覆盖率低于某个百分比则会失败。问题是我根本无法弄清楚如何添加自定义目标。
我最接近的是找到this示例autotools配置,但我看不到该项目中的目标'make lcov'被添加。我只能在m4 / auxdevel.m4中看到一些配置标志。
任何提示?
答案 0 :(得分:6)
你显然可以在Makefile.am中为目标添加额外的步骤,这就是我最终的结果(灵感来自#http://www.enlightenment.org/svn/e/trunk/ewl/Makefile.am ):
#http://www.enlightenment.org/svn/e/trunk/ewl/Makefile.am
if ENABLE_COV
cov-reset:
@rm -fr coverage
@find . -name "*.gcda" -exec rm {} \;
@lcov --directory . --zerocounters
cov-report:
@mkdir -p coverage
@lcov --compat-libtool --directory . --capture --output-file coverage/app.info
@genhtml -o coverage/ coverage/app.info
cov:
@make cov-report
clean-local:
@make cov-reset
check:
@make cov
endif
正在检查的'@make cov'会将'cov'目标添加到默认的'make check'目标。