linux-test-project / lcov

LCOV
GNU General Public License v2.0
894 stars 240 forks source link

genhtml: ERROR: cannot read an inexistent path #158

Closed paintedveil5 closed 1 year ago

paintedveil5 commented 2 years ago

I performed a coverage test on Javascript engine ChakraCore. Nothing wrong with running of lcov, which command is

 lcov --capture --directory ./ --no-external --rc lcov_branch_coverage=1 --output-file src_coverage.info

genhtml execution failed with an error. command:

genhtml -o result-1 src_coverage.info

error information:

genhtml: ERROR: cannot read /home/ubuntu/Desktop/ChakraCore/ChakraCore-master/out/Debug/lib/wabt/CMakeFiles/libwabt.dir/src/prebuilt/src/wast-lexer.cc

The path /home/ubuntu/Desktop/ChakraCore/ChakraCore-master/out/Debug/lib/wabt/CMakeFiles/libwabt.dir/src/prebuilt/src/wast-lexer.cc does not exist.

The correct path may be /home/ubuntu/Desktop/ChakraCore/ChakraCore-master/out/Debug/lib/wabt/CMakeFiles/libwabt.dir/src/prebuilt/wast-lexer.cc.

I don't know why "/src/" is wrong appended . How to fix it?

henry2cox commented 2 years ago

The”.info” file generated by lcov capture is plain ASCII with the filename in an obvious key.

‘sed’ is your friend. Just hack the path(s) to what they should be.

Your issue comes up in any moderately complicated project, where the source layout and the build structure are not identical.

Hope this helps

Henry

PS: maybe I should add that I had modified lcov/genhtml/geninfo to add a '--substitute' option - to support path substitutions. That somewhat complicates the LCOV use model, but simplifies our build-and-regress flow quite substantially. That update is not merged to master (yet). It is also part of a much larger set of changes - so the merge might not happen too soon.

paintedveil5 commented 2 years ago

Solved temporarily. Cheers!

Lily

henry2cox commented 2 years ago

Not sure if the sed workaround helped to solve or not – but the other thing I forgot to mention is that I had also implemented a cheap-and-cheerful error manager such that you can turn certain hard errors (“die…”) into warnings or ignore them altogether. In your case, adding “genhtml … --ignore-error source …” to your command line would tell the tool to warn about missing source code – but then generate fake file content to match the coverage data. If you do not need to study the actual source code in that file to figure out a coverage issue – then this enables you to just skip over stuff you don’t care about, and generate the actual report which you do care about.

There are quite a few such error categories which you may (or may not) want to skip over. And, of course – not all errors can be skipped. Some really are fatal.

In any event: I’m glad that you got past the issue.

Henry

henry2cox commented 1 year ago

Hi - The changes mentioned above have been merged to master - so now the "--substitute" option is a recommended solution to the problem. Other than changing your build so that the compiler puts the expected path into the generated code, I think that this (or 'sed') is your best alternative. If you agree - please close the issue. Thanks Henry