Java test code clean-up
Remove unused parameters and make testJava return the config. Test: Ran all java tests. Change-Id: Iaa123f3fd93188e2f55452b887e1d340429cc710
This commit is contained in:
parent
63f4b57a7f
commit
f9a0443a9c
|
@ -15,18 +15,20 @@
|
||||||
package java
|
package java
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"android/soong/android"
|
|
||||||
"bytes"
|
"bytes"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"android/soong/android"
|
||||||
)
|
)
|
||||||
|
|
||||||
type testAndroidMk struct {
|
type testAndroidMk struct {
|
||||||
*testing.T
|
*testing.T
|
||||||
body []byte
|
body []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
type testAndroidMkModule struct {
|
type testAndroidMkModule struct {
|
||||||
*testing.T
|
*testing.T
|
||||||
props map[string]string
|
props map[string]string
|
||||||
|
@ -115,30 +117,26 @@ func getAndroidMk(t *testing.T, ctx *android.TestContext, config android.Config,
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRequired(t *testing.T) {
|
func TestRequired(t *testing.T) {
|
||||||
config := testConfig(nil)
|
ctx, config := testJava(t, `
|
||||||
ctx := testContext(config, `
|
|
||||||
java_library {
|
java_library {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["a.java"],
|
srcs: ["a.java"],
|
||||||
required: ["libfoo"],
|
required: ["libfoo"],
|
||||||
}
|
}
|
||||||
`, nil)
|
`)
|
||||||
run(t, ctx, config)
|
|
||||||
|
|
||||||
mk := getAndroidMk(t, ctx, config, "foo")
|
mk := getAndroidMk(t, ctx, config, "foo")
|
||||||
mk.moduleFor("foo").hasRequired("libfoo")
|
mk.moduleFor("foo").hasRequired("libfoo")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHostdex(t *testing.T) {
|
func TestHostdex(t *testing.T) {
|
||||||
config := testConfig(nil)
|
ctx, config := testJava(t, `
|
||||||
ctx := testContext(config, `
|
|
||||||
java_library {
|
java_library {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["a.java"],
|
srcs: ["a.java"],
|
||||||
hostdex: true,
|
hostdex: true,
|
||||||
}
|
}
|
||||||
`, nil)
|
`)
|
||||||
run(t, ctx, config)
|
|
||||||
|
|
||||||
mk := getAndroidMk(t, ctx, config, "foo")
|
mk := getAndroidMk(t, ctx, config, "foo")
|
||||||
mk.moduleFor("foo")
|
mk.moduleFor("foo")
|
||||||
|
@ -146,16 +144,14 @@ func TestHostdex(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHostdexRequired(t *testing.T) {
|
func TestHostdexRequired(t *testing.T) {
|
||||||
config := testConfig(nil)
|
ctx, config := testJava(t, `
|
||||||
ctx := testContext(config, `
|
|
||||||
java_library {
|
java_library {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["a.java"],
|
srcs: ["a.java"],
|
||||||
hostdex: true,
|
hostdex: true,
|
||||||
required: ["libfoo"],
|
required: ["libfoo"],
|
||||||
}
|
}
|
||||||
`, nil)
|
`)
|
||||||
run(t, ctx, config)
|
|
||||||
|
|
||||||
mk := getAndroidMk(t, ctx, config, "foo")
|
mk := getAndroidMk(t, ctx, config, "foo")
|
||||||
mk.moduleFor("foo").hasRequired("libfoo")
|
mk.moduleFor("foo").hasRequired("libfoo")
|
||||||
|
@ -163,8 +159,7 @@ func TestHostdexRequired(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHostdexSpecificRequired(t *testing.T) {
|
func TestHostdexSpecificRequired(t *testing.T) {
|
||||||
config := testConfig(nil)
|
ctx, config := testJava(t, `
|
||||||
ctx := testContext(config, `
|
|
||||||
java_library {
|
java_library {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["a.java"],
|
srcs: ["a.java"],
|
||||||
|
@ -175,8 +170,7 @@ func TestHostdexSpecificRequired(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
`, nil)
|
`)
|
||||||
run(t, ctx, config)
|
|
||||||
|
|
||||||
mk := getAndroidMk(t, ctx, config, "foo")
|
mk := getAndroidMk(t, ctx, config, "foo")
|
||||||
mk.moduleFor("foo").hasNoRequired("libfoo")
|
mk.moduleFor("foo").hasNoRequired("libfoo")
|
||||||
|
|
|
@ -43,7 +43,7 @@ var (
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func testAppContext(config android.Config, bp string, fs map[string][]byte) *android.TestContext {
|
func testAppContext(bp string, fs map[string][]byte) *android.TestContext {
|
||||||
appFS := map[string][]byte{}
|
appFS := map[string][]byte{}
|
||||||
for k, v := range fs {
|
for k, v := range fs {
|
||||||
appFS[k] = v
|
appFS[k] = v
|
||||||
|
@ -53,13 +53,13 @@ func testAppContext(config android.Config, bp string, fs map[string][]byte) *and
|
||||||
appFS[file] = nil
|
appFS[file] = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return testContext(config, bp, appFS)
|
return testContext(bp, appFS)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testApp(t *testing.T, bp string) *android.TestContext {
|
func testApp(t *testing.T, bp string) *android.TestContext {
|
||||||
config := testConfig(nil)
|
config := testConfig(nil)
|
||||||
|
|
||||||
ctx := testAppContext(config, bp, nil)
|
ctx := testAppContext(bp, nil)
|
||||||
|
|
||||||
run(t, ctx, config)
|
run(t, ctx, config)
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ func TestResourceDirs(t *testing.T) {
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
t.Run(testCase.name, func(t *testing.T) {
|
t.Run(testCase.name, func(t *testing.T) {
|
||||||
config := testConfig(nil)
|
config := testConfig(nil)
|
||||||
ctx := testContext(config, fmt.Sprintf(bp, testCase.prop), fs)
|
ctx := testContext(fmt.Sprintf(bp, testCase.prop), fs)
|
||||||
run(t, ctx, config)
|
run(t, ctx, config)
|
||||||
|
|
||||||
module := ctx.ModuleForTests("foo", "android_common")
|
module := ctx.ModuleForTests("foo", "android_common")
|
||||||
|
@ -388,7 +388,7 @@ func TestAndroidResources(t *testing.T) {
|
||||||
config.TestProductVariables.EnforceRROExcludedOverlays = testCase.enforceRROExcludedOverlays
|
config.TestProductVariables.EnforceRROExcludedOverlays = testCase.enforceRROExcludedOverlays
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := testAppContext(config, bp, fs)
|
ctx := testAppContext(bp, fs)
|
||||||
run(t, ctx, config)
|
run(t, ctx, config)
|
||||||
|
|
||||||
resourceListToFiles := func(module android.TestingModule, list []string) (files []string) {
|
resourceListToFiles := func(module android.TestingModule, list []string) (files []string) {
|
||||||
|
@ -515,7 +515,7 @@ func TestAppSdkVersion(t *testing.T) {
|
||||||
config.TestProductVariables.Platform_sdk_codename = &test.platformSdkCodename
|
config.TestProductVariables.Platform_sdk_codename = &test.platformSdkCodename
|
||||||
config.TestProductVariables.Platform_sdk_final = &test.platformSdkFinal
|
config.TestProductVariables.Platform_sdk_final = &test.platformSdkFinal
|
||||||
|
|
||||||
ctx := testAppContext(config, bp, nil)
|
ctx := testAppContext(bp, nil)
|
||||||
|
|
||||||
run(t, ctx, config)
|
run(t, ctx, config)
|
||||||
|
|
||||||
|
@ -547,7 +547,7 @@ func TestAppSdkVersion(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestJNIABI(t *testing.T) {
|
func TestJNIABI(t *testing.T) {
|
||||||
ctx := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
|
ctx, _ := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
|
||||||
cc_library {
|
cc_library {
|
||||||
name: "libjni",
|
name: "libjni",
|
||||||
system_shared_libs: [],
|
system_shared_libs: [],
|
||||||
|
@ -620,7 +620,7 @@ func TestJNIABI(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestJNIPackaging(t *testing.T) {
|
func TestJNIPackaging(t *testing.T) {
|
||||||
ctx := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
|
ctx, _ := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
|
||||||
cc_library {
|
cc_library {
|
||||||
name: "libjni",
|
name: "libjni",
|
||||||
system_shared_libs: [],
|
system_shared_libs: [],
|
||||||
|
@ -774,7 +774,7 @@ func TestCertificates(t *testing.T) {
|
||||||
if test.certificateOverride != "" {
|
if test.certificateOverride != "" {
|
||||||
config.TestProductVariables.CertificateOverrides = []string{test.certificateOverride}
|
config.TestProductVariables.CertificateOverrides = []string{test.certificateOverride}
|
||||||
}
|
}
|
||||||
ctx := testAppContext(config, test.bp, nil)
|
ctx := testAppContext(test.bp, nil)
|
||||||
|
|
||||||
run(t, ctx, config)
|
run(t, ctx, config)
|
||||||
foo := ctx.ModuleForTests("foo", "android_common")
|
foo := ctx.ModuleForTests("foo", "android_common")
|
||||||
|
@ -832,7 +832,7 @@ func TestPackageNameOverride(t *testing.T) {
|
||||||
if test.packageNameOverride != "" {
|
if test.packageNameOverride != "" {
|
||||||
config.TestProductVariables.PackageNameOverrides = []string{test.packageNameOverride}
|
config.TestProductVariables.PackageNameOverrides = []string{test.packageNameOverride}
|
||||||
}
|
}
|
||||||
ctx := testAppContext(config, test.bp, nil)
|
ctx := testAppContext(test.bp, nil)
|
||||||
|
|
||||||
run(t, ctx, config)
|
run(t, ctx, config)
|
||||||
foo := ctx.ModuleForTests("foo", "android_common")
|
foo := ctx.ModuleForTests("foo", "android_common")
|
||||||
|
@ -865,7 +865,7 @@ func TestInstrumentationTargetOverridden(t *testing.T) {
|
||||||
`
|
`
|
||||||
config := testConfig(nil)
|
config := testConfig(nil)
|
||||||
config.TestProductVariables.ManifestPackageNameOverrides = []string{"foo:org.dandroid.bp"}
|
config.TestProductVariables.ManifestPackageNameOverrides = []string{"foo:org.dandroid.bp"}
|
||||||
ctx := testAppContext(config, bp, nil)
|
ctx := testAppContext(bp, nil)
|
||||||
|
|
||||||
run(t, ctx, config)
|
run(t, ctx, config)
|
||||||
|
|
||||||
|
@ -879,7 +879,7 @@ func TestInstrumentationTargetOverridden(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestOverrideAndroidApp(t *testing.T) {
|
func TestOverrideAndroidApp(t *testing.T) {
|
||||||
ctx := testJava(t, `
|
ctx, _ := testJava(t, `
|
||||||
android_app {
|
android_app {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["a.java"],
|
srcs: ["a.java"],
|
||||||
|
@ -980,7 +980,7 @@ func TestOverrideAndroidApp(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestOverrideAndroidAppDependency(t *testing.T) {
|
func TestOverrideAndroidAppDependency(t *testing.T) {
|
||||||
ctx := testJava(t, `
|
ctx, _ := testJava(t, `
|
||||||
android_app {
|
android_app {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["a.java"],
|
srcs: ["a.java"],
|
||||||
|
@ -1021,7 +1021,7 @@ func TestOverrideAndroidAppDependency(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAndroidAppImport(t *testing.T) {
|
func TestAndroidAppImport(t *testing.T) {
|
||||||
ctx := testJava(t, `
|
ctx, _ := testJava(t, `
|
||||||
android_app_import {
|
android_app_import {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
apk: "prebuilts/apk/app.apk",
|
apk: "prebuilts/apk/app.apk",
|
||||||
|
@ -1050,7 +1050,7 @@ func TestAndroidAppImport(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAndroidAppImport_NoDexPreopt(t *testing.T) {
|
func TestAndroidAppImport_NoDexPreopt(t *testing.T) {
|
||||||
ctx := testJava(t, `
|
ctx, _ := testJava(t, `
|
||||||
android_app_import {
|
android_app_import {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
apk: "prebuilts/apk/app.apk",
|
apk: "prebuilts/apk/app.apk",
|
||||||
|
@ -1071,7 +1071,7 @@ func TestAndroidAppImport_NoDexPreopt(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAndroidAppImport_Presigned(t *testing.T) {
|
func TestAndroidAppImport_Presigned(t *testing.T) {
|
||||||
ctx := testJava(t, `
|
ctx, _ := testJava(t, `
|
||||||
android_app_import {
|
android_app_import {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
apk: "prebuilts/apk/app.apk",
|
apk: "prebuilts/apk/app.apk",
|
||||||
|
@ -1166,7 +1166,7 @@ func TestAndroidAppImport_DpiVariants(t *testing.T) {
|
||||||
config := testConfig(nil)
|
config := testConfig(nil)
|
||||||
config.TestProductVariables.AAPTPreferredConfig = test.aaptPreferredConfig
|
config.TestProductVariables.AAPTPreferredConfig = test.aaptPreferredConfig
|
||||||
config.TestProductVariables.AAPTPrebuiltDPI = test.aaptPrebuiltDPI
|
config.TestProductVariables.AAPTPrebuiltDPI = test.aaptPrebuiltDPI
|
||||||
ctx := testAppContext(config, bp, nil)
|
ctx := testAppContext(bp, nil)
|
||||||
|
|
||||||
run(t, ctx, config)
|
run(t, ctx, config)
|
||||||
|
|
||||||
|
@ -1183,7 +1183,7 @@ func TestAndroidAppImport_DpiVariants(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStl(t *testing.T) {
|
func TestStl(t *testing.T) {
|
||||||
ctx := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
|
ctx, _ := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
|
||||||
cc_library {
|
cc_library {
|
||||||
name: "libjni",
|
name: "libjni",
|
||||||
}
|
}
|
||||||
|
@ -1286,7 +1286,7 @@ func TestUsesLibraries(t *testing.T) {
|
||||||
config := testConfig(nil)
|
config := testConfig(nil)
|
||||||
config.TestProductVariables.MissingUsesLibraries = []string{"baz"}
|
config.TestProductVariables.MissingUsesLibraries = []string{"baz"}
|
||||||
|
|
||||||
ctx := testAppContext(config, bp, nil)
|
ctx := testAppContext(bp, nil)
|
||||||
|
|
||||||
run(t, ctx, config)
|
run(t, ctx, config)
|
||||||
|
|
||||||
|
@ -1398,7 +1398,7 @@ func TestCodelessApp(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEmbedNotice(t *testing.T) {
|
func TestEmbedNotice(t *testing.T) {
|
||||||
ctx := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
|
ctx, _ := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
|
||||||
android_app {
|
android_app {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["a.java"],
|
srcs: ["a.java"],
|
||||||
|
@ -1549,7 +1549,7 @@ func TestUncompressDex(t *testing.T) {
|
||||||
config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true)
|
config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := testAppContext(config, bp, nil)
|
ctx := testAppContext(bp, nil)
|
||||||
|
|
||||||
run(t, ctx, config)
|
run(t, ctx, config)
|
||||||
|
|
||||||
|
|
|
@ -50,9 +50,7 @@ func TestDeviceForHost(t *testing.T) {
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
config := testConfig(nil)
|
ctx, config := testJava(t, bp)
|
||||||
ctx := testContext(config, bp, nil)
|
|
||||||
run(t, ctx, config)
|
|
||||||
|
|
||||||
deviceModule := ctx.ModuleForTests("device_module", "android_common")
|
deviceModule := ctx.ModuleForTests("device_module", "android_common")
|
||||||
deviceTurbineCombined := deviceModule.Output("turbine-combined/device_module.jar")
|
deviceTurbineCombined := deviceModule.Output("turbine-combined/device_module.jar")
|
||||||
|
@ -133,9 +131,7 @@ func TestHostForDevice(t *testing.T) {
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
config := testConfig(nil)
|
ctx, config := testJava(t, bp)
|
||||||
ctx := testContext(config, bp, nil)
|
|
||||||
run(t, ctx, config)
|
|
||||||
|
|
||||||
hostModule := ctx.ModuleForTests("host_module", config.BuildOsCommonVariant)
|
hostModule := ctx.ModuleForTests("host_module", config.BuildOsCommonVariant)
|
||||||
hostJavac := hostModule.Output("javac/host_module.jar")
|
hostJavac := hostModule.Output("javac/host_module.jar")
|
||||||
|
|
|
@ -51,7 +51,7 @@ func TestDexpreoptBootJars(t *testing.T) {
|
||||||
dexpreoptConfig.RuntimeApexJars = []string{"foo", "bar", "baz"}
|
dexpreoptConfig.RuntimeApexJars = []string{"foo", "bar", "baz"}
|
||||||
setDexpreoptTestGlobalConfig(config, dexpreoptConfig)
|
setDexpreoptTestGlobalConfig(config, dexpreoptConfig)
|
||||||
|
|
||||||
ctx := testContext(config, bp, nil)
|
ctx := testContext(bp, nil)
|
||||||
|
|
||||||
ctx.RegisterSingletonType("dex_bootjars", android.SingletonFactoryAdaptor(dexpreoptBootJarsFactory))
|
ctx.RegisterSingletonType("dex_bootjars", android.SingletonFactoryAdaptor(dexpreoptBootJarsFactory))
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ func TestDexpreoptEnabled(t *testing.T) {
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
ctx := testJava(t, test.bp)
|
ctx, _ := testJava(t, test.bp)
|
||||||
|
|
||||||
dexpreopt := ctx.ModuleForTests("foo", "android_common").MaybeDescription("dexpreopt")
|
dexpreopt := ctx.ModuleForTests("foo", "android_common").MaybeDescription("dexpreopt")
|
||||||
enabled := dexpreopt.Rule != nil
|
enabled := dexpreopt.Rule != nil
|
||||||
|
|
|
@ -57,8 +57,7 @@ func testConfig(env map[string]string) android.Config {
|
||||||
return TestConfig(buildDir, env)
|
return TestConfig(buildDir, env)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testContext(config android.Config, bp string,
|
func testContext(bp string, fs map[string][]byte) *android.TestContext {
|
||||||
fs map[string][]byte) *android.TestContext {
|
|
||||||
|
|
||||||
ctx := android.NewTestArchContext()
|
ctx := android.NewTestArchContext()
|
||||||
ctx.RegisterModuleType("android_app", android.ModuleFactoryAdaptor(AndroidAppFactory))
|
ctx.RegisterModuleType("android_app", android.ModuleFactoryAdaptor(AndroidAppFactory))
|
||||||
|
@ -222,13 +221,13 @@ func run(t *testing.T, ctx *android.TestContext, config android.Config) {
|
||||||
android.FailIfErrored(t, errs)
|
android.FailIfErrored(t, errs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testJava(t *testing.T, bp string) *android.TestContext {
|
func testJava(t *testing.T, bp string) (*android.TestContext, android.Config) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
config := testConfig(nil)
|
config := testConfig(nil)
|
||||||
ctx := testContext(config, bp, nil)
|
ctx := testContext(bp, nil)
|
||||||
run(t, ctx, config)
|
run(t, ctx, config)
|
||||||
|
|
||||||
return ctx
|
return ctx, config
|
||||||
}
|
}
|
||||||
|
|
||||||
func moduleToPath(name string) string {
|
func moduleToPath(name string) string {
|
||||||
|
@ -243,7 +242,7 @@ func moduleToPath(name string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSimple(t *testing.T) {
|
func TestSimple(t *testing.T) {
|
||||||
ctx := testJava(t, `
|
ctx, _ := testJava(t, `
|
||||||
java_library {
|
java_library {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["a.java"],
|
srcs: ["a.java"],
|
||||||
|
@ -287,7 +286,7 @@ func TestSimple(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSdkVersion(t *testing.T) {
|
func TestSdkVersion(t *testing.T) {
|
||||||
ctx := testJava(t, `
|
ctx, _ := testJava(t, `
|
||||||
java_library {
|
java_library {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["a.java"],
|
srcs: ["a.java"],
|
||||||
|
@ -313,7 +312,7 @@ func TestSdkVersion(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestArchSpecific(t *testing.T) {
|
func TestArchSpecific(t *testing.T) {
|
||||||
ctx := testJava(t, `
|
ctx, _ := testJava(t, `
|
||||||
java_library {
|
java_library {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["a.java"],
|
srcs: ["a.java"],
|
||||||
|
@ -332,7 +331,7 @@ func TestArchSpecific(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBinary(t *testing.T) {
|
func TestBinary(t *testing.T) {
|
||||||
ctx := testJava(t, `
|
ctx, _ := testJava(t, `
|
||||||
java_library_host {
|
java_library_host {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["a.java"],
|
srcs: ["a.java"],
|
||||||
|
@ -361,7 +360,7 @@ func TestBinary(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPrebuilts(t *testing.T) {
|
func TestPrebuilts(t *testing.T) {
|
||||||
ctx := testJava(t, `
|
ctx, _ := testJava(t, `
|
||||||
java_library {
|
java_library {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["a.java"],
|
srcs: ["a.java"],
|
||||||
|
@ -412,7 +411,7 @@ func TestPrebuilts(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDefaults(t *testing.T) {
|
func TestDefaults(t *testing.T) {
|
||||||
ctx := testJava(t, `
|
ctx, _ := testJava(t, `
|
||||||
java_defaults {
|
java_defaults {
|
||||||
name: "defaults",
|
name: "defaults",
|
||||||
srcs: ["a.java"],
|
srcs: ["a.java"],
|
||||||
|
@ -558,7 +557,7 @@ func TestResources(t *testing.T) {
|
||||||
|
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
ctx := testJava(t, `
|
ctx, _ := testJava(t, `
|
||||||
java_library {
|
java_library {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: [
|
srcs: [
|
||||||
|
@ -587,7 +586,7 @@ func TestResources(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIncludeSrcs(t *testing.T) {
|
func TestIncludeSrcs(t *testing.T) {
|
||||||
ctx := testJava(t, `
|
ctx, _ := testJava(t, `
|
||||||
java_library {
|
java_library {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: [
|
srcs: [
|
||||||
|
@ -650,7 +649,7 @@ func TestIncludeSrcs(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGeneratedSources(t *testing.T) {
|
func TestGeneratedSources(t *testing.T) {
|
||||||
ctx := testJava(t, `
|
ctx, _ := testJava(t, `
|
||||||
java_library {
|
java_library {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: [
|
srcs: [
|
||||||
|
@ -683,7 +682,7 @@ func TestGeneratedSources(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTurbine(t *testing.T) {
|
func TestTurbine(t *testing.T) {
|
||||||
ctx := testJava(t, `
|
ctx, _ := testJava(t, `
|
||||||
java_library {
|
java_library {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["a.java"],
|
srcs: ["a.java"],
|
||||||
|
@ -732,7 +731,7 @@ func TestTurbine(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSharding(t *testing.T) {
|
func TestSharding(t *testing.T) {
|
||||||
ctx := testJava(t, `
|
ctx, _ := testJava(t, `
|
||||||
java_library {
|
java_library {
|
||||||
name: "bar",
|
name: "bar",
|
||||||
srcs: ["a.java","b.java","c.java"],
|
srcs: ["a.java","b.java","c.java"],
|
||||||
|
@ -750,7 +749,7 @@ func TestSharding(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDroiddoc(t *testing.T) {
|
func TestDroiddoc(t *testing.T) {
|
||||||
ctx := testJava(t, `
|
ctx, _ := testJava(t, `
|
||||||
droiddoc_template {
|
droiddoc_template {
|
||||||
name: "droiddoc-templates-sdk",
|
name: "droiddoc-templates-sdk",
|
||||||
path: ".",
|
path: ".",
|
||||||
|
@ -793,7 +792,7 @@ func TestDroiddoc(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestJarGenrules(t *testing.T) {
|
func TestJarGenrules(t *testing.T) {
|
||||||
ctx := testJava(t, `
|
ctx, _ := testJava(t, `
|
||||||
java_library {
|
java_library {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["a.java"],
|
srcs: ["a.java"],
|
||||||
|
@ -847,7 +846,7 @@ func TestJarGenrules(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestExcludeFileGroupInSrcs(t *testing.T) {
|
func TestExcludeFileGroupInSrcs(t *testing.T) {
|
||||||
ctx := testJava(t, `
|
ctx, _ := testJava(t, `
|
||||||
java_library {
|
java_library {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["a.java", ":foo-srcs"],
|
srcs: ["a.java", ":foo-srcs"],
|
||||||
|
@ -874,7 +873,7 @@ func TestExcludeFileGroupInSrcs(t *testing.T) {
|
||||||
|
|
||||||
func TestJavaLibrary(t *testing.T) {
|
func TestJavaLibrary(t *testing.T) {
|
||||||
config := testConfig(nil)
|
config := testConfig(nil)
|
||||||
ctx := testContext(config, "", map[string][]byte{
|
ctx := testContext("", map[string][]byte{
|
||||||
"libcore/Android.bp": []byte(`
|
"libcore/Android.bp": []byte(`
|
||||||
java_library {
|
java_library {
|
||||||
name: "core",
|
name: "core",
|
||||||
|
@ -886,7 +885,7 @@ func TestJavaLibrary(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestJavaSdkLibrary(t *testing.T) {
|
func TestJavaSdkLibrary(t *testing.T) {
|
||||||
ctx := testJava(t, `
|
ctx, _ := testJava(t, `
|
||||||
droiddoc_template {
|
droiddoc_template {
|
||||||
name: "droiddoc-templates-sdk",
|
name: "droiddoc-templates-sdk",
|
||||||
path: ".",
|
path: ".",
|
||||||
|
@ -1057,7 +1056,7 @@ func TestPatchModule(t *testing.T) {
|
||||||
|
|
||||||
t.Run("Java language level 8", func(t *testing.T) {
|
t.Run("Java language level 8", func(t *testing.T) {
|
||||||
// Test default javac -source 1.8 -target 1.8
|
// Test default javac -source 1.8 -target 1.8
|
||||||
ctx := testJava(t, bp)
|
ctx, _ := testJava(t, bp)
|
||||||
|
|
||||||
checkPatchModuleFlag(t, ctx, "foo", "")
|
checkPatchModuleFlag(t, ctx, "foo", "")
|
||||||
checkPatchModuleFlag(t, ctx, "bar", "")
|
checkPatchModuleFlag(t, ctx, "bar", "")
|
||||||
|
@ -1067,7 +1066,7 @@ func TestPatchModule(t *testing.T) {
|
||||||
t.Run("Java language level 9", func(t *testing.T) {
|
t.Run("Java language level 9", func(t *testing.T) {
|
||||||
// Test again with javac -source 9 -target 9
|
// Test again with javac -source 9 -target 9
|
||||||
config := testConfig(map[string]string{"EXPERIMENTAL_JAVA_LANGUAGE_LEVEL_9": "true"})
|
config := testConfig(map[string]string{"EXPERIMENTAL_JAVA_LANGUAGE_LEVEL_9": "true"})
|
||||||
ctx := testContext(config, bp, nil)
|
ctx := testContext(bp, nil)
|
||||||
run(t, ctx, config)
|
run(t, ctx, config)
|
||||||
|
|
||||||
checkPatchModuleFlag(t, ctx, "foo", "")
|
checkPatchModuleFlag(t, ctx, "foo", "")
|
||||||
|
|
|
@ -22,7 +22,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestKotlin(t *testing.T) {
|
func TestKotlin(t *testing.T) {
|
||||||
ctx := testJava(t, `
|
ctx, _ := testJava(t, `
|
||||||
java_library {
|
java_library {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["a.java", "b.kt"],
|
srcs: ["a.java", "b.kt"],
|
||||||
|
@ -84,7 +84,7 @@ func TestKotlin(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestKapt(t *testing.T) {
|
func TestKapt(t *testing.T) {
|
||||||
ctx := testJava(t, `
|
ctx, _ := testJava(t, `
|
||||||
java_library {
|
java_library {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["a.java", "b.kt"],
|
srcs: ["a.java", "b.kt"],
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNoPlugin(t *testing.T) {
|
func TestNoPlugin(t *testing.T) {
|
||||||
ctx := testJava(t, `
|
ctx, _ := testJava(t, `
|
||||||
java_library {
|
java_library {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["a.java"],
|
srcs: ["a.java"],
|
||||||
|
@ -44,7 +44,7 @@ func TestNoPlugin(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPlugin(t *testing.T) {
|
func TestPlugin(t *testing.T) {
|
||||||
ctx := testJava(t, `
|
ctx, _ := testJava(t, `
|
||||||
java_library {
|
java_library {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["a.java"],
|
srcs: ["a.java"],
|
||||||
|
@ -83,7 +83,7 @@ func TestPlugin(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPluginGeneratesApi(t *testing.T) {
|
func TestPluginGeneratesApi(t *testing.T) {
|
||||||
ctx := testJava(t, `
|
ctx, _ := testJava(t, `
|
||||||
java_library {
|
java_library {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["a.java"],
|
srcs: ["a.java"],
|
||||||
|
|
|
@ -282,7 +282,7 @@ func TestClasspath(t *testing.T) {
|
||||||
if testcase.pdk {
|
if testcase.pdk {
|
||||||
config.TestProductVariables.Pdk = proptools.BoolPtr(true)
|
config.TestProductVariables.Pdk = proptools.BoolPtr(true)
|
||||||
}
|
}
|
||||||
ctx := testContext(config, bp, nil)
|
ctx := testContext(bp, nil)
|
||||||
run(t, ctx, config)
|
run(t, ctx, config)
|
||||||
|
|
||||||
checkClasspath(t, ctx)
|
checkClasspath(t, ctx)
|
||||||
|
@ -309,7 +309,7 @@ func TestClasspath(t *testing.T) {
|
||||||
if testcase.pdk {
|
if testcase.pdk {
|
||||||
config.TestProductVariables.Pdk = proptools.BoolPtr(true)
|
config.TestProductVariables.Pdk = proptools.BoolPtr(true)
|
||||||
}
|
}
|
||||||
ctx := testContext(config, bp, nil)
|
ctx := testContext(bp, nil)
|
||||||
run(t, ctx, config)
|
run(t, ctx, config)
|
||||||
|
|
||||||
javac := ctx.ModuleForTests("foo", variant).Rule("javac")
|
javac := ctx.ModuleForTests("foo", variant).Rule("javac")
|
||||||
|
@ -335,7 +335,7 @@ func TestClasspath(t *testing.T) {
|
||||||
if testcase.pdk {
|
if testcase.pdk {
|
||||||
config.TestProductVariables.Pdk = proptools.BoolPtr(true)
|
config.TestProductVariables.Pdk = proptools.BoolPtr(true)
|
||||||
}
|
}
|
||||||
ctx := testContext(config, bp, nil)
|
ctx := testContext(bp, nil)
|
||||||
run(t, ctx, config)
|
run(t, ctx, config)
|
||||||
|
|
||||||
checkClasspath(t, ctx)
|
checkClasspath(t, ctx)
|
||||||
|
|
Loading…
Reference in New Issue