diff options
author | 2017-09-11 22:25:33 +0200 | |
---|---|---|
committer | 2017-09-12 14:05:28 +0200 | |
commit | bb50580a7f3eb3f4e7c5fba8e92d20e931591a70 (patch) | |
tree | 26b0b3b0e1dcac29980476b38f8ca99a320a6061 /src/test/java/com | |
parent | d24f3cbfc0b3102aaf550a282f26bc9c1ba073bf (diff) |
Inline CustomCommandLine methods that can be expressed using VectorArg.
This whole CL was done using IDE refactoring tools and should be safe.
PiperOrigin-RevId: 168275575
Diffstat (limited to 'src/test/java/com')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/actions/CustomCommandLineTest.java | 347 | ||||
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java | 5 |
2 files changed, 248 insertions, 104 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 96da8ef7ab..856158a601 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 @@ -23,6 +23,7 @@ import com.google.devtools.build.lib.actions.Artifact.SpecialArtifactType; import com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact; import com.google.devtools.build.lib.analysis.actions.CustomCommandLine; 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.collect.nestedset.NestedSet; import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; @@ -165,10 +166,18 @@ public class CustomCommandLineTest { assertThat(builder().addExecPaths(nestedSet(artifact1, artifact2)).build().arguments()) .containsExactly("dir/file1.txt", "dir/file2.txt") .inOrder(); - assertThat(builder().addAll(list(foo("1"), foo("2")), Foo::str).build().arguments()) + assertThat( + builder() + .addAll(VectorArg.of(list(foo("1"), foo("2"))).mapped(Foo::str)) + .build() + .arguments()) .containsExactly("1", "2") .inOrder(); - assertThat(builder().addAll(nestedSet(foo("1"), foo("2")), Foo::str).build().arguments()) + assertThat( + builder() + .addAll(VectorArg.of(nestedSet(foo("1"), foo("2"))).mapped(Foo::str)) + .build() + .arguments()) .containsExactly("1", "2") .inOrder(); @@ -199,102 +208,144 @@ public class CustomCommandLineTest { assertThat(builder().addExecPaths("--arg", nestedSet(artifact1, artifact2)).build().arguments()) .containsExactly("--arg", "dir/file1.txt", "dir/file2.txt") .inOrder(); - assertThat(builder().addAll("--arg", list(foo("1"), foo("2")), Foo::str).build().arguments()) + assertThat( + builder() + .addAll("--arg", VectorArg.of(list(foo("1"), foo("2"))).mapped(Foo::str)) + .build() + .arguments()) .containsExactly("--arg", "1", "2") .inOrder(); assertThat( - builder().addAll("--arg", nestedSet(foo("1"), foo("2")), Foo::str).build().arguments()) + builder() + .addAll("--arg", VectorArg.of(nestedSet(foo("1"), foo("2"))).mapped(Foo::str)) + .build() + .arguments()) .containsExactly("--arg", "1", "2") .inOrder(); } @Test public void testAddJoined() throws Exception { - assertThat(builder().addJoined(":", list("val1", "val2")).build().arguments()) + assertThat(builder().addAll(VectorArg.join(":").each(list("val1", "val2"))).build().arguments()) .containsExactly("val1:val2") .inOrder(); - assertThat(builder().addJoined(":", nestedSet("val1", "val2")).build().arguments()) + assertThat( + builder() + .addAll(VectorArg.join(":").each(nestedSet("val1", "val2"))) + .build() + .arguments()) .containsExactly("val1:val2") .inOrder(); assertThat( builder() - .addJoinedPaths( - ":", list(PathFragment.create("path1"), PathFragment.create("path2"))) + .addPaths( + VectorArg.join(":") + .each(list(PathFragment.create("path1"), PathFragment.create("path2")))) .build() .arguments()) .containsExactly("path1:path2") .inOrder(); assertThat( builder() - .addJoinedPaths( - ":", nestedSet(PathFragment.create("path1"), PathFragment.create("path2"))) + .addPaths( + VectorArg.join(":") + .each( + nestedSet(PathFragment.create("path1"), PathFragment.create("path2")))) .build() .arguments()) .containsExactly("path1:path2") .inOrder(); - assertThat(builder().addJoinedExecPaths(":", list(artifact1, artifact2)).build().arguments()) + assertThat( + builder() + .addExecPaths(VectorArg.join(":").each(list(artifact1, artifact2))) + .build() + .arguments()) .containsExactly("dir/file1.txt:dir/file2.txt") .inOrder(); assertThat( - builder().addJoinedExecPaths(":", nestedSet(artifact1, artifact2)).build().arguments()) + builder() + .addExecPaths(VectorArg.join(":").each(nestedSet(artifact1, artifact2))) + .build() + .arguments()) .containsExactly("dir/file1.txt:dir/file2.txt") .inOrder(); - assertThat(builder().addJoined(":", list(foo("1"), foo("2")), Foo::str).build().arguments()) + assertThat( + builder() + .addAll(VectorArg.join(":").each(list(foo("1"), foo("2"))).mapped(Foo::str)) + .build() + .arguments()) .containsExactly("1:2") .inOrder(); assertThat( - builder().addJoined(":", nestedSet(foo("1"), foo("2")), Foo::str).build().arguments()) + builder() + .addAll(VectorArg.join(":").each(nestedSet(foo("1"), foo("2"))).mapped(Foo::str)) + .build() + .arguments()) .containsExactly("1:2") .inOrder(); - assertThat(builder().addJoined("--arg", ":", list("val1", "val2")).build().arguments()) + assertThat( + builder() + .addAll("--arg", VectorArg.join(":").each(list("val1", "val2"))) + .build() + .arguments()) .containsExactly("--arg", "val1:val2") .inOrder(); - assertThat(builder().addJoined("--arg", ":", nestedSet("val1", "val2")).build().arguments()) + assertThat( + builder() + .addAll("--arg", VectorArg.join(":").each(nestedSet("val1", "val2"))) + .build() + .arguments()) .containsExactly("--arg", "val1:val2") .inOrder(); assertThat( builder() - .addJoinedPaths( - "--arg", ":", list(PathFragment.create("path1"), PathFragment.create("path2"))) + .addPaths( + "--arg", + VectorArg.join(":") + .each(list(PathFragment.create("path1"), PathFragment.create("path2")))) .build() .arguments()) .containsExactly("--arg", "path1:path2") .inOrder(); assertThat( builder() - .addJoinedPaths( + .addPaths( "--arg", - ":", - nestedSet(PathFragment.create("path1"), PathFragment.create("path2"))) + VectorArg.join(":") + .each( + nestedSet(PathFragment.create("path1"), PathFragment.create("path2")))) .build() .arguments()) .containsExactly("--arg", "path1:path2") .inOrder(); assertThat( builder() - .addJoinedExecPaths("--arg", ":", list(artifact1, artifact2)) + .addExecPaths("--arg", VectorArg.join(":").each(list(artifact1, artifact2))) .build() .arguments()) .containsExactly("--arg", "dir/file1.txt:dir/file2.txt") .inOrder(); assertThat( builder() - .addJoinedExecPaths("--arg", ":", nestedSet(artifact1, artifact2)) + .addExecPaths("--arg", VectorArg.join(":").each(nestedSet(artifact1, artifact2))) .build() .arguments()) .containsExactly("--arg", "dir/file1.txt:dir/file2.txt") .inOrder(); assertThat( builder() - .addJoined("--arg", ":", list(foo("1"), foo("2")), Foo::str) + .addAll( + "--arg", VectorArg.join(":").each(list(foo("1"), foo("2"))).mapped(Foo::str)) .build() .arguments()) .containsExactly("--arg", "1:2") .inOrder(); assertThat( builder() - .addJoined("--arg", ":", nestedSet(foo("1"), foo("2")), Foo::str) + .addAll( + "--arg", + VectorArg.join(":").each(nestedSet(foo("1"), foo("2"))).mapped(Foo::str)) .build() .arguments()) .containsExactly("--arg", "1:2") @@ -303,102 +354,133 @@ public class CustomCommandLineTest { @Test public void testAddFormatEach() throws Exception { - assertThat(builder().addFormatEach("-D%s", list("val1", "val2")).build().arguments()) + assertThat( + builder() + .addAll(VectorArg.format("-D%s").each(list("val1", "val2"))) + .build() + .arguments()) .containsExactly("-Dval1", "-Dval2") .inOrder(); - assertThat(builder().addFormatEach("-D%s", nestedSet("val1", "val2")).build().arguments()) + assertThat( + builder() + .addAll(VectorArg.format("-D%s").each(nestedSet("val1", "val2"))) + .build() + .arguments()) .containsExactly("-Dval1", "-Dval2") .inOrder(); assertThat( builder() - .addFormatEachPath( - "-D%s", list(PathFragment.create("path1"), PathFragment.create("path2"))) + .addPaths( + VectorArg.format("-D%s") + .each(list(PathFragment.create("path1"), PathFragment.create("path2")))) .build() .arguments()) .containsExactly("-Dpath1", "-Dpath2") .inOrder(); assertThat( builder() - .addFormatEachPath( - "-D%s", nestedSet(PathFragment.create("path1"), PathFragment.create("path2"))) + .addPaths( + VectorArg.format("-D%s") + .each( + nestedSet(PathFragment.create("path1"), PathFragment.create("path2")))) .build() .arguments()) .containsExactly("-Dpath1", "-Dpath2") .inOrder(); assertThat( - builder().addFormatEachExecPath("-D%s", list(artifact1, artifact2)).build().arguments()) + builder() + .addExecPaths(VectorArg.format("-D%s").each(list(artifact1, artifact2))) + .build() + .arguments()) .containsExactly("-Ddir/file1.txt", "-Ddir/file2.txt") .inOrder(); assertThat( builder() - .addFormatEachExecPath("-D%s", nestedSet(artifact1, artifact2)) + .addExecPaths(VectorArg.format("-D%s").each(nestedSet(artifact1, artifact2))) .build() .arguments()) .containsExactly("-Ddir/file1.txt", "-Ddir/file2.txt") .inOrder(); assertThat( - builder().addFormatEach("-D%s", list(foo("1"), foo("2")), Foo::str).build().arguments()) + builder() + .addAll(VectorArg.format("-D%s").each(list(foo("1"), foo("2"))).mapped(Foo::str)) + .build() + .arguments()) .containsExactly("-D1", "-D2") .inOrder(); assertThat( builder() - .addFormatEach("-D%s", nestedSet(foo("1"), foo("2")), Foo::str) + .addAll( + VectorArg.format("-D%s").each(nestedSet(foo("1"), foo("2"))).mapped(Foo::str)) .build() .arguments()) .containsExactly("-D1", "-D2") .inOrder(); - assertThat(builder().addFormatEach("--arg", "-D%s", list("val1", "val2")).build().arguments()) + assertThat( + builder() + .addAll("--arg", VectorArg.format("-D%s").each(list("val1", "val2"))) + .build() + .arguments()) .containsExactly("--arg", "-Dval1", "-Dval2") .inOrder(); assertThat( - builder().addFormatEach("--arg", "-D%s", nestedSet("val1", "val2")).build().arguments()) + builder() + .addAll("--arg", VectorArg.format("-D%s").each(nestedSet("val1", "val2"))) + .build() + .arguments()) .containsExactly("--arg", "-Dval1", "-Dval2") .inOrder(); assertThat( builder() - .addFormatEachPath( + .addPaths( "--arg", - "-D%s", - list(PathFragment.create("path1"), PathFragment.create("path2"))) + VectorArg.format("-D%s") + .each(list(PathFragment.create("path1"), PathFragment.create("path2")))) .build() .arguments()) .containsExactly("--arg", "-Dpath1", "-Dpath2") .inOrder(); assertThat( builder() - .addFormatEachPath( + .addPaths( "--arg", - "-D%s", - nestedSet(PathFragment.create("path1"), PathFragment.create("path2"))) + VectorArg.format("-D%s") + .each( + nestedSet(PathFragment.create("path1"), PathFragment.create("path2")))) .build() .arguments()) .containsExactly("--arg", "-Dpath1", "-Dpath2") .inOrder(); assertThat( builder() - .addFormatEachExecPath("--arg", "-D%s", list(artifact1, artifact2)) + .addExecPaths("--arg", VectorArg.format("-D%s").each(list(artifact1, artifact2))) .build() .arguments()) .containsExactly("--arg", "-Ddir/file1.txt", "-Ddir/file2.txt") .inOrder(); assertThat( builder() - .addFormatEachExecPath("--arg", "-D%s", nestedSet(artifact1, artifact2)) + .addExecPaths( + "--arg", VectorArg.format("-D%s").each(nestedSet(artifact1, artifact2))) .build() .arguments()) .containsExactly("--arg", "-Ddir/file1.txt", "-Ddir/file2.txt") .inOrder(); assertThat( builder() - .addFormatEach("--arg", "-D%s", list(foo("1"), foo("2")), Foo::str) + .addAll( + "--arg", + VectorArg.format("-D%s").each(list(foo("1"), foo("2"))).mapped(Foo::str)) .build() .arguments()) .containsExactly("--arg", "-D1", "-D2") .inOrder(); assertThat( builder() - .addFormatEach("--arg", "-D%s", nestedSet(foo("1"), foo("2")), Foo::str) + .addAll( + "--arg", + VectorArg.format("-D%s").each(nestedSet(foo("1"), foo("2"))).mapped(Foo::str)) .build() .arguments()) .containsExactly("--arg", "-D1", "-D2") @@ -407,57 +489,74 @@ public class CustomCommandLineTest { @Test public void testAddFormatEachJoined() throws Exception { - assertThat(builder().addFormatEachJoined("-D%s", ":", list("val1", "val2")).build().arguments()) + assertThat( + builder() + .addAll(VectorArg.format("-D%s").join(":").each(list("val1", "val2"))) + .build() + .arguments()) .containsExactly("-Dval1:-Dval2") .inOrder(); assertThat( builder() - .addFormatEachJoined("-D%s", ":", nestedSet("val1", "val2")) + .addAll(VectorArg.format("-D%s").join(":").each(nestedSet("val1", "val2"))) .build() .arguments()) .containsExactly("-Dval1:-Dval2") .inOrder(); assertThat( builder() - .addFormatEachPathJoined( - "-D%s", ":", list(PathFragment.create("path1"), PathFragment.create("path2"))) + .addPaths( + VectorArg.format("-D%s") + .join(":") + .each(list(PathFragment.create("path1"), PathFragment.create("path2")))) .build() .arguments()) .containsExactly("-Dpath1:-Dpath2") .inOrder(); assertThat( builder() - .addFormatEachPathJoined( - "-D%s", - ":", nestedSet(PathFragment.create("path1"), PathFragment.create("path2"))) + .addPaths( + VectorArg.format("-D%s") + .join(":") + .each( + nestedSet(PathFragment.create("path1"), PathFragment.create("path2")))) .build() .arguments()) .containsExactly("-Dpath1:-Dpath2") .inOrder(); assertThat( builder() - .addFormatEachExecPathJoined("-D%s", ":", list(artifact1, artifact2)) + .addExecPaths(VectorArg.format("-D%s").join(":").each(list(artifact1, artifact2))) .build() .arguments()) .containsExactly("-Ddir/file1.txt:-Ddir/file2.txt") .inOrder(); assertThat( builder() - .addFormatEachExecPathJoined("-D%s", ":", nestedSet(artifact1, artifact2)) + .addExecPaths( + VectorArg.format("-D%s").join(":").each(nestedSet(artifact1, artifact2))) .build() .arguments()) .containsExactly("-Ddir/file1.txt:-Ddir/file2.txt") .inOrder(); assertThat( builder() - .addFormatEachJoined("-D%s", ":", list(foo("1"), foo("2")), Foo::str) + .addAll( + VectorArg.format("-D%s") + .join(":") + .each(list(foo("1"), foo("2"))) + .mapped(Foo::str)) .build() .arguments()) .containsExactly("-D1:-D2") .inOrder(); assertThat( builder() - .addFormatEachJoined("-D%s", ":", nestedSet(foo("1"), foo("2")), Foo::str) + .addAll( + VectorArg.format("-D%s") + .join(":") + .each(nestedSet(foo("1"), foo("2"))) + .mapped(Foo::str)) .build() .arguments()) .containsExactly("-D1:-D2") @@ -465,64 +564,78 @@ public class CustomCommandLineTest { assertThat( builder() - .addFormatEachJoined("--arg", "-D%s", ":", list("val1", "val2")) + .addAll("--arg", VectorArg.format("-D%s").join(":").each(list("val1", "val2"))) .build() .arguments()) .containsExactly("--arg", "-Dval1:-Dval2") .inOrder(); assertThat( builder() - .addFormatEachJoined("--arg", "-D%s", ":", nestedSet("val1", "val2")) + .addAll("--arg", VectorArg.format("-D%s").join(":").each(nestedSet("val1", "val2"))) .build() .arguments()) .containsExactly("--arg", "-Dval1:-Dval2") .inOrder(); assertThat( builder() - .addFormatEachPathJoined( + .addPaths( "--arg", - "-D%s", - ":", - list(PathFragment.create("path1"), PathFragment.create("path2"))) + VectorArg.format("-D%s") + .join(":") + .each(list(PathFragment.create("path1"), PathFragment.create("path2")))) .build() .arguments()) .containsExactly("--arg", "-Dpath1:-Dpath2") .inOrder(); assertThat( builder() - .addFormatEachPathJoined( + .addPaths( "--arg", - "-D%s", - ":", - nestedSet(PathFragment.create("path1"), PathFragment.create("path2"))) + VectorArg.format("-D%s") + .join(":") + .each( + nestedSet(PathFragment.create("path1"), PathFragment.create("path2")))) .build() .arguments()) .containsExactly("--arg", "-Dpath1:-Dpath2") .inOrder(); assertThat( builder() - .addFormatEachExecPathJoined("--arg", "-D%s", ":", list(artifact1, artifact2)) + .addExecPaths( + "--arg", VectorArg.format("-D%s").join(":").each(list(artifact1, artifact2))) .build() .arguments()) .containsExactly("--arg", "-Ddir/file1.txt:-Ddir/file2.txt") .inOrder(); assertThat( builder() - .addFormatEachExecPathJoined("--arg", "-D%s", ":", nestedSet(artifact1, artifact2)) + .addExecPaths( + "--arg", + VectorArg.format("-D%s").join(":").each(nestedSet(artifact1, artifact2))) .build() .arguments()) .containsExactly("--arg", "-Ddir/file1.txt:-Ddir/file2.txt") .inOrder(); assertThat( builder() - .addFormatEachJoined("--arg", "-D%s", ":", list(foo("1"), foo("2")), Foo::str) + .addAll( + "--arg", + VectorArg.format("-D%s") + .join(":") + .each(list(foo("1"), foo("2"))) + .mapped(Foo::str)) .build() .arguments()) .containsExactly("--arg", "-D1:-D2") .inOrder(); assertThat( builder() - .addFormatEachJoined("--arg", "-D%s", ":", nestedSet(foo("1"), foo("2")), Foo::str) + .addAll( + "--arg", + VectorArg.format("-D%s") + .join(":") + .each(nestedSet(foo("1"), foo("2"))) + .mapped(Foo::str)) .build() .arguments()) .containsExactly("--arg", "-D1:-D2") @@ -531,46 +644,64 @@ public class CustomCommandLineTest { @Test public void testAddBeforeEach() throws Exception { - assertThat(builder().addBeforeEach("-D", list("val1", "val2")).build().arguments()) + assertThat( + builder() + .addAll(VectorArg.addBefore("-D").each(list("val1", "val2"))) + .build() + .arguments()) .containsExactly("-D", "val1", "-D", "val2") .inOrder(); - assertThat(builder().addBeforeEach("-D", nestedSet("val1", "val2")).build().arguments()) + assertThat( + builder() + .addAll(VectorArg.addBefore("-D").each(nestedSet("val1", "val2"))) + .build() + .arguments()) .containsExactly("-D", "val1", "-D", "val2") .inOrder(); assertThat( builder() - .addBeforeEachPath( - "-D", list(PathFragment.create("path1"), PathFragment.create("path2"))) + .addPaths( + VectorArg.addBefore("-D") + .each(list(PathFragment.create("path1"), PathFragment.create("path2")))) .build() .arguments()) .containsExactly("-D", "path1", "-D", "path2") .inOrder(); assertThat( builder() - .addBeforeEachPath( - "-D", nestedSet(PathFragment.create("path1"), PathFragment.create("path2"))) + .addPaths( + VectorArg.addBefore("-D") + .each( + nestedSet(PathFragment.create("path1"), PathFragment.create("path2")))) .build() .arguments()) .containsExactly("-D", "path1", "-D", "path2") .inOrder(); assertThat( - builder().addBeforeEachExecPath("-D", list(artifact1, artifact2)).build().arguments()) + builder() + .addExecPaths(VectorArg.addBefore("-D").each(list(artifact1, artifact2))) + .build() + .arguments()) .containsExactly("-D", "dir/file1.txt", "-D", "dir/file2.txt") .inOrder(); assertThat( builder() - .addBeforeEachExecPath("-D", nestedSet(artifact1, artifact2)) + .addExecPaths(VectorArg.addBefore("-D").each(nestedSet(artifact1, artifact2))) .build() .arguments()) .containsExactly("-D", "dir/file1.txt", "-D", "dir/file2.txt") .inOrder(); assertThat( - builder().addBeforeEach("-D", list(foo("1"), foo("2")), Foo::str).build().arguments()) + builder() + .addAll(VectorArg.addBefore("-D").each(list(foo("1"), foo("2"))).mapped(Foo::str)) + .build() + .arguments()) .containsExactly("-D", "1", "-D", "2") .inOrder(); assertThat( builder() - .addBeforeEach("-D", nestedSet(foo("1"), foo("2")), Foo::str) + .addAll( + VectorArg.addBefore("-D").each(nestedSet(foo("1"), foo("2"))).mapped(Foo::str)) .build() .arguments()) .containsExactly("-D", "1", "-D", "2") @@ -580,58 +711,74 @@ public class CustomCommandLineTest { @Test public void testAddBeforeEachFormatted() throws Exception { assertThat( - builder().addBeforeEachFormatted("-D", "D%s", list("val1", "val2")).build().arguments()) + builder() + .addAll(VectorArg.addBefore("-D").format("D%s").each(list("val1", "val2"))) + .build() + .arguments()) .containsExactly("-D", "Dval1", "-D", "Dval2") .inOrder(); assertThat( builder() - .addBeforeEachFormatted("-D", "D%s", nestedSet("val1", "val2")) + .addAll(VectorArg.addBefore("-D").format("D%s").each(nestedSet("val1", "val2"))) .build() .arguments()) .containsExactly("-D", "Dval1", "-D", "Dval2") .inOrder(); assertThat( builder() - .addBeforeEachPathFormatted( - "-D", "D%s", list(PathFragment.create("path1"), PathFragment.create("path2"))) + .addPaths( + VectorArg.addBefore("-D") + .format("D%s") + .each(list(PathFragment.create("path1"), PathFragment.create("path2")))) .build() .arguments()) .containsExactly("-D", "Dpath1", "-D", "Dpath2") .inOrder(); assertThat( builder() - .addBeforeEachPathFormatted( - "-D", - "D%s", - nestedSet(PathFragment.create("path1"), PathFragment.create("path2"))) + .addPaths( + VectorArg.addBefore("-D") + .format("D%s") + .each( + nestedSet(PathFragment.create("path1"), PathFragment.create("path2")))) .build() .arguments()) .containsExactly("-D", "Dpath1", "-D", "Dpath2") .inOrder(); assertThat( builder() - .addBeforeEachExecPathFormatted("-D", "D%s", list(artifact1, artifact2)) + .addExecPaths( + VectorArg.addBefore("-D").format("D%s").each(list(artifact1, artifact2))) .build() .arguments()) .containsExactly("-D", "Ddir/file1.txt", "-D", "Ddir/file2.txt") .inOrder(); assertThat( builder() - .addBeforeEachExecPathFormatted("-D", "D%s", nestedSet(artifact1, artifact2)) + .addExecPaths( + VectorArg.addBefore("-D").format("D%s").each(nestedSet(artifact1, artifact2))) .build() .arguments()) .containsExactly("-D", "Ddir/file1.txt", "-D", "Ddir/file2.txt") .inOrder(); assertThat( builder() - .addBeforeEachFormatted("-D", "D%s", list(foo("1"), foo("2")), Foo::str) + .addAll( + VectorArg.addBefore("-D") + .format("D%s") + .each(list(foo("1"), foo("2"))) + .mapped(Foo::str)) .build() .arguments()) .containsExactly("-D", "D1", "-D", "D2") .inOrder(); assertThat( builder() - .addBeforeEachFormatted("-D", "D%s", nestedSet(foo("1"), foo("2")), Foo::str) + .addAll( + VectorArg.addBefore("-D") + .format("D%s") + .each(nestedSet(foo("1"), foo("2"))) + .mapped(Foo::str)) .build() .arguments()) .containsExactly("-D", "D1", "-D", "D2") @@ -695,22 +842,18 @@ public class CustomCommandLineTest { .addPaths(ImmutableList.of()) .addExecPaths((ImmutableList<Artifact>) null) .addExecPaths(ImmutableList.of()) - .addAll((ImmutableList<Foo>) null, Foo::str) - .addAll(ImmutableList.of(), Foo::str) .addAll((NestedSet<String>) null) .addAll(NestedSetBuilder.emptySet(Order.STABLE_ORDER)) .addPaths((NestedSet<PathFragment>) null) .addPaths(NestedSetBuilder.emptySet(Order.STABLE_ORDER)) .addExecPaths((NestedSet<Artifact>) null) .addExecPaths(NestedSetBuilder.emptySet(Order.STABLE_ORDER)) - .addAll((NestedSet<Foo>) null, Foo::str) - .addAll(NestedSetBuilder.emptySet(Order.STABLE_ORDER), Foo::str) + .addAll(VectorArg.of((NestedSet<String>) null)) + .addAll(VectorArg.of(NestedSetBuilder.<String>emptySet(Order.STABLE_ORDER))) .addAll("foo", (ImmutableList<String>) null) .addAll("foo", ImmutableList.of()) .addPaths("foo", (ImmutableList<PathFragment>) null) .addPaths("foo", ImmutableList.of()) - .addAll("foo", (ImmutableList<Foo>) null, Foo::str) - .addAll("foo", ImmutableList.of(), Foo::str) .addExecPaths("foo", (ImmutableList<Artifact>) null) .addExecPaths("foo", ImmutableList.of()) .addAll("foo", (NestedSet<String>) null) @@ -719,8 +862,8 @@ public class CustomCommandLineTest { .addPaths("foo", NestedSetBuilder.emptySet(Order.STABLE_ORDER)) .addExecPaths("foo", (NestedSet<Artifact>) null) .addExecPaths("foo", NestedSetBuilder.emptySet(Order.STABLE_ORDER)) - .addAll("foo", (NestedSet<Foo>) null, Foo::str) - .addAll("foo", NestedSetBuilder.emptySet(Order.STABLE_ORDER), Foo::str) + .addAll("foo", VectorArg.of((NestedSet<String>) null)) + .addAll("foo", VectorArg.of(NestedSetBuilder.<String>emptySet(Order.STABLE_ORDER))) .addCustomMultiArgv(null) .addPlaceholderTreeArtifactExecPath("foo", null) .build(); 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 b48d242c6b..3a7647e172 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,7 @@ 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; @@ -2217,7 +2218,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase { .add("--minimum-deployment-target", minimumOsVersion.toString()) .add("--module") .add("x") - .addBeforeEach("--target-device", targetDevices) + .addAll(VectorArg.addBefore("--target-device").each(targetDevices)) .add("x/1.storyboard") .build() .arguments()) @@ -2238,7 +2239,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase { .add("--minimum-deployment-target", minimumOsVersion.toString()) .add("--module") .add("x") - .addBeforeEach("--target-device", targetDevices) + .addAll(VectorArg.addBefore("--target-device").each(targetDevices)) .add("x/ja.lproj/loc.storyboard") .build() .arguments()) |