aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com
diff options
context:
space:
mode:
authorGravatar tomlu <tomlu@google.com>2017-08-10 19:26:34 +0200
committerGravatar Marcel Hlopko <hlopko@google.com>2017-08-11 12:56:11 +0200
commit4435515d156dbb0cc40869de686d326b175f61b8 (patch)
tree4e15de1bd9693857c867d6ef11bf4aee52714eaf /src/test/java/com
parentbc4eb273de3ac59962d6e78628a28a9109e43715 (diff)
Inline @Deprecated methods in CustomCommandLine.
Apart from updating CustomCommandLineTest this CL is entirely automated. We also sneak in a rename of addFormat -> addFormatted. RELNOTES: None PiperOrigin-RevId: 164870140
Diffstat (limited to 'src/test/java/com')
-rw-r--r--src/test/java/com/google/devtools/build/lib/actions/CustomCommandLineTest.java145
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/actions/CustomCommandLineTest.java75
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java47
3 files changed, 134 insertions, 133 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/actions/CustomCommandLineTest.java b/src/test/java/com/google/devtools/build/lib/actions/CustomCommandLineTest.java
index 799db447d4..ba0439e1d6 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/CustomCommandLineTest.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/CustomCommandLineTest.java
@@ -17,7 +17,6 @@ import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;
import com.google.common.base.Function;
-import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableList;
import com.google.common.testing.NullPointerTester;
import com.google.devtools.build.lib.actions.Artifact.ArtifactExpander;
@@ -28,10 +27,12 @@ import com.google.devtools.build.lib.analysis.actions.CommandLine;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.CustomArgv;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.CustomMultiArgv;
+import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.VectorArg;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.cmdline.LabelSyntaxException;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
+import com.google.devtools.build.lib.collect.nestedset.Order;
import com.google.devtools.build.lib.testutil.Scratch;
import com.google.devtools.build.lib.vfs.PathFragment;
import java.util.Collection;
@@ -81,8 +82,10 @@ public class CustomCommandLineTest {
@Test
public void testArtifactJoinStringArgs() {
- CustomCommandLine cl = CustomCommandLine.builder().addJoinStrings("--path", ":",
- ImmutableList.of("foo", "bar")).build();
+ CustomCommandLine cl =
+ CustomCommandLine.builder()
+ .add("--path", VectorArg.of(ImmutableList.of("foo", "bar")).joinWith(":"))
+ .build();
assertThat(cl.arguments()).isEqualTo(ImmutableList.of("--path", "foo:bar"));
}
@@ -90,66 +93,77 @@ public class CustomCommandLineTest {
public void testJoinValues() {
CustomCommandLine cl =
CustomCommandLine.builder()
- .addJoinValues(
+ .add(
"--path",
- ":",
- ImmutableList.of("foo", "bar", "baz"),
- new Function<String, String>() {
- @Nullable
- @Override
- public String apply(@Nullable String s) {
- return s.toUpperCase();
- }
- })
+ VectorArg.of(ImmutableList.of("foo", "bar", "baz"))
+ .joinWith(":")
+ .mapEach(
+ new Function<String, String>() {
+ @Nullable
+ @Override
+ public String apply(@Nullable String s) {
+ return s.toUpperCase();
+ }
+ }))
.build();
assertThat(cl.arguments()).isEqualTo(ImmutableList.of("--path", "FOO:BAR:BAZ"));
}
@Test
public void testArtifactExecPathArgs() {
- CustomCommandLine cl = CustomCommandLine.builder().addExecPath("--path", artifact1).build();
+ CustomCommandLine cl = CustomCommandLine.builder().add("--path", artifact1).build();
assertThat(cl.arguments()).isEqualTo(ImmutableList.of("--path", "dir/file1.txt"));
}
@Test
public void testArtifactExecPathsArgs() {
- CustomCommandLine cl = CustomCommandLine.builder().addExecPaths("--path",
- ImmutableList.of(artifact1, artifact2)).build();
+ CustomCommandLine cl =
+ CustomCommandLine.builder().add("--path", ImmutableList.of(artifact1, artifact2)).build();
assertThat(cl.arguments())
.isEqualTo(ImmutableList.of("--path", "dir/file1.txt", "dir/file2.txt"));
}
@Test
public void testNestedSetArtifactExecPathsArgs() {
- CustomCommandLine cl = CustomCommandLine.builder().addExecPaths(
- NestedSetBuilder.<Artifact>stableOrder().add(artifact1).add(artifact2).build()).build();
+ CustomCommandLine cl =
+ CustomCommandLine.builder()
+ .add(NestedSetBuilder.<Artifact>stableOrder().add(artifact1).add(artifact2).build())
+ .build();
assertThat(cl.arguments()).isEqualTo(ImmutableList.of("dir/file1.txt", "dir/file2.txt"));
}
@Test
public void testArtifactJoinExecPathArgs() {
- CustomCommandLine cl = CustomCommandLine.builder().addJoinExecPaths("--path", ":",
- ImmutableList.of(artifact1, artifact2)).build();
+ CustomCommandLine cl =
+ CustomCommandLine.builder()
+ .add("--path", VectorArg.of(ImmutableList.of(artifact1, artifact2)).joinWith(":"))
+ .build();
assertThat(cl.arguments()).isEqualTo(ImmutableList.of("--path", "dir/file1.txt:dir/file2.txt"));
}
@Test
public void testPathArgs() {
- CustomCommandLine cl = CustomCommandLine.builder().addPath(artifact1.getExecPath()).build();
+ CustomCommandLine cl = CustomCommandLine.builder().add(artifact1.getExecPath()).build();
assertThat(cl.arguments()).isEqualTo(ImmutableList.of("dir/file1.txt"));
}
@Test
public void testJoinPathArgs() {
- CustomCommandLine cl = CustomCommandLine.builder().addJoinPaths(":",
- ImmutableList.of(artifact1.getExecPath(), artifact2.getExecPath())).build();
+ CustomCommandLine cl =
+ CustomCommandLine.builder()
+ .add(
+ VectorArg.of(ImmutableList.of(artifact1.getExecPath(), artifact2.getExecPath()))
+ .joinWith(":"))
+ .build();
assertThat(cl.arguments()).isEqualTo(ImmutableList.of("dir/file1.txt:dir/file2.txt"));
}
@Test
public void testPathsArgs() {
- CustomCommandLine cl = CustomCommandLine.builder().addPaths("%s:%s",
- artifact1.getExecPath(), artifact1.getRootRelativePath()).build();
+ CustomCommandLine cl =
+ CustomCommandLine.builder()
+ .addFormatted("%s:%s", artifact1.getExecPath(), artifact1.getRootRelativePath())
+ .build();
assertThat(cl.arguments()).isEqualTo(ImmutableList.of("dir/file1.txt:dir/file1.txt"));
}
@@ -177,12 +191,13 @@ public class CustomCommandLineTest {
@Test
public void testCombinedArgs() {
- CustomCommandLine cl = CustomCommandLine.builder()
- .add("--arg")
- .add("--args", ImmutableList.of("abc"))
- .addExecPaths("--path1", ImmutableList.of(artifact1))
- .addExecPath("--path2", artifact2)
- .build();
+ CustomCommandLine cl =
+ CustomCommandLine.builder()
+ .add("--arg")
+ .add("--args", ImmutableList.of("abc"))
+ .add("--path1", ImmutableList.of(artifact1))
+ .add("--path2", artifact2)
+ .build();
assertThat(cl.arguments())
.isEqualTo(
ImmutableList.of(
@@ -196,36 +211,26 @@ public class CustomCommandLineTest {
CustomCommandLine cl =
CustomCommandLine.builder()
- .add((CharSequence) null)
- .add((Label) null)
- .add("foo", (Artifact) null)
- .add("foo", ImmutableList.of())
+ .add((Object) null)
+ .add("foo", (Object) null)
.add((ImmutableList<String>) null)
.add(ImmutableList.<String>of())
- .addExecPath("foo", null)
- .addExecPaths("foo", (NestedSet<Artifact>) null)
- .addExecPaths("foo", ImmutableList.<Artifact>of())
- .addExecPaths((NestedSet) null)
- .addExecPaths(ImmutableList.of())
+ .add((NestedSet<String>) null)
+ .add(NestedSetBuilder.<String>emptySet(Order.STABLE_ORDER))
+ .add("foo", (ImmutableList<String>) null)
+ .add("foo", ImmutableList.<String>of())
+ .add("foo", (NestedSet<String>) null)
+ .add("foo", NestedSetBuilder.<String>emptySet(Order.STABLE_ORDER))
+ .add(VectorArg.of((ImmutableList<String>) null))
+ .add(VectorArg.of(ImmutableList.<String>of()))
+ .add(VectorArg.of((NestedSet<String>) null))
+ .add(VectorArg.of(NestedSetBuilder.<String>emptySet(Order.STABLE_ORDER)))
+ .add("foo", VectorArg.of((ImmutableList<String>) null))
+ .add("foo", VectorArg.of(ImmutableList.<String>of()))
+ .add("foo", VectorArg.of((NestedSet<String>) null))
+ .add("foo", VectorArg.of(NestedSetBuilder.<String>emptySet(Order.STABLE_ORDER)))
.addPlaceholderTreeArtifactExecPath("foo", null)
- .addJoinStrings("foo", "bar", null)
- .addJoinStrings("foo", "bar", ImmutableList.of())
- .addJoinValues("foo", "bar", (NestedSet) null, String::toString)
- .addJoinValues("foo", "bar", ImmutableList.of(), String::toString)
- .addJoinExecPaths("foo", "bar", (NestedSet) null)
- .addJoinExecPaths("foo", "bar", ImmutableList.of())
- .addPath(null)
.addPlaceholderTreeArtifactFormattedExecPath("foo", null)
- .addJoinPaths("foo", null)
- .addJoinPaths("foo", ImmutableList.of())
- .addBeforeEachPath("foo", (NestedSet) null)
- .addBeforeEachPath("foo", ImmutableList.of())
- .addBeforeEach("foo", null)
- .addBeforeEach("foo", ImmutableList.of())
- .addBeforeEachExecPath("foo", (NestedSet) null)
- .addBeforeEachExecPath("foo", ImmutableList.of())
- .addFormatEach("%s", (NestedSet) null)
- .addFormatEach("%s", ImmutableList.of())
.add((CustomArgv) null)
.add((CustomMultiArgv) null)
.build();
@@ -240,47 +245,21 @@ public class CustomCommandLineTest {
.setDefault(PathFragment[].class, new PathFragment[] {PathFragment.create("foo")});
npt.testMethod(obj, clazz.getMethod("add", String.class, Object.class));
- npt.testMethod(obj, clazz.getMethod("addExecPath", String.class, Artifact.class));
- npt.testMethod(obj, clazz.getMethod("addExecPaths", String.class, ImmutableCollection.class));
npt.testMethod(
obj, clazz.getMethod("addPlaceholderTreeArtifactExecPath", String.class, Artifact.class));
npt.testMethod(
obj,
clazz.getMethod(
"addPlaceholderTreeArtifactFormattedExecPath", String.class, Artifact.class));
- npt.testMethod(obj, clazz.getMethod("addParamFile", String.class, Artifact.class));
- npt.testMethod(obj, clazz.getMethod("addPaths", String.class, PathFragment.class));
npt.testMethod(
obj, clazz.getMethod("addJoinExpandedTreeArtifactExecPath", String.class, Artifact.class));
npt.testMethod(obj, clazz.getMethod("addExpandedTreeArtifactExecPaths", Artifact.class));
npt.setDefault(Iterable.class, ImmutableList.of("foo"));
- npt.testMethod(
- obj,
- clazz.getMethod("addJoinStrings", String.class, String.class, ImmutableCollection.class));
- npt.testMethod(
- obj,
- clazz.getMethod(
- "addJoinValues",
- String.class,
- String.class,
- ImmutableCollection.class,
- Function.class));
- npt.testMethod(obj, clazz.getMethod("addBeforeEach", String.class, ImmutableCollection.class));
- npt.testMethod(obj, clazz.getMethod("addFormatEach", String.class, ImmutableCollection.class));
npt.setDefault(Iterable.class, ImmutableList.of(artifact1));
- npt.testMethod(
- obj,
- clazz.getMethod("addJoinExecPaths", String.class, String.class, ImmutableCollection.class));
- npt.testMethod(
- obj, clazz.getMethod("addBeforeEachExecPath", String.class, ImmutableCollection.class));
npt.setDefault(Iterable.class, ImmutableList.of(PathFragment.create("foo")));
- npt.testMethod(obj, clazz.getMethod("addJoinPaths", String.class, ImmutableCollection.class));
- npt.testMethod(
- obj, clazz.getMethod("addBeforeEachPath", String.class, ImmutableCollection.class));
-
npt.setDefault(Artifact.class, treeArtifact);
npt.testMethod(
obj, clazz.getMethod("addJoinExpandedTreeArtifactExecPath", String.class, Artifact.class));
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/actions/CustomCommandLineTest.java b/src/test/java/com/google/devtools/build/lib/analysis/actions/CustomCommandLineTest.java
index fb28f70d6e..f43e1767bf 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/actions/CustomCommandLineTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/actions/CustomCommandLineTest.java
@@ -17,9 +17,10 @@ import static com.google.common.truth.Truth.assertThat;
import com.google.common.collect.ImmutableList;
import com.google.devtools.build.lib.actions.Artifact;
+import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.Builder;
+import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.VectorArg;
import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
import com.google.devtools.build.lib.vfs.PathFragment;
-
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@@ -29,14 +30,18 @@ public class CustomCommandLineTest extends BuildViewTestCase {
@Test
public void testAddBeforeEachPath() {
- CustomCommandLine commandLine = new CustomCommandLine.Builder()
- .add("foo")
- .addBeforeEachPath(
- "-I", ImmutableList.of(PathFragment.create("/path1"), PathFragment.create("/path2")))
- .add("bar")
- .addBeforeEachPath("-I", ImmutableList.<PathFragment>of())
- .add("baz")
- .build();
+ CustomCommandLine commandLine =
+ new Builder()
+ .add("foo")
+ .add(
+ VectorArg.of(
+ ImmutableList.of(
+ PathFragment.create("/path1"), PathFragment.create("/path2")))
+ .beforeEach("-I"))
+ .add("bar")
+ .add(VectorArg.of(ImmutableList.<PathFragment>of()).beforeEach("-I"))
+ .add("baz")
+ .build();
assertThat(commandLine.arguments())
.containsExactly("foo", "-I", "/path1", "-I", "/path2", "bar", "baz")
.inOrder();
@@ -44,13 +49,16 @@ public class CustomCommandLineTest extends BuildViewTestCase {
@Test
public void testAddBeforeEach() {
- CustomCommandLine commandLine = new CustomCommandLine.Builder()
- .add("foo")
- .addBeforeEach("-D", ImmutableList.<String>of())
- .add("bar")
- .addBeforeEach("-D", ImmutableList.of("DEBUG=42", "ENABLE_QUANTUM", "__OBJC__"))
- .add("baz")
- .build();
+ CustomCommandLine commandLine =
+ new Builder()
+ .add("foo")
+ .add(VectorArg.of(ImmutableList.<String>of()).beforeEach("-D"))
+ .add("bar")
+ .add(
+ VectorArg.of(ImmutableList.of("DEBUG=42", "ENABLE_QUANTUM", "__OBJC__"))
+ .beforeEach("-D"))
+ .add("baz")
+ .build();
assertThat(commandLine.arguments())
.containsExactly(
"foo", "bar", "-D", "DEBUG=42", "-D", "ENABLE_QUANTUM", "-D", "__OBJC__", "baz")
@@ -59,14 +67,18 @@ public class CustomCommandLineTest extends BuildViewTestCase {
@Test
public void testAddBeforeEachExecPath() throws Exception {
- CustomCommandLine commandLine = new CustomCommandLine.Builder()
- .add("foo")
- .addBeforeEachExecPath("-l",
- ImmutableList.of(getSourceArtifact("pkg/util.a"), getSourceArtifact("pkg2/extra.a")))
- .add("bar")
- .addBeforeEachExecPath("-l", ImmutableList.<Artifact>of())
- .add("baz")
- .build();
+ CustomCommandLine commandLine =
+ new Builder()
+ .add("foo")
+ .add(
+ VectorArg.of(
+ ImmutableList.of(
+ getSourceArtifact("pkg/util.a"), getSourceArtifact("pkg2/extra.a")))
+ .beforeEach("-l"))
+ .add("bar")
+ .add(VectorArg.of(ImmutableList.<Artifact>of()).beforeEach("-l"))
+ .add("baz")
+ .build();
assertThat(commandLine.arguments())
.containsExactly("foo", "-l", "pkg/util.a", "-l", "pkg2/extra.a", "bar", "baz")
.inOrder();
@@ -74,13 +86,14 @@ public class CustomCommandLineTest extends BuildViewTestCase {
@Test
public void testAddFormatEach() {
- CustomCommandLine commandLine = new CustomCommandLine.Builder()
- .add("foo")
- .addFormatEach("-X'%s'", ImmutableList.<String>of())
- .add("bar")
- .addFormatEach("-X'%s'", ImmutableList.of("42", "1011"))
- .add("baz")
- .build();
+ CustomCommandLine commandLine =
+ new Builder()
+ .add("foo")
+ .add(VectorArg.of(ImmutableList.<String>of()).formatEach("-X'%s'"))
+ .add("bar")
+ .add(VectorArg.of(ImmutableList.of("42", "1011")).formatEach("-X'%s'"))
+ .add("baz")
+ .build();
assertThat(commandLine.arguments())
.containsExactly("foo", "bar", "-X'42'", "-X'1011'", "baz")
.inOrder();
diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java
index c2df07bc0d..41927eb6bf 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java
@@ -67,6 +67,8 @@ import com.google.devtools.build.lib.analysis.OutputGroupProvider;
import com.google.devtools.build.lib.analysis.RunfilesSupport;
import com.google.devtools.build.lib.analysis.actions.BinaryFileWriteAction;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine;
+import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.Builder;
+import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.VectorArg;
import com.google.devtools.build.lib.analysis.actions.FileWriteAction;
import com.google.devtools.build.lib.analysis.actions.ParameterFileWriteAction;
import com.google.devtools.build.lib.analysis.actions.SpawnAction;
@@ -2155,16 +2157,19 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
String archiveRoot = targetDevices.contains("watch") ? "." : "1.storyboardc";
assertThat(compileAction.getOutputs()).containsExactly(storyboardZip);
assertThat(compileAction.getArguments())
- .containsExactlyElementsIn(new CustomCommandLine.Builder()
- .add(MOCK_IBTOOLWRAPPER_PATH)
- .add(storyboardZip.getExecPathString())
- .add(archiveRoot) // archive root
- .add("--minimum-deployment-target").add(minimumOsVersion.toString())
- .add("--module").add("x")
- .addBeforeEach("--target-device", targetDevices)
- .add("x/1.storyboard")
- .build()
- .arguments())
+ .containsExactlyElementsIn(
+ new Builder()
+ .add(MOCK_IBTOOLWRAPPER_PATH)
+ .add(storyboardZip.getExecPathString())
+ .add(archiveRoot) // archive root
+ .add("--minimum-deployment-target")
+ .add(minimumOsVersion.toString())
+ .add("--module")
+ .add("x")
+ .add(VectorArg.of(targetDevices).beforeEach("--target-device"))
+ .add("x/1.storyboard")
+ .build()
+ .arguments())
.inOrder();
storyboardZip = getBinArtifact("x/ja.lproj/loc.storyboard.zip", target);
@@ -2176,15 +2181,19 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
assertThat(compileAction.getOutputs()).containsExactly(storyboardZip);
archiveRoot = targetDevices.contains("watch") ? "ja.lproj/" : "ja.lproj/loc.storyboardc";
assertThat(compileAction.getArguments())
- .containsExactlyElementsIn(new CustomCommandLine.Builder()
- .add(MOCK_IBTOOLWRAPPER_PATH)
- .add(storyboardZip.getExecPathString())
- .add(archiveRoot) // archive root
- .add("--minimum-deployment-target").add(minimumOsVersion.toString())
- .add("--module").add("x")
- .addBeforeEach("--target-device", targetDevices)
- .add("x/ja.lproj/loc.storyboard")
- .build().arguments())
+ .containsExactlyElementsIn(
+ new Builder()
+ .add(MOCK_IBTOOLWRAPPER_PATH)
+ .add(storyboardZip.getExecPathString())
+ .add(archiveRoot) // archive root
+ .add("--minimum-deployment-target")
+ .add(minimumOsVersion.toString())
+ .add("--module")
+ .add("x")
+ .add(VectorArg.of(targetDevices).beforeEach("--target-device"))
+ .add("x/ja.lproj/loc.storyboard")
+ .build()
+ .arguments())
.inOrder();
}