aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib
diff options
context:
space:
mode:
authorGravatar lberki <lberki@google.com>2017-07-11 15:15:20 +0200
committerGravatar László Csomor <laszlocsomor@google.com>2017-07-11 18:25:26 +0200
commit440919933dc11d8aa4394dbd53790271a2073bc5 (patch)
tree7d75ab55310db2e3011a89dfa7064aef1f45b25e /src/test/java/com/google/devtools/build/lib
parentc16f7988c8a3077dd94b6a678a7af11ad761c580 (diff)
Add a cc_toolchain_alias and java_runtime_alias rules so that e.g. genrules can depend on the C++ toolchain/Java runtime being used.
The naive way to do this would be via @bazel_tools//, except that that does not take configuration transitions into account and e.g. will be the same in the host and the target configurations even if different toolchains are used. Eventually, this will be supplanted by the toolchain selection mechanism. However, that is not live yet and the migration cost this will incur is not a lot; just replacing the one single instance of these undocumented rules with the reference to the toolchain type. RELNOTES: None. PiperOrigin-RevId: 161519229
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib')
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainTest.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainTest.java
index 43aa2a4700..03c3deac40 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainTest.java
@@ -14,6 +14,9 @@
package com.google.devtools.build.lib.rules.cpp;
+import static com.google.common.truth.Truth.assertThat;
+
+import com.google.devtools.build.lib.analysis.ConfiguredTarget;
import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig;
import org.junit.Test;
@@ -106,4 +109,12 @@ public class CcToolchainTest extends BuildViewTestCase {
" dynamic_runtime_libs = ['dynamic-runtime-libs-cherry'],",
" static_runtime_libs = ['static-runtime-libs-cherry'])");
}
+
+ @Test
+ public void testToolchainAlias() throws Exception {
+ ConfiguredTarget reference = scratchConfiguredTarget("a", "ref",
+ "cc_toolchain_alias(name='ref')");
+ assertThat(reference.getProvider(CcToolchainProvider.class)).isNotNull();
+ assertThat(reference.get(CcToolchainProvider.SKYLARK_CONSTRUCTOR.getKey())).isNotNull();
+ }
}