[Python] Not all files have gcno with bazel --coverage

Discussão em 'Python' iniciado por Stack, Agosto 11, 2025.

  1. Stack

    Stack Membro Participativo

    NB I have the custom targets which run by python scripts. So I couldn't use bazel coverage directly for this one.

    1.

    • I defined in .bazelrc

    build:coverage --collect_code_coverage
    build:coverage --instrumentation_filter="^//src[/:]"
    coverage --instrumentation_filter="^//src[/:]"

    • In the root BUILD

    config_setting(
    name = "Coverage",
    flag_values = {
    ":coverage": "true",
    },
    )

    bool_flag(
    name = "coverage",
    build_setting_default = False,
    )

    • In the cc_binary wrapper I use

    + select({"//:Coverage": coverageCopts, "//conditions:default": [], }),
    // and
    select({"//:Coverage": coverageLopts, "//conditions:default": [], }),


    where

    coverageCopts = ["--coverage", "-fprofile-abs-path", "-fprofile-arcs", "-ftest-coverage"]
    coverageLopts = ["--coverage", "-lgcov"]

    • and run this python script (from bazel) like this:

    bazel run --subcommands --//\:coverage=true script:runner


    1. But for some mystical reasons I have a lack of gcno files.


    2. although there are these gcno's for neighboring files from the same library.


    3. Grepping for bazel --subcommands indicates the presences of --coverage flag for this cpp file.


    4. I did bazel clean --expunge - same result.

    Continue reading...

Compartilhe esta Página