3

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?

kermite
  • 31
  • 2

3 Answers3

5

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.

rasnm
  • 51
  • 1
  • 2
0

I don't know if this could be useful in that environment.

I had the same problem, and to solve it I created this script. I hope this helps you!

https://github.com/jorgesarabia/flutter_coverage

Please let me know if this solves your problem!

J. Sarabia
  • 158
  • 9
0

I tried this!!

Instead of cd'ing into coverage/ then running genhtml lcov.info -o anything

Just run the whole command from the root of project, So the new command will look something like this:-

genhtml coverage/lcov.info -o anything

P.S. I was trying to run a coverage file generated by Flutter test.

flutterninja9
  • 71
  • 1
  • 3