diff --git a/e2e/rules_cc/BUILD.bazel b/e2e/rules_cc/BUILD.bazel index 5a0dd47c..f111de8d 100644 --- a/e2e/rules_cc/BUILD.bazel +++ b/e2e/rules_cc/BUILD.bazel @@ -6,11 +6,13 @@ load("@rules_cc//cc:cc_library.bzl", "cc_library") load("@rules_cc//cc:cc_static_library.bzl", "cc_static_library") load("@rules_cc//cc:cc_test.bzl", "cc_test") load("@rules_cc//cc:objc_library.bzl", "objc_library") +load("@rules_python//python:defs.bzl", "py_test") load("@rules_shell//shell:sh_test.bzl", "sh_test") load( "//:defs.bzl", "asan_cc_binary", "cfi_cc_binary", + "coverage_cc_binary", "dfsan_cc_binary", "lsan_cc_binary", "msan_cc_binary", @@ -531,3 +533,30 @@ sh_test( ) ####################################################### + +coverage_cc_binary( + name = "coverage_main", + srcs = ["profile_main.cc"], + target_compatible_with = select({ + "@platforms//os:linux": [], + "@platforms//os:windows": [], + "//conditions:default": ["@platforms//:incompatible"], + }), +) + +py_test( + name = "coverage_output_test", + srcs = ["profile_output_test.py"], + data = [":coverage_main"], + env = { + "BINARY": "$(rootpath :coverage_main)", + }, + exec_compatible_with = HOST_CONSTRAINTS, + main = "profile_output_test.py", + tags = ["no-remote"], + target_compatible_with = select({ + "@platforms//os:linux": [], + "@platforms//os:windows": [], + "//conditions:default": ["@platforms//:incompatible"], + }), +) diff --git a/e2e/rules_cc/defs.bzl b/e2e/rules_cc/defs.bzl index 3e163822..f17d1321 100644 --- a/e2e/rules_cc/defs.bzl +++ b/e2e/rules_cc/defs.bzl @@ -93,3 +93,8 @@ opt_binary, _opt_binary_internal = with_cfg(cc_binary).set( "compilation_mode", "opt", ).build() + +coverage_cc_binary, _coverage_cc_binary_internal = with_cfg(cc_binary).set( + "collect_code_coverage", + True, +).build() diff --git a/toolchain/features/BUILD.bazel b/toolchain/features/BUILD.bazel index bb92c4eb..5274d0a7 100644 --- a/toolchain/features/BUILD.bazel +++ b/toolchain/features/BUILD.bazel @@ -233,10 +233,9 @@ cc_feature_set( ":dbg_stub", ":static_link_cpp_runtimes", ":parse_headers", - # TODO: Re-enable once coverage is supported - # ":coverage_stub", - # ":llvm_coverage_map_format", - # ":gcc_coverage_map_format", + ":coverage_stub", + ":llvm_coverage_map_format", + ":gcc_coverage_map_format", ":fully_static_link", ], visibility = ["//visibility:public"],