diff options
Diffstat (limited to 'java')
-rw-r--r-- | java/app.go | 1 | ||||
-rw-r--r-- | java/java.go | 6 | ||||
-rw-r--r-- | java/java_test.go | 23 | ||||
-rw-r--r-- | java/robolectric.go | 1 |
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 |