代码之家  ›  专栏  ›  技术社区  ›  Alexander Torstling

“make check”后自动调用lcov

  •  4
  • Alexander Torstling  · 技术社区  · 15 年前

    我已经成功地建立了一个autotools项目,在这个项目中,测试使用工具进行编译,这样我就可以得到一个测试覆盖率报告。

    我可以通过在成功的“make check”之后在source dir中运行lcov来获取报告。

    我现在面临的问题是,我想自动化这一步骤。我想将此添加到“检查”中,或者将其作为单独的目标“检查覆盖范围”。理想情况下,我希望解析结果,如果覆盖率低于某个百分比,则会失败。问题是我根本不知道如何添加自定义目标。

    我最近的发现是 this 示例autotools配置,但我看不到在该项目中添加目标“make lcov”的位置。我只能在m4/auxdevel.m4中看到一些配置标志。

    有什么小窍门吗?

    1 回复  |  直到 11 年前
        1
  •  6
  •   Alexander Torstling    15 年前

    很明显,你可以在makefile.am中为目标添加额外的步骤,这就是我的最终目的(灵感来源于http://www.importation.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”目标。