forked from bazelbuild/rules_scala
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix coverage tests with experimental flags
Adds the new `test/shell/test_coverage_helper.sh` file, which defines (amongst other helpers) `COVERAGE_FLAGS` as containing: - `--experimental_fetch_all_coverage_outputs` - `--experimental_split_coverage_postprocessing` This resolves the following error under Bazel 7.4.1 with Bzlmod enabled: ```txt /mnt/engflow/worker/work/3/exec/bazel-out/ darwin_arm64-opt-exec-ST-f4dfef26580e/bin/external/ bazel_tools~remote_coverage_tools_extension~remote_coverage_tools/Main: Cannot locate runfiles directory. (Set $JAVA_RUNFILES to inhibit searching.) ``` This error resembles bazelbuild/bazel#20577, but wasn't due to the presence of `--nobuild_runfile_links`, but to the lack of the aforementioned `--experimental_*` flags. I learned about these flags from: - bazelbuild/bazel#4685 (comment) - bazelbuild/bazel#16556
- Loading branch information
Showing
6 changed files
with
60 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
COVERAGE_FLAGS=( | ||
"--experimental_fetch_all_coverage_outputs" | ||
"--experimental_split_coverage_postprocessing" | ||
) | ||
TESTLOGS="$(bazel info bazel-testlogs)" | ||
|
||
# Default to 2.12.20 for `diff` tests because other versions change the output. | ||
SCALA_VERSION="${SCALA_VERSION:-2.12.20}" | ||
|
||
_coverage_path() { | ||
echo "$TESTLOGS/$TEST_PKG/$TARGET/coverage.dat" | ||
} | ||
|
||
do_test_coverage_on() { | ||
bazel coverage "${COVERAGE_FLAGS[@]}" "${EXTRA_COVERAGE_FLAGS[@]}" \ | ||
--repo_env="SCALA_VERSION=${SCALA_VERSION}" "//$TEST_PKG:$TARGET" | ||
diff "${EXPECTED_COVERAGE_PATH:-$TEST_PKG/expected-coverage.dat}" \ | ||
"$(_coverage_path)" | ||
} | ||
|
||
do_test_coverage_includes_test_targets() { | ||
local test_file="$1" | ||
|
||
bazel coverage "${COVERAGE_FLAGS[@]}" "${EXTRA_COVERAGE_FLAGS[@]}" \ | ||
--instrument_test_targets=True "//$TEST_PKG:$TARGET" | ||
grep -q "SF:$TEST_PKG/$test_file" "$(_coverage_path)" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters