Skip to content

Commit fa020ed

Browse files
committed
fix wd_test
1 parent 8d45d41 commit fa020ed

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

.bazelrc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -421,16 +421,17 @@ build:coverage --test_env=BAZEL_USE_LLVM_NATIVE_COVERAGE=1
421421
# GCOV is used by rules_cc to merge raw profile data (.profraw) into indexed profile data (.profdata)
422422
build:coverage --action_env=GCOV=llvm-profdata
423423
build:coverage --test_env=GCOV=llvm-profdata
424-
# COVERAGE_GCOV_PATH is passed through from the environment. Users must set this to the absolute path
425-
# of llvm-profdata (used by collect_cc_coverage.sh for merging .profraw files).
426-
# Example: export COVERAGE_GCOV_PATH=$(which llvm-profdata)
427-
build:coverage --action_env=COVERAGE_GCOV_PATH
428-
build:coverage --test_env=COVERAGE_GCOV_PATH
424+
# COVERAGE_GCOV_PATH is used by collect_cc_coverage.sh for merging .profraw files.
425+
build:coverage --action_env=COVERAGE_GCOV_PATH=/usr/bin/llvm-profdata
426+
build:coverage --test_env=COVERAGE_GCOV_PATH=/usr/bin/llvm-profdata
429427
# BAZEL_LLVM_COV is used by rules_cc to generate coverage reports from profile data
430428
build:coverage --action_env=BAZEL_LLVM_COV=llvm-cov
431429
build:coverage --test_env=BAZEL_LLVM_COV=llvm-cov
432430
# LLVM_COV is used by collect_cc_coverage.sh for generating LCOV output
433431
build:coverage --test_env=LLVM_COV=llvm-cov
432+
# GENERATE_LLVM_LCOV=1 tells collect_cc_coverage.sh to use llvm-cov export to generate LCOV format
433+
# instead of just outputting raw profdata. LLVM_COV specifies the llvm-cov binary to use.
434+
build:coverage --test_env=GENERATE_LLVM_LCOV=1
434435
build:coverage --experimental_use_llvm_covmap
435436
build:coverage --experimental_generate_llvm_lcov
436437
# Ensure that we fetch coverage data from remote cache

build/wd_test.bzl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,6 @@ def _wd_test_impl(ctx):
242242
ctx,
243243
source_attributes = ["src", "data"],
244244
dependency_attributes = ["workerd", "sidecar", "sidecar_supervisor"],
245-
# Include all file types that might contain testable code
246-
extensions = ["cc", "c++", "cpp", "cxx", "c", "h", "hh", "hpp", "hxx", "inc", "js", "ts", "mjs", "wd-test", "capnp"],
247245
)
248246
environment = dict(ctx.attr.env)
249247
if ctx.attr.python_snapshot_test:
@@ -282,11 +280,14 @@ _wd_test = rule(
282280
),
283281
# Source file
284282
"src": attr.label(allow_single_file = True),
285-
# The workerd executable is used to run all tests
283+
# The workerd executable is used to run all tests.
284+
# Using cfg = "target" instead of "exec" ensures workerd is built with coverage
285+
# instrumentation when running `bazel coverage`. With cfg = "exec", the binary
286+
# would be built in exec configuration which doesn't include coverage flags.
286287
"workerd": attr.label(
287288
allow_single_file = True,
288289
executable = True,
289-
cfg = "exec",
290+
cfg = "target",
290291
default = "//src/workerd/server:workerd_cross",
291292
),
292293
# A list of files that this test requires to be present in order to run.

0 commit comments

Comments
 (0)