Skip to content

Commit b20085a

Browse files
meteorcloudycopybara-github
authored andcommitted
integration_test_setup.sh: load bash runfiles library
Instead of getting the rlocation function from [test-setup.sh](https://cs.opensource.google/bazel/bazel/+/master:tools/test/test-setup.sh;l=115), we should use the actual bash runfiles library which supports repo mapping. Working towards: #18957 RELNOTES: None PiperOrigin-RevId: 552778831 Change-Id: Ie747faf58a5c3fc33d38653130d9657224909430
1 parent 282fffa commit b20085a

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

src/test/shell/BUILD

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ sh_library(
4545
"unittest.bash",
4646
"unittest_utils.sh",
4747
],
48-
data = [":testenv.sh"],
48+
data = [
49+
":testenv.sh",
50+
"@bazel_tools//tools/bash/runfiles",
51+
],
4952
visibility = ["//visibility:public"],
5053
)
5154

src/test/shell/bazel/BUILD

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,6 @@ gen_workspace_stanza(
2222
],
2323
)
2424

25-
gen_workspace_stanza(
26-
name = "rules_proto_stanza",
27-
out = "rules_proto_stanza.txt",
28-
repos = [
29-
"rules_proto",
30-
],
31-
)
32-
3325
filegroup(
3426
name = "test-deps",
3527
testonly = 1,
@@ -346,10 +338,7 @@ sh_test(
346338
name = "bazel_proto_library_test",
347339
size = "large", # Downloads and compiles protobuf for *every* *test* *case*
348340
srcs = ["bazel_proto_library_test.sh"],
349-
data = [
350-
":rules_proto_stanza.txt",
351-
":test-deps",
352-
],
341+
data = [":test-deps"],
353342
exec_compatible_with = ["//:highcpu_machine"],
354343
tags = ["no_windows"], # Doesn't work on Windows for unknown reason
355344
)

src/test/shell/bazel/bazel_proto_library_test.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ function write_workspace() {
4848
mkdir -p "$workspace"
4949
fi
5050

51-
cat $(rlocation io_bazel/src/tests/shell/bazel/rules_proto_stanza.txt) >> "$workspace"WORKSPACE
52-
5351
cat >> "$workspace"WORKSPACE << EOF
5452
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
5553
rules_proto_dependencies()

src/test/shell/integration_test_setup.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,20 @@ function print_message_and_exit() {
2020
}
2121

2222
if type rlocation >&/dev/null; then
23-
# If rlocation is defined, use it to look up data-dependencies.
23+
# An incomplete rlocation function is defined in Bazel's test-setup.sh script,
24+
# load the actual Bash runfiles library from @bazel_tools//tools/bash/runfiles
25+
# to make sure repo mappings is respected.
26+
# --- begin runfiles.bash initialization v3 ---
27+
# Copy-pasted from the Bazel Bash runfiles library v3.
28+
set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash
29+
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
30+
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
31+
source "$0.runfiles/$f" 2>/dev/null || \
32+
source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
33+
source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
34+
{ echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
35+
# --- end runfiles.bash initialization v3 ---
36+
2437
# Load the unit test framework
2538
source "$(rlocation io_bazel/src/test/shell/unittest.bash)" \
2639
|| print_message_and_exit "unittest.bash not found!"

0 commit comments

Comments
 (0)