Skip to content

Commit

Permalink
Make testpilot recognize that these tests have coverage instrumentation
Browse files Browse the repository at this point in the history
Summary: TestPilot uses two flags to determine whether coverage is already instrumented: `fbcode_macros` and `coverage`.  Normally, these two tags are added automatically to cpp tests, but this is a fake cpp test, so we must manually add them.  The first is easy - `fbcode_macros` is added by the `custom_unittest` library, which is in `fbcode_macros`, so it is appropriate.  The second is harder - we need to verify that we should add the macro.  We do this using the `coverage.bzl` functions.

Reviewed By: siying

Differential Revision: D20549040

fbshipit-source-id: d2732b3ec26f3dff065efdf398abe3241075bb2f
  • Loading branch information
Ben0mega authored and facebook-github-bot committed Mar 20, 2020
1 parent 093ff0b commit d2e3822
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# defs.bzl - Definitions for Facebook-specific buck build integration
# in TARGETS

load("@fbcode_macros//build_defs:coverage.bzl", "coverage")
load("@fbcode_macros//build_defs:cpp_binary.bzl", "cpp_binary")
load("@fbcode_macros//build_defs:custom_unittest.bzl", "custom_unittest")

Expand Down Expand Up @@ -37,9 +38,19 @@ def test_binary(

binary_path = "$(location :{})".format(test_bin)

base_path = native.package_name()
tags = []
if coverage.is_coverage_enabled(base_path):
# This tag instructs testpilot to use
# the lower-memory coverage runner
# (e.g. it tells testpilot that the binary
# is actually instrumented with coverage info)
tags = ["coverage"]

custom_unittest(
name = test_name,
command = [TEST_RUNNER, binary_path],
type = ttype,
env = {"BUCK_BASE_BINARY": binary_path},
tags = tags,
)

0 comments on commit d2e3822

Please sign in to comment.