aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google
diff options
context:
space:
mode:
authorGravatar jingwen <jingwen@google.com>2017-10-26 21:12:21 +0200
committerGravatar Dmitry Lomov <dslomov@google.com>2017-10-27 16:29:31 +0200
commit19c5039ad76476951095f603aad380051086a832 (patch)
treead5c2ae916e5d02a4bf1f9ec2941a9766dc690cc /src/test/java/com/google
parent67deac4e0dc1d65012cfba4f41ccbfe246306421 (diff)
Modify android_instrumentation_test.instrumentation to accept android_binary instead of android_instrumentation.
GITHUB: #903 RELNOTES: None. PiperOrigin-RevId: 173572553
Diffstat (limited to 'src/test/java/com/google')
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/android/AndroidInstrumentationTestTest.java64
1 files changed, 28 insertions, 36 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidInstrumentationTestTest.java b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidInstrumentationTestTest.java
index 647e583bcc..6084ee30b5 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidInstrumentationTestTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidInstrumentationTestTest.java
@@ -38,11 +38,7 @@ public class AndroidInstrumentationTestTest extends AndroidBuildViewTestCase {
scratch.file(
"java/com/app/BUILD",
"android_binary(",
- " name = 'app1',",
- " manifest = 'AndroidManifest.xml',",
- ")",
- "android_binary(",
- " name = 'app2',",
+ " name = 'app',",
" manifest = 'AndroidManifest.xml',",
")",
"android_binary(",
@@ -52,23 +48,10 @@ public class AndroidInstrumentationTestTest extends AndroidBuildViewTestCase {
scratch.file(
"javatests/com/app/BUILD",
"android_binary(",
- " name = 'instrumentation_app1',",
- " manifest = 'AndroidManifest.xml',",
- ")",
- "android_instrumentation(",
- " name = 'instrumentation1',",
- " target = '//java/com/app:app1',",
- " instrumentation = ':instrumentation_app1',",
- ")",
- "android_binary(",
- " name = 'instrumentation_app2',",
+ " name = 'instrumentation_app',",
+ " instruments = '//java/com/app',",
" manifest = 'AndroidManifest.xml',",
")",
- "android_instrumentation(",
- " name = 'instrumentation2',",
- " target = '//java/com/app:app2',",
- " instrumentation = ':instrumentation_app2',",
- ")",
"android_device_script_fixture(",
" name = 'device_fixture',",
" cmd = 'foo bar',",
@@ -89,10 +72,7 @@ public class AndroidInstrumentationTestTest extends AndroidBuildViewTestCase {
"javatests/com/app/ait/BUILD",
"android_instrumentation_test(",
" name = 'ait',",
- " instrumentations = [",
- " '//javatests/com/app:instrumentation1',",
- " '//javatests/com/app:instrumentation2',",
- " ],",
+ " instrumentation = '//javatests/com/app:instrumentation_app',",
" target_device = '//tools/android/emulated_device:nexus_6',",
" fixtures = [",
" '//javatests/com/app:device_fixture',",
@@ -168,10 +148,8 @@ public class AndroidInstrumentationTestTest extends AndroidBuildViewTestCase {
assertThat(runfiles)
.containsAllOf(
getDeviceFixtureScript(getConfiguredTarget("//javatests/com/app:device_fixture")),
- getInstrumentationApk(getConfiguredTarget("//javatests/com/app:instrumentation1")),
- getTargetApk(getConfiguredTarget("//javatests/com/app:instrumentation1")),
- getInstrumentationApk(getConfiguredTarget("//javatests/com/app:instrumentation2")),
- getTargetApk(getConfiguredTarget("//javatests/com/app:instrumentation2")),
+ getInstrumentationApk(getConfiguredTarget("//javatests/com/app:instrumentation_app")),
+ getTargetApk(getConfiguredTarget("//javatests/com/app:instrumentation_app")),
Iterables.getOnlyElement(
getConfiguredTarget("//javatests/com/app/ait:foo.txt")
.getProvider(FileProvider.class)
@@ -192,13 +170,8 @@ public class AndroidInstrumentationTestTest extends AndroidBuildViewTestCase {
.getFileContents();
assertThat(testExecutableScript)
- .contains(
- "instrumentation_apks=\"javatests/com/app/instrumentation1-instrumentation.apk "
- + "javatests/com/app/instrumentation2-instrumentation.apk\"");
- assertThat(testExecutableScript)
- .contains(
- "target_apks=\"javatests/com/app/instrumentation1-target.apk "
- + "javatests/com/app/instrumentation2-target.apk\"");
+ .contains("instrumentation_apk=\"javatests/com/app/instrumentation_app.apk\"");
+ assertThat(testExecutableScript).contains("target_apk=\"java/com/app/app.apk\"");
assertThat(testExecutableScript).contains("support_apks=\"java/com/app/support.apk\"");
assertThat(testExecutableScript)
.contains(
@@ -224,7 +197,7 @@ public class AndroidInstrumentationTestTest extends AndroidBuildViewTestCase {
")",
"android_instrumentation_test(",
" name = 'ait',",
- " instrumentations = ['//javatests/com/app:instrumentation1'],",
+ " instrumentation = '//javatests/com/app:instrumentation_app',",
" target_device = '//tools/android/emulated_device:nexus_6',",
" fixtures = [",
" ':host_fixture',",
@@ -233,6 +206,25 @@ public class AndroidInstrumentationTestTest extends AndroidBuildViewTestCase {
")");
}
+ @Test
+ public void testInstrumentationBinaryIsInstrumenting() throws Exception {
+ checkError(
+ "javatests/com/app/instr",
+ "ait",
+ "The android_binary target at //javatests/com/app/instr:app "
+ + "is missing an 'instruments' attribute",
+ "android_binary(",
+ " name = 'app',",
+ " srcs = ['a.java'],",
+ " manifest = 'AndroidManifest.xml',",
+ ")",
+ "android_instrumentation_test(",
+ " name = 'ait',",
+ " instrumentation = ':app',",
+ " target_device = '//tools/android/emulated_device:nexus_6',",
+ ")");
+ }
+
private static Artifact getDeviceFixtureScript(ConfiguredTarget deviceScriptFixture) {
return getFirstArtifactEndingWith(
deviceScriptFixture.getProvider(FileProvider.class).getFilesToBuild(), ".sh");