aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/shell
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/shell')
-rwxr-xr-xsrc/test/shell/bazel/workspace_test.sh37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/test/shell/bazel/workspace_test.sh b/src/test/shell/bazel/workspace_test.sh
index 7addf93a08..a308c2adb0 100755
--- a/src/test/shell/bazel/workspace_test.sh
+++ b/src/test/shell/bazel/workspace_test.sh
@@ -381,4 +381,41 @@ EOF
expect_log "@flower//daisy:daisy"
}
+function test_repository_mapping_in_build_file_load() {
+ # Main repo assigns @x to @y within @a
+ mkdir -p main
+ cat > main/WORKSPACE <<EOF
+workspace(name = "main")
+
+local_repository(name = "a", path="../a", repo_mapping = {"@x" : "@y"})
+local_repository(name = "y", path="../y")
+EOF
+ touch main/BUILD
+
+ # Repository y is a substitute for x
+ mkdir -p y
+ touch y/WORKSPACE
+ touch y/BUILD
+ cat > y/symbol.bzl <<EOF
+Y_SYMBOL = "y_symbol"
+EOF
+
+ # Repository a refers to @x
+ mkdir -p a
+ touch a/WORKSPACE
+ cat > a/BUILD<<EOF
+load("@x//:symbol.bzl", "Y_SYMBOL")
+genrule(name = "a",
+ outs = ["result.txt"],
+ cmd = "echo %s > \$(location result.txt);" % (Y_SYMBOL)
+)
+EOF
+
+ cd main
+ bazel build --experimental_enable_repo_mapping @a//:a || fail "Expected build to succeed"
+ cat bazel-genfiles/external/a/result.txt
+ grep "y_symbol" bazel-genfiles/external/a/result.txt \
+ || fail "expected 'y_symbol' in $(cat bazel-genfiles/external/a/result.txt)"
+}
+
run_suite "workspace tests"