diff options
author | Paul Duffin <paulduffin@google.com> | 2019-03-20 12:45:53 +0000 |
---|---|---|
committer | Paul Duffin <paulduffin@google.com> | 2019-03-25 11:48:01 +0000 |
commit | 42df144fd4c18171b76ed15e6c4e8ab4cf9749cd (patch) | |
tree | a46003684d42098a85d593000e860d754653026e /java/androidmk.go | |
parent | 789b84b12f23389676f848eaf80dc0469eb64919 (diff) | |
download | android_build_soong-42df144fd4c18171b76ed15e6c4e8ab4cf9749cd.tar.gz android_build_soong-42df144fd4c18171b76ed15e6c4e8ab4cf9749cd.tar.bz2 android_build_soong-42df144fd4c18171b76ed15e6c4e8ab4cf9749cd.zip |
Add java_test_helper_library
Extracts testSuiteComponent() function to reduce duplication.
Bug: 128969758
Test: atest CtsJdwpTestCases
Change-Id: I23746b18112d22f8670666f429a665b34b1955fd
Diffstat (limited to 'java/androidmk.go')
-rw-r--r-- | java/androidmk.go | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/java/androidmk.go b/java/androidmk.go index 5b4f738a..908286a7 100644 --- a/java/androidmk.go +++ b/java/androidmk.go @@ -95,16 +95,21 @@ func (library *Library) AndroidMk() android.AndroidMkData { } } +// Called for modules that are a component of a test suite. +func testSuiteComponent(w io.Writer, test_suites []string) { + fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests") + if len(test_suites) > 0 { + fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=", + strings.Join(test_suites, " ")) + } else { + fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite") + } +} + func (j *Test) AndroidMk() android.AndroidMkData { data := j.Library.AndroidMk() data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) { - fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests") - if len(j.testProperties.Test_suites) > 0 { - fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=", - strings.Join(j.testProperties.Test_suites, " ")) - } else { - fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite") - } + testSuiteComponent(w, j.testProperties.Test_suites) if j.testConfig != nil { fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", j.testConfig.String()) } @@ -115,6 +120,15 @@ func (j *Test) AndroidMk() android.AndroidMkData { return data } +func (j *TestHelperLibrary) AndroidMk() android.AndroidMkData { + data := j.Library.AndroidMk() + data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) { + testSuiteComponent(w, j.testHelperLibraryProperties.Test_suites) + }) + + return data +} + func (prebuilt *Import) AndroidMk() android.AndroidMkData { return android.AndroidMkData{ Class: "JAVA_LIBRARIES", @@ -321,13 +335,7 @@ func (a *AndroidApp) getOverriddenPackages() []string { func (a *AndroidTest) AndroidMk() android.AndroidMkData { data := a.AndroidApp.AndroidMk() data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) { - fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests") - if len(a.testProperties.Test_suites) > 0 { - fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=", - strings.Join(a.testProperties.Test_suites, " ")) - } else { - fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite") - } + testSuiteComponent(w, a.testProperties.Test_suites) if a.testConfig != nil { fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", a.testConfig.String()) } @@ -340,13 +348,7 @@ func (a *AndroidTest) AndroidMk() android.AndroidMkData { func (a *AndroidTestHelperApp) AndroidMk() android.AndroidMkData { data := a.AndroidApp.AndroidMk() data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) { - fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests") - if len(a.appTestHelperAppProperties.Test_suites) > 0 { - fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=", - strings.Join(a.appTestHelperAppProperties.Test_suites, " ")) - } else { - fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite") - } + testSuiteComponent(w, a.appTestHelperAppProperties.Test_suites) }) return data |