aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/analysis
diff options
context:
space:
mode:
authorGravatar ulfjack <ulfjack@google.com>2017-12-18 06:09:06 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2017-12-18 06:11:52 -0800
commit2f10da0db062e023b1f0f8222f8545467b29ae4e (patch)
tree75545833e1aef50831e2301d14b3f94564b91ed7 /src/test/java/com/google/devtools/build/lib/analysis
parentdd11a0e2e7a143f89bca1be6e4cd56df0640dbe0 (diff)
Change CommandHelper to use TemplateExpander directly
This is a partial rollback of https://github.com/bazelbuild/bazel/commit/e8d32b7c922f65539b74357711d5ad6b70934115, only the CommandHelper change. Progress on #2475. PiperOrigin-RevId: 179413908
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/analysis')
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/ExpanderIntegrationTest.java (renamed from src/test/java/com/google/devtools/build/lib/analysis/LocationExpanderIntegrationTest.java)29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/LocationExpanderIntegrationTest.java b/src/test/java/com/google/devtools/build/lib/analysis/ExpanderIntegrationTest.java
index 1db06a8883..382ee60bc5 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/LocationExpanderIntegrationTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/ExpanderIntegrationTest.java
@@ -16,15 +16,16 @@ package com.google.devtools.build.lib.analysis;
import static com.google.common.truth.Truth.assertThat;
+import com.google.common.collect.ImmutableMap;
import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
-/** Integration tests for {@link LocationExpander}. */
+/** Integration tests for {@link Expander}. */
@RunWith(JUnit4.class)
-public class LocationExpanderIntegrationTest extends BuildViewTestCase {
+public class ExpanderIntegrationTest extends BuildViewTestCase {
@Before
public void createFiles() throws Exception {
@@ -40,10 +41,10 @@ public class LocationExpanderIntegrationTest extends BuildViewTestCase {
" deps = [':files'])");
}
- private LocationExpander makeExpander(String label) throws Exception {
+ private Expander makeExpander(String label) throws Exception {
ConfiguredTarget target = getConfiguredTarget(label);
RuleContext ruleContext = getRuleContext(target);
- return LocationExpander.withRunfilesPaths(ruleContext);
+ return ruleContext.getExpander().withExecLocations(ImmutableMap.of());
}
@Test
@@ -57,9 +58,9 @@ public class LocationExpanderIntegrationTest extends BuildViewTestCase {
"sh_library(name='lib',",
" deps = [':files'])");
- LocationExpander expander = makeExpander("//spaces:lib");
+ Expander expander = makeExpander("//spaces:lib");
String input = "foo $(locations :files) bar";
- String result = expander.expand(input);
+ String result = expander.expand(null, input);
assertThat(result).isEqualTo("foo 'spaces/file with space A' 'spaces/file with space B' bar");
}
@@ -71,14 +72,14 @@ public class LocationExpanderIntegrationTest extends BuildViewTestCase {
"genrule(name='foo', outs=['foo.txt'], cmd='never executed')",
"sh_library(name='lib', srcs=[':foo'])");
- LocationExpander expander = makeExpander("//expansion:lib");
- assertThat(expander.expand("foo $(execpath :foo) bar"))
+ Expander expander = makeExpander("//expansion:lib");
+ assertThat(expander.expand("<attribute>", "foo $(execpath :foo) bar"))
.matches("foo .*-out/.*/expansion/foo\\.txt bar");
- assertThat(expander.expand("foo $(execpaths :foo) bar"))
+ assertThat(expander.expand("<attribute>", "foo $(execpaths :foo) bar"))
.matches("foo .*-out/.*/expansion/foo\\.txt bar");
- assertThat(expander.expand("foo $(rootpath :foo) bar"))
+ assertThat(expander.expand("<attribute>", "foo $(rootpath :foo) bar"))
.matches("foo expansion/foo.txt bar");
- assertThat(expander.expand("foo $(rootpaths :foo) bar"))
+ assertThat(expander.expand("<attribute>", "foo $(rootpaths :foo) bar"))
.matches("foo expansion/foo.txt bar");
}
@@ -89,10 +90,10 @@ public class LocationExpanderIntegrationTest extends BuildViewTestCase {
"genrule(name='foo', outs=['foo.txt', 'bar.txt'], cmd='never executed')",
"sh_library(name='lib', srcs=[':foo'])");
- LocationExpander expander = makeExpander("//expansion:lib");
- assertThat(expander.expand("foo $(execpaths :foo) bar"))
+ Expander expander = makeExpander("//expansion:lib");
+ assertThat(expander.expand("<attribute>", "foo $(execpaths :foo) bar"))
.matches("foo .*-out/.*/expansion/bar\\.txt .*-out/.*/expansion/foo\\.txt bar");
- assertThat(expander.expand("foo $(rootpaths :foo) bar"))
+ assertThat(expander.expand("<attribute>", "foo $(rootpaths :foo) bar"))
.matches("foo expansion/bar.txt expansion/foo.txt bar");
}
}