【问题标题】:Run genhtml in WSL在 WSL 中运行 genhtml
【发布时间】:2019-12-24 16:39:28
【问题描述】:

我一直在尝试使用 WSL 为我的 Flutter 项目的代码覆盖率生成 html 报告,但是当我运行 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

我可以理解这可能与路径有关,但我不确定如何修复它。有什么建议吗?

【问题讨论】:

  • 尝试使用 WSL 中的用户主文件夹 (~) 而不是 C 盘 (/mnt/c)。

标签: flutter windows-subsystem-for-linux lcov


【解决方案1】:

我在尝试通过 WSL 使用 lcov 时遇到了同样的问题,我已经解决了这个问题。

flutter test --coverage 在 Windows 上生成的 lcov 文件在路径中使用反斜杠 \ 而不是正斜杠 /

在运行genhtml 之前,只需将lcov.info 文件中的所有反斜杠替换为正斜杠即可解决问题。

【讨论】:

    【解决方案2】:

    我不知道这在那种环境中是否有用。

    我遇到了同样的问题,为了解决它,我创建了这个脚本。希望对你有帮助!

    https://github.com/jorgesarabia/flutter_coverage

    如果这能解决您的问题,请告诉我!

    【讨论】:

      【解决方案3】:

      我试过了!!

      而不是 cd'ing 进入 coverage/ 然后运行 ​​genhtml lcov.info -o anything

      只需从项目的根目录运行整个命令,因此新命令将如下所示:-

      genhtml coverage/lcov.info -o 任何东西

      附:我试图运行由 Flutter 测试生成的覆​​盖率文件。

      【讨论】:

        猜你喜欢
        • 2010-12-26
        • 2020-05-27
        • 2021-12-05
        • 1970-01-01
        • 2020-06-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多