aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test
diff options
context:
space:
mode:
authorGravatar Klaus Aehlig <aehlig@google.com>2018-06-18 04:35:10 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-06-18 04:37:11 -0700
commit2d553b5c1411ae790b929e895f947e48e05f28f9 (patch)
tree9412571094c41d051f9010359c1b653ef562afb0 /src/test
parent4a9c3bca5da2e71003583f0a808dd8d638c80d04 (diff)
RepositoryFunction: depend on overrides, even if there is no rule
Not all bazel external repositories are generated by a rule (e.g., they might be unbound names with the expectation that on override binds them). Still, even those external repositories depend on changes to the repository override. Register this dependency. Change-Id: I900c94f969d08dec82c5776eff28337878379b5e PiperOrigin-RevId: 200974283
Diffstat (limited to 'src/test')
-rw-r--r--src/test/shell/bazel/BUILD1
-rwxr-xr-xsrc/test/shell/bazel/workspace_test.sh70
2 files changed, 71 insertions, 0 deletions
diff --git a/src/test/shell/bazel/BUILD b/src/test/shell/bazel/BUILD
index 29e10f1937..49f93ffbec 100644
--- a/src/test/shell/bazel/BUILD
+++ b/src/test/shell/bazel/BUILD
@@ -404,6 +404,7 @@ sh_test(
size = "large",
srcs = ["workspace_test.sh"],
data = [":test-deps"],
+ shard_count = 5,
tags = ["no_windows"],
)
diff --git a/src/test/shell/bazel/workspace_test.sh b/src/test/shell/bazel/workspace_test.sh
index a308c2adb0..d7af19dbdd 100755
--- a/src/test/shell/bazel/workspace_test.sh
+++ b/src/test/shell/bazel/workspace_test.sh
@@ -418,4 +418,74 @@ EOF
|| fail "expected 'y_symbol' in $(cat bazel-genfiles/external/a/result.txt)"
}
+function test_workspace_addition_change_aspect() {
+ mkdir -p repo_one
+ mkdir -p repo_two
+
+
+ touch foo.c
+ cat > BUILD <<EOF
+cc_library(
+ name = "lib",
+ srcs = ["foo.c"],
+)
+EOF
+
+ touch WORKSPACE
+ touch repo_one/BUILD
+ touch repo_two/BUILD
+
+ cat > repo_one/WORKSPACE <<EOF
+workspace(name = "new_repo")
+EOF
+ cat > repo_two/WORKSPACE <<EOF
+workspace(name = "new_repo")
+EOF
+
+
+ cat > repo_one/aspects.bzl <<EOF
+def _print_aspect_impl(target, ctx):
+ # Make sure the rule has a srcs attribute.
+ if hasattr(ctx.rule.attr, 'srcs'):
+ # Output '1' for each file in srcs.
+ for src in ctx.rule.attr.srcs:
+ for f in src.files:
+ print(1)
+ return []
+
+print_aspect = aspect(
+ implementation = _print_aspect_impl,
+ attr_aspects = ['deps'],
+)
+EOF
+ cat > repo_two/aspects.bzl <<EOF
+def _print_aspect_impl(target, ctx):
+ # Make sure the rule has a srcs attribute.
+ if hasattr(ctx.rule.attr, 'srcs'):
+ print(ctx.rule.attr.srcs)
+ return []
+
+print_aspect = aspect(
+ implementation = _print_aspect_impl,
+ attr_aspects = ['deps'],
+)
+EOF
+
+ bazel clean --expunge
+
+ echo; echo "no repo"; echo
+ bazel build //:lib --aspects @new_repo//:aspects.bzl%print_aspect \
+ && fail "Failure expected" || true
+
+ echo; echo "repo_one"; echo
+ bazel build //:lib --override_repository="new_repo=$PWD/repo_one" \
+ --aspects @new_repo//:aspects.bzl%print_aspect \
+ || fail "Expected build to succeed"
+
+ echo; echo "repo_two"; echo
+ bazel build //:lib --override_repository="new_repo=$PWD/repo_two" \
+ --aspects @new_repo//:aspects.bzl%print_aspect \
+ || fail "Expected build to succeed"
+}
+
run_suite "workspace tests"