summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2025-02-21 15:31:29 -0800
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2025-02-21 15:31:29 -0800
commitff5a9c36f906accadb520cd479f876daf1d4587d (patch)
tree5f55e2d0b02a90ddc9f598ec33bd1f7a54f196c2 /java
parent2cb77e066ae2548db00cfaba95665141aa3cfc02 (diff)
parentb361442aa66c644efba22c6c3da846ac0644d86a (diff)
Merge "Implement host_common_data property for cc, java, rust and sh test modules" into main
Diffstat (limited to 'java')
-rw-r--r--java/app.go1
-rw-r--r--java/java.go6
-rw-r--r--java/java_test.go23
-rw-r--r--java/robolectric.go1
4 files changed, 31 insertions, 0 deletions
diff --git a/java/app.go b/java/app.go
index 7580db4c6..17548e74a 100644
--- a/java/app.go
+++ b/java/app.go
@@ -1646,6 +1646,7 @@ func (a *AndroidTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
a.data = append(a.data, android.PathsForModuleSrc(ctx, a.testProperties.Device_common_data)...)
a.data = append(a.data, android.PathsForModuleSrc(ctx, a.testProperties.Device_first_data)...)
a.data = append(a.data, android.PathsForModuleSrc(ctx, a.testProperties.Device_first_prefer32_data)...)
+ a.data = append(a.data, android.PathsForModuleSrc(ctx, a.testProperties.Host_common_data)...)
// Install test deps
if !ctx.Config().KatiEnabled() {
diff --git a/java/java.go b/java/java.go
index 505612031..b18c56130 100644
--- a/java/java.go
+++ b/java/java.go
@@ -1549,6 +1549,11 @@ type testProperties struct {
// host test.
Device_first_prefer32_data []string `android:"path_device_first_prefer32"`
+ // Same as data, but will add dependencies on modules using the host's os variation and
+ // the common arch variation. Useful for a device test that wants to depend on a host
+ // module, for example to include a custom Tradefed test runner.
+ Host_common_data []string `android:"path_host_common"`
+
// Flag to indicate whether or not to create test config automatically. If AndroidTest.xml
// doesn't exist next to the Android.bp, this attribute doesn't need to be set to true
// explicitly.
@@ -1847,6 +1852,7 @@ func (j *Test) generateAndroidBuildActionsWithConfig(ctx android.ModuleContext,
j.data = append(j.data, android.PathsForModuleSrc(ctx, j.testProperties.Device_common_data)...)
j.data = append(j.data, android.PathsForModuleSrc(ctx, j.testProperties.Device_first_data)...)
j.data = append(j.data, android.PathsForModuleSrc(ctx, j.testProperties.Device_first_prefer32_data)...)
+ j.data = append(j.data, android.PathsForModuleSrc(ctx, j.testProperties.Host_common_data)...)
j.extraTestConfigs = android.PathsForModuleSrc(ctx, j.testProperties.Test_options.Extra_test_configs)
diff --git a/java/java_test.go b/java/java_test.go
index 636a0c891..a6290a628 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -585,6 +585,29 @@ func TestTest(t *testing.T) {
}
}
+func TestHostCommonData(t *testing.T) {
+ t.Parallel()
+ ctx, _ := testJava(t, `
+ java_library_host {
+ name: "host",
+ srcs: ["a.java"],
+ }
+
+ java_test {
+ name: "foo",
+ srcs: ["a.java"],
+ host_common_data: [":host"],
+ }
+ `)
+
+ foo := ctx.ModuleForTests(t, "foo", "android_common").Module().(*Test)
+ host := ctx.ModuleForTests(t, "host", ctx.Config().BuildOSCommonTarget.String()).Module().(*Library)
+
+ if g, w := foo.data.RelativeToTop().Strings(), []string{host.outputFile.RelativeToTop().String()}; !slices.Equal(g, w) {
+ t.Errorf("expected test data %q, got %q\n", w, g)
+ }
+}
+
func TestHostBinaryNoJavaDebugInfoOverride(t *testing.T) {
t.Parallel()
bp := `
diff --git a/java/robolectric.go b/java/robolectric.go
index 5dcc7dd81..be369f780 100644
--- a/java/robolectric.go
+++ b/java/robolectric.go
@@ -168,6 +168,7 @@ func (r *robolectricTest) GenerateAndroidBuildActions(ctx android.ModuleContext)
r.data = append(r.data, android.PathsForModuleSrc(ctx, r.testProperties.Device_common_data)...)
r.data = append(r.data, android.PathsForModuleSrc(ctx, r.testProperties.Device_first_data)...)
r.data = append(r.data, android.PathsForModuleSrc(ctx, r.testProperties.Device_first_prefer32_data)...)
+ r.data = append(r.data, android.PathsForModuleSrc(ctx, r.testProperties.Host_common_data)...)
var ok bool
var instrumentedApp *JavaInfo