Run genhtml in WSL

792

I ran into the same problem when attempting to use lcov through WSL, and I have figured out the issue.

The lcov file generated by flutter test --coverage on Windows has back slashes \ for paths instead of forward slashes /.

Simply replacing all back slashes in your lcov.info file with forward slashes before running genhtml, should resolve the issue.

Share:
792
kermite
Author by

kermite

Updated on December 16, 2022

Comments

  • kermite
    kermite over 1 year

    I've been trying to use WSL to generate html reports for the code coverage of my flutter project, but this happens when I run genhtml coverage/lcov.info -o coverage/html:

    Reading data file coverage/lcov.info
    Resolved relative source file path "lib\blocs\bloc1\bloc1.dart" with CWD to "/mnt/c/Users/User/flutter_project/lib\blocs\bloc1\bloc1.dart".
    Found 284 entries.
    Found common filename prefix "/mnt/c/Users/User/flutter_project"
    Writing .css and .png files.
    Generating output.
    Processing file flutter_project/lib\otherDir\other_file.dart
    genhtml: ERROR: cannot read /mnt/c/Users/User/flutter_project/lib\otherDir\other_file.dart
    

    I can understand that this has possibly to do with the paths, but I'm not sure on how to fix it. Any tips?

    • Biswapriyo
      Biswapriyo over 4 years
      Try to use the user home folder (~) in WSL instead of C drive (/mnt/c).