aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test
diff options
context:
space:
mode:
authorGravatar jcater <jcater@google.com>2018-06-13 10:17:30 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-06-13 10:19:12 -0700
commitd7ce626a447ac5d612013ee46166c8acc063b04d (patch)
tree0338fbb6b9fcc0cbd2a9f20c4f53ab839643c855 /src/test
parentbf57a0a9205e336c690e101ff1663c48e5f9679e (diff)
Enable per-target execution for genrule, sh_*, and *_test.
PiperOrigin-RevId: 200410988
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java3
-rwxr-xr-xsrc/test/shell/bazel/toolchain_test.sh48
2 files changed, 50 insertions, 1 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java
index fbd3760519..b7c714b1c7 100644
--- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java
@@ -632,7 +632,8 @@ public class SkylarkRuleContextTest extends SkylarkTestCase {
"executable",
"stamp",
"heuristic_label_expansion",
- "kind");
+ "kind",
+ "exec_compatible_with");
}
@Test
diff --git a/src/test/shell/bazel/toolchain_test.sh b/src/test/shell/bazel/toolchain_test.sh
index bb0f34d45b..748182c0bc 100755
--- a/src/test/shell/bazel/toolchain_test.sh
+++ b/src/test/shell/bazel/toolchain_test.sh
@@ -686,4 +686,52 @@ EOF
}
+function test_native_rule_target_exec_constraints() {
+ mkdir -p platform
+ cat >> platform/BUILD <<EOF
+package(default_visibility = ["//visibility:public"])
+constraint_setting(name = "test")
+
+constraint_value(
+ name = "test_enabled",
+ constraint_setting = ":test",
+)
+
+platform(
+ name = "test_platform",
+ constraint_values = [
+ ":test_enabled",
+ ],
+)
+EOF
+
+ mkdir -p demo
+ cat >> demo/BUILD <<EOF
+genrule(
+ name = "target",
+ outs = ["out.txt"],
+ cmd = """
+ echo "platform" > \$@
+ """,
+ exec_compatible_with = [
+ "//platform:test_enabled",
+ ],
+)
+EOF
+
+ # When no platform has the constraint, an error
+ bazel build \
+ --toolchain_resolution_debug \
+ //demo:target &> $TEST_log && fail "Build failure expected"
+ expect_log "While resolving toolchains for target //demo:target: .* from available execution platforms \[\]"
+
+ # When the platform exists, it is used.
+ bazel build \
+ --extra_execution_platforms=//platform:test_platform \
+ --toolchain_resolution_debug \
+ //demo:target &> $TEST_log || fail "Build failed"
+ expect_log "ToolchainUtil: Selected execution platform //platform:test_platform"
+}
+
+
run_suite "toolchain tests"