diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/rules/android/AndroidLocalTestTest.java | 20 | ||||
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/rules/android/BUILD | 1 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidLocalTestTest.java b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidLocalTestTest.java index b28eb2e49f..b9726cd607 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidLocalTestTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidLocalTestTest.java @@ -18,6 +18,7 @@ import static com.google.common.truth.Truth.assertThat; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.actions.util.ActionsTestUtil; import com.google.devtools.build.lib.analysis.ConfiguredTarget; +import com.google.devtools.build.lib.rules.java.JavaPrimaryClassProvider; import com.google.devtools.build.lib.testutil.MoreAsserts; import java.util.List; import org.junit.Test; @@ -161,6 +162,25 @@ public abstract class AndroidLocalTestTest extends AbstractAndroidLocalTestTestB assertThat(resourceApk).isNull(); } + /** + * Tests that the Java package can be correctly inferred from the path to a target, not just the + * path to the corresponding BUILD file. + */ + @Test + public void testInferredJavaPackageFromPackageName() throws Exception { + useConfiguration("--android_decouple_data_processing"); + + ConfiguredTarget target = + scratchConfiguredTarget( + "java-src/test", + "test/java/foo/bar", + "android_local_test(name ='test/java/foo/bar',", + " manifest = 'AndroidManifest.xml')"); + + assertThat(target.getProvider(JavaPrimaryClassProvider.class).getPrimaryClass()) + .isEqualTo("foo.bar"); + } + @Override protected String getRuleName() { return "android_local_test"; diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/BUILD b/src/test/java/com/google/devtools/build/lib/rules/android/BUILD index 3da5c1b498..b04f6061cf 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/android/BUILD +++ b/src/test/java/com/google/devtools/build/lib/rules/android/BUILD @@ -340,6 +340,7 @@ java_library( ":AbstractAndroidLocalTestTestBase", "//src/main/java/com/google/devtools/build/lib:android-rules", "//src/main/java/com/google/devtools/build/lib:build-base", + "//src/main/java/com/google/devtools/build/lib:java-rules", "//src/main/java/com/google/devtools/build/lib:util", "//src/main/java/com/google/devtools/build/lib/actions", "//src/test/java/com/google/devtools/build/lib:actions_testutil", |