diff --git a/.github/workflows/default.yaml b/.github/workflows/default.yaml index 4f6eeb8..f920c2c 100644 --- a/.github/workflows/default.yaml +++ b/.github/workflows/default.yaml @@ -62,6 +62,17 @@ jobs: bazel test --config ci --config ${{ matrix.sanitizer }} //tests/sanitizers:${{ matrix.sanitizer }}_test env: BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }} + coverage: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + - uses: bazelbuild/setup-bazelisk@v2 + - name: Test Coverage + run: | + ./.github/workflows/configurebb.sh + bazel coverage --config ci //examples/hello_world_cpp:hello_world_cpp_test + env: + BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }} rbe: if: (github.ref == 'refs/heads/main' || contains(github.head_ref, 'rbe')) strategy: diff --git a/examples/hello_world_cpp/BUILD.bazel b/examples/hello_world_cpp/BUILD.bazel index 0a07131..88bcbbb 100644 --- a/examples/hello_world_cpp/BUILD.bazel +++ b/examples/hello_world_cpp/BUILD.bazel @@ -32,6 +32,12 @@ cc_binary( data = ["names.txt"], ) +cc_test( + name = "hello_world_cpp_test", + srcs = ["main.cpp"], + data = ["names.txt"], +) + platform_transition_filegroup( name = "hello_world_cpp_linux_aarch64", srcs = [":hello_world_cpp"], diff --git a/toolchain/defs.bzl b/toolchain/defs.bzl index 32ba805..0991f63 100644 --- a/toolchain/defs.bzl +++ b/toolchain/defs.bzl @@ -503,6 +503,12 @@ filegroup( visibility = ["//visibility:public"], ) +filegroup( + name = "coverage_files", + srcs = [":gcov"], + visibility = ["//visibility:public"], +) + [ filegroup( name = bin, @@ -516,6 +522,7 @@ filegroup( for bin in [ "ar", "as", + "gcov", "ld", "ld.bfd", "nm", @@ -575,6 +582,7 @@ cc_toolchain( linker_files = ":linker_files", objcopy_files = ":objcopy_files", strip_files = ":strip_files", + coverage_files = ":coverage_files", supports_param_files = 0, toolchain_config = ":cc_toolchain_config", toolchain_identifier = "gcc-toolchain", @@ -598,6 +606,7 @@ filegroup( ":ar_files", ":as_files", ":compiler_files", + ":coverage_files", ":dwp_files", ":linker_files", ":objcopy_files", @@ -662,6 +671,14 @@ filegroup( ], ) +filegroup( + name = "coverage_files", + srcs = [ + "@{toolchain_files_repository_name}//:coverage_files", + ":gcov", + ], +) + filegroup( name = "gcc", srcs = [ @@ -671,6 +688,11 @@ filegroup( ], ) +filegroup( + name = "gcov", + srcs = ["bin/gcov"], +) + filegroup( name = "gfortran", srcs = ["bin/gfortran"],