diff options
Diffstat (limited to 'src/test/shell/bazel/local_repository_test.sh')
-rwxr-xr-x | src/test/shell/bazel/local_repository_test.sh | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/test/shell/bazel/local_repository_test.sh b/src/test/shell/bazel/local_repository_test.sh index a57940ef4c..2e6b0231ec 100755 --- a/src/test/shell/bazel/local_repository_test.sh +++ b/src/test/shell/bazel/local_repository_test.sh @@ -1224,4 +1224,80 @@ EOF expect_log "is not a directory" } +# Creates an indirect dependency on X from A and make sure the error message +# refers to the correct label, both in an external repository and not. +function test_indirect_dep_message() { + local external_dir=$TEST_TMPDIR/ext-dir + mkdir -p a b $external_dir/x + cat > a/A.java <<EOF +package a; + +import x.X; + +public class A { + public static void main(String args[]) { + X.print(); + } +} +EOF + cat > a/BUILD <<EOF +java_binary( + name = "a", + main_class = "a.A", + srcs = ["A.java"], + deps = ["//b"], +) +EOF + + + cat > b/B.java <<EOF +package b; + +public class B { + public static void print() { + System.out.println("B"); + } +} +EOF + cat > b/BUILD <<EOF +java_library( + name = "b", + srcs = ["B.java"], + deps = ["@x_repo//x"], + visibility = ["//visibility:public"], +) +EOF + + cp -r a b $external_dir + + touch $external_dir/WORKSPACE + cat > $external_dir/x/X.java <<EOF +package x; + +public class X { + public static void print() { + System.out.println("X"); + } +} +EOF + cat > $external_dir/x/BUILD <<EOF +java_library( + name = "x", + srcs = ["X.java"], + visibility = ["//visibility:public"], +) +EOF + + cat > WORKSPACE <<EOF +local_repository( + name = "x_repo", + path = "$external_dir", +) +EOF + + bazel build @x_repo//a >& $TEST_log && fail "Building @x_repo//a should error out" + expect_log "** Please add the following dependencies:" + expect_log "@x_repo//x to @x_repo//a" +} + run_suite "local repository tests" |