aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/shell
diff options
context:
space:
mode:
authorGravatar John Cater <jcater@google.com>2017-08-09 21:09:53 +0200
committerGravatar Marcel Hlopko <hlopko@google.com>2017-08-10 13:47:59 +0200
commit3a0ce7780a5707450d7fb013c006e90bf6861e27 (patch)
tree9a2f634c04fa570a69efb13a1bdc545f7ff43609 /src/test/shell
parent6cc9d93a73d4cae58ab55748edde5be782cc0727 (diff)
Ensure that invalid target errors are properly reported in
ConfiguredTargetFunction. Fixes #3430. Change-Id: Iac1ab3fb4958dc6fb23e92a43a32b81461dcf0f3 PiperOrigin-RevId: 164754851
Diffstat (limited to 'src/test/shell')
-rwxr-xr-xsrc/test/shell/bazel/toolchain_test.sh35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/test/shell/bazel/toolchain_test.sh b/src/test/shell/bazel/toolchain_test.sh
index 7c676254a8..206abe89f1 100755
--- a/src/test/shell/bazel/toolchain_test.sh
+++ b/src/test/shell/bazel/toolchain_test.sh
@@ -478,4 +478,39 @@ EOF
expect_log "While resolving toolchains for target //demo:use: invalid registered toolchain '//demo:invalid': target does not provide the DeclaredToolchainInfo provider"
}
+
+function test_toolchain_error_invalid_target() {
+ write_test_toolchain
+ write_test_rule
+# write_toolchains
+
+ # Write toolchain with an invalid target.
+ mkdir -p invalid
+ cat > invalid/BUILD <<EOF
+toolchain(
+ name = 'invalid_toolchain',
+ toolchain_type = '//toolchain:test_toolchain',
+ exec_compatible_with = [],
+ target_compatible_with = [],
+ toolchain = '//toolchain:does_not_exist',
+ visibility = ['//visibility:public'])
+EOF
+
+ cat > WORKSPACE <<EOF
+register_toolchains('//invalid:invalid_toolchain')
+EOF
+
+ mkdir -p demo
+ cat >> demo/BUILD <<EOF
+load('//toolchain:rule.bzl', 'use_toolchain')
+# Use the toolchain.
+use_toolchain(
+ name = 'use',
+ message = 'this is the rule')
+EOF
+
+ bazel build //demo:use &> $TEST_log && fail "Build failure expected"
+ expect_log "While resolving toolchains for target //demo:use: no such target '//toolchain:does_not_exist': target 'does_not_exist' not declared in package 'toolchain'"
+}
+
run_suite "toolchain tests"