2016-06-07 112 views
3

我想在我的項目上運行覆蓋後,更新到Ubuntu 16.04。 我得到錯誤,而代碼覆蓋率報告使用lcov

Deleted 665 files 
Writing data to coverage.info.cleaned 
lcov: ERROR: cannot write to coverage.info.cleaned! 
CMakeFiles/coverage.dir/build.make:57: recipe for target 'CMakeFiles/coverage' failed 
make[3]: *** [CMakeFiles/coverage] Error 13 
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/coverage.dir/all' failed 
make[2]: *** [CMakeFiles/coverage.dir/all] Error 2 
CMakeFiles/Makefile2:74: recipe for target 'CMakeFiles/coverage.dir/rule' failed 
make[1]: *** [CMakeFiles/coverage.dir/rule] Error 2 
Makefile:129: recipe for target 'coverage' failed 
make: *** [coverage] Error 2 
enter code here 

更新我沒有問題,運行覆蓋

+0

你有沒有試過'做乾淨'? – Gluttton

+0

當然,我甚至重新覆蓋目錄 – Ortal

+2

發現問題,在我的情況最後我已經刪除了所有不必要的輸出,並重新將它們寫入不同的文件。在更新到16.04之後,寫入新數據的新位置位於根目錄下。它通過設置新目標來修復 – Ortal

回答

3

它是否幫助,如果你傳遞文件lcov時使用絕對路徑,而不是相對路徑之前?

我遇到了一個類似的問題,其中lcov也無法寫入文件。 不知道這是在lcov一個錯誤,但問題是,它糊塗了相對路徑:

lcov -a test_fast_cxxtest_gcov__base.info -a test_fast_cxxtest_gcov__test.info \ 
    -o test_fast_cxxtest_gcov__total.info 
Combining tracefiles. 
Reading tracefile test_fast_cxxtest_gcov__base.info 
Reading tracefile test_fast_cxxtest_gcov__test.info 
lcov: WARNING: function data mismatch at /home/phil/ghost/constants.h:1862 
Writing data to test_fast_cxxtest_gcov__total.info 
lcov: ERROR: cannot write to test_fast_cxxtest_gcov__total.info! 

strace運行它顯露它的多個位置執行chdir("/"),從而改變工作目錄/ 。這就解釋了爲什麼它不能寫入文件。

一種解決方法是使用絕對路徑。舉例來說,如果你正在使用GNU化妝,你可以使用abspath命令:

lcov -a $(abspath test_fast_cxxtest_gcov__base.info) \ 
    -a $(abspath test_fast_cxxtest_gcov__test.info) \ 
    -o $(abspath test_fast_cxxtest_gcov__total.info) 

這種變化之後,終於能夠寫入文件。

(其他選項,如想使用--base-directory--directory選項沒有效果設置目錄,據我所看到的。 的lcov的版本,我是1.12的測試。)

問題並不限於Ubuntu,因爲我在Arch Linux上遇到了它。這可能是1.12引入的迴歸,但是,我報告了它(請參閱issue #77630)。

更新: Lcov不是GCC的一部分,所以我的原始錯誤報告已經關閉,但我從Lcov郵件列表中得到了一個答案。該問題已經在承諾632c25中得到解決。基於Arch Linux的發行版的用戶可以使用aur/lcov-git來嘗試最新的快照。

相關問題