diff options
author | 2017-07-06 07:07:48 -0400 | |
---|---|---|
committer | 2017-07-06 07:14:21 -0400 | |
commit | 4ca8b8f98f043ef624b2d1605d658aa39c2c63dc (patch) | |
tree | ff8c8136671d594ef197e249d3b50def7d516b7d /src/test/java/com | |
parent | 3903c92b4d7115bea2be275a0430617f31bd7182 (diff) |
Android tests: prepare tests for parameter files
Prepare tests for an upcoming change where some
Android actions will use a parameter file, because
they expect command line flags with lists of files
and the list separators don't work on Windows.
See https://github.com/bazelbuild/bazel/issues/3264
RELNOTES: none
PiperOrigin-RevId: 161064058
Diffstat (limited to 'src/test/java/com')
3 files changed, 20 insertions, 21 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java index 833cd9c6d3..d8e079ea11 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java @@ -688,6 +688,14 @@ public abstract class BuildViewTestCase extends FoundationTestCase { return (SpawnAction) getGeneratingAction(artifact); } + protected final List<String> getGeneratingSpawnActionArgs(Artifact artifact) { + SpawnAction a = getGeneratingSpawnAction(artifact); + ParameterFileWriteAction p = findParamsFileAction(a); + return p == null + ? a.getArguments() + : ImmutableList.copyOf(Iterables.concat(a.getArguments(), p.getContents())); + } + protected SpawnAction getGeneratingSpawnAction(ConfiguredTarget target, String outputName) { return getGeneratingSpawnAction( Iterables.find(getFilesToBuild(target), artifactNamed(outputName))); diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidDataBindingTest.java b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidDataBindingTest.java index 93d5779c43..38ad88e592 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidDataBindingTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidDataBindingTest.java @@ -120,13 +120,13 @@ public class AndroidDataBindingTest extends AndroidBuildViewTestCase { // output: Artifact libResourceInfoOutput = getFirstArtifactEndingWith(allArtifacts, "databinding/lib_with_data_binding/layout-info.zip"); - assertThat(getGeneratingSpawnAction(libResourceInfoOutput).getArguments()) + assertThat(getGeneratingSpawnActionArgs(libResourceInfoOutput)) .containsAllOf("--dataBindingInfoOut", libResourceInfoOutput.getExecPathString()) .inOrder(); Artifact binResourceInfoOutput = getFirstArtifactEndingWith(allArtifacts, "databinding/app/layout-info.zip"); - assertThat(getGeneratingSpawnAction(binResourceInfoOutput).getArguments()) + assertThat(getGeneratingSpawnActionArgs(binResourceInfoOutput)) .containsAllOf("--dataBindingInfoOut", binResourceInfoOutput.getExecPathString()) .inOrder(); diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidLibraryTest.java b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidLibraryTest.java index b8298e2ea9..b21353a1ce 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidLibraryTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidLibraryTest.java @@ -690,8 +690,7 @@ public class AndroidLibraryTest extends AndroidBuildViewTestCase { "<resources><string name = 'hello'>Hello Android!</string></resources>"); ConfiguredTarget resource = getConfiguredTarget("//c/b/m/a:r"); - List<String> args = ((SpawnAction) getGeneratingAction(getResourceArtifact(resource))) - .getArguments(); + List<String> args = getGeneratingSpawnActionArgs(getResourceArtifact(resource)); assertPrimaryResourceDirs(resource, ImmutableList.of("c/b/m/a/b_/res"), args); } @@ -706,8 +705,7 @@ public class AndroidLibraryTest extends AndroidBuildViewTestCase { "<resources><string name = 'hello'>Hello Android!</string></resources>"); ConfiguredTarget resource = getConfiguredTarget("//java/android:r"); - List<String> args = ((SpawnAction) getGeneratingAction(getResourceArtifact(resource))) - .getArguments(); + List<String> args = getGeneratingSpawnActionArgs(getResourceArtifact(resource)); assertPrimaryResourceDirs(resource, ImmutableList.of("java/android/res"), args); } @@ -724,8 +722,7 @@ public class AndroidLibraryTest extends AndroidBuildViewTestCase { "<resources><string name = 'hello'>Hello Android!</string></resources>"); ConfiguredTarget resource = getConfiguredTarget("//java/android:r"); - List<String> args = ((SpawnAction) getGeneratingAction(getResourceArtifact(resource))) - .getArguments(); + List<String> args = getGeneratingSpawnActionArgs(getResourceArtifact(resource)); assertPrimaryResourceDirs(resource, ImmutableList.of("java/android/res"), args); } @@ -740,8 +737,7 @@ public class AndroidLibraryTest extends AndroidBuildViewTestCase { "exports_files(['res/values/strings.xml'])"); ConfiguredTarget resource = getConfiguredTarget("//java/android:r"); - List<String> args = ((SpawnAction) getGeneratingAction(getResourceArtifact(resource))) - .getArguments(); + List<String> args = getGeneratingSpawnActionArgs(getResourceArtifact(resource)); assertPrimaryResourceDirs(resource, ImmutableList.of("java/other/res"), args); assertNoEvents(); } @@ -759,8 +755,7 @@ public class AndroidLibraryTest extends AndroidBuildViewTestCase { ")"); ConfiguredTarget resource = getConfiguredTarget("//java/android:r"); - List<String> args = ((SpawnAction) getGeneratingAction(getResourceArtifact(resource))) - .getArguments(); + List<String> args = getGeneratingSpawnActionArgs(getResourceArtifact(resource)); assertPrimaryResourceDirs(resource, ImmutableList.of("java/other/res"), args); assertNoEvents(); } @@ -779,8 +774,7 @@ public class AndroidLibraryTest extends AndroidBuildViewTestCase { "exports_files(['res/values/strings.xml'])"); ConfiguredTarget resource = getConfiguredTarget("//java/android:r"); - List<String> args = ((SpawnAction) getGeneratingAction(getResourceArtifact(resource))) - .getArguments(); + List<String> args = getGeneratingSpawnActionArgs(getResourceArtifact(resource)); assertPrimaryResourceDirs(resource, ImmutableList.of("java/other/res"), args); assertNoEvents(); } @@ -801,8 +795,7 @@ public class AndroidLibraryTest extends AndroidBuildViewTestCase { ")"); ConfiguredTarget resource = getConfiguredTarget("//java/android:r"); - List<String> args = ((SpawnAction) getGeneratingAction(getResourceArtifact(resource))) - .getArguments(); + List<String> args = getGeneratingSpawnActionArgs(getResourceArtifact(resource)); assertPrimaryResourceDirs(resource, ImmutableList.of("java/other/res"), args); assertNoEvents(); } @@ -925,7 +918,7 @@ public class AndroidLibraryTest extends AndroidBuildViewTestCase { " )"); ConfiguredTarget r = getConfiguredTarget("//a/r:r"); assertNoEvents(); - List<String> args = ((SpawnAction) getGeneratingAction(getResourceArtifact(r))).getArguments(); + List<String> args = getGeneratingSpawnActionArgs(getResourceArtifact(r)); assertContainsSublist(args, ImmutableList.of("--packageForR", "com.google.android.bar")); } @@ -1315,8 +1308,7 @@ public class AndroidLibraryTest extends AndroidBuildViewTestCase { " resource_files = ['d2-res/values/strings.xml'],", " )"); ConfiguredTarget resource = getConfiguredTarget("//java/android/resources/d1:d1"); - List<String> args = ((SpawnAction) getGeneratingAction(getResourceArtifact(resource))) - .getArguments(); + List<String> args = getGeneratingSpawnActionArgs(getResourceArtifact(resource)); assertPrimaryResourceDirs(resource, ImmutableList.of("java/android/resources/d1/d1-res"), args); Truth.assertThat(getDirectDependentResourceDirs(resource, args)) .contains("java/android/resources/d2/d2-res"); @@ -1353,8 +1345,7 @@ public class AndroidLibraryTest extends AndroidBuildViewTestCase { " )"); ConfiguredTarget resource = getConfiguredTarget("//java/android/resources/d1:d1"); - List<String> args = ((SpawnAction) getGeneratingAction(getResourceArtifact(resource))) - .getArguments(); + List<String> args = getGeneratingSpawnActionArgs(getResourceArtifact(resource)); assertPrimaryResourceDirs( resource, ImmutableList.of("java/android/resources/d1/d1-res"), args); Truth.assertThat(getDirectDependentResourceDirs(resource, args)) |