aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java6
-rwxr-xr-xsrc/test/shell/bazel/external_integration_test.sh21
2 files changed, 24 insertions, 3 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java
index a14800870d..6f6573e0f1 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java
@@ -27,7 +27,6 @@ import com.google.devtools.build.lib.skyframe.FileValue;
import com.google.devtools.build.lib.skyframe.PrecomputedValue;
import com.google.devtools.build.lib.skyframe.PrecomputedValue.Precomputed;
import com.google.devtools.build.lib.skyframe.SkyFunctions;
-import com.google.devtools.build.lib.syntax.EvalException;
import com.google.devtools.build.lib.util.Fingerprint;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
import com.google.devtools.build.lib.vfs.Path;
@@ -122,6 +121,7 @@ public final class RepositoryDelegatorFunction implements SkyFunction {
if (rule == null) {
return null;
}
+
RepositoryFunction handler;
if (rule.getRuleClassObject().isSkylark()) {
handler = skylarkHandler;
@@ -129,8 +129,8 @@ public final class RepositoryDelegatorFunction implements SkyFunction {
handler = handlers.get(rule.getRuleClass());
}
if (handler == null) {
- throw new IllegalStateException(
- new EvalException(rule.getLocation(), "Could not find handler for " + rule));
+ // If we refer to a non repository rule then the repository does not exist.
+ return RepositoryDirectoryValue.NO_SUCH_REPOSITORY_VALUE;
}
handler.setClientEnvironment(clientEnvironment);
diff --git a/src/test/shell/bazel/external_integration_test.sh b/src/test/shell/bazel/external_integration_test.sh
index fb16be7dfe..6d3f375500 100755
--- a/src/test/shell/bazel/external_integration_test.sh
+++ b/src/test/shell/bazel/external_integration_test.sh
@@ -813,6 +813,27 @@ EOF
expect_log "//external:androidsdk"
}
+function test_use_bind_as_repository() {
+ cat > WORKSPACE <<'EOF'
+local_repository(name = 'foobar', path = 'foo')
+bind(name = 'foo', actual = '@foobar//:test')
+EOF
+ mkdir foo
+ touch foo/WORKSPACE
+ touch foo/test
+ echo 'exports_files(["test"])' > foo/BUILD
+ cat > BUILD <<'EOF'
+genrule(
+ name = "foo",
+ srcs = ["@foo//:test"],
+ cmd = "echo $< | tee $@",
+ outs = ["foo.txt"],
+)
+EOF
+ bazel build :foo &> "$TEST_log" && fail "Expected failure" || true
+ expect_log "no such package '@foo//'"
+}
+
function test_flip_flopping() {
REPO_PATH=$TEST_TMPDIR/repo
mkdir -p "$REPO_PATH"