diff options
author | 2017-09-06 14:05:26 +0200 | |
---|---|---|
committer | 2017-09-07 09:56:39 +0200 | |
commit | 1673b5ab20f79d010340383f8df21d2968c46888 (patch) | |
tree | ab8be66e39e4605d375239b791451fb7a4a50b1a /src | |
parent | 8328dc9e3b0d473756ec94508744afefe4d8eaf2 (diff) |
Returns repository does not exists when referring to a bind rule...
...or any other non repository rule.
Using a bind rule as the name of the repository was returning
a strange error "could not find handler for bind rule" which was
not useful, so was replaced by a crash.
Fixes #3664
Change-Id: Id0711470e6a1ab9267e05eb273900b18d0a27d6b
PiperOrigin-RevId: 167706825
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java | 6 | ||||
-rwxr-xr-x | src/test/shell/bazel/external_integration_test.sh | 21 |
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" |