Merge "Convert JavaSdkLibrary... tests in java package to test fixtures" am: fb3fc0cf40
am: dcdefb6b53
am: b75252399c
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1634627 Change-Id: I272a50cea888cf1db902e29c647072bca4f308f2
This commit is contained in:
commit
5df5ad660d
|
@ -135,7 +135,7 @@ func TestHostdexSpecificRequired(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestJavaSdkLibrary_RequireXmlPermissionFile(t *testing.T) {
|
||||
ctx, _ := testJava(t, `
|
||||
result := javaFixtureFactory.RunTestWithBp(t, `
|
||||
java_sdk_library {
|
||||
name: "foo-shared_library",
|
||||
srcs: ["a.java"],
|
||||
|
@ -148,7 +148,7 @@ func TestJavaSdkLibrary_RequireXmlPermissionFile(t *testing.T) {
|
|||
`)
|
||||
|
||||
// Verify the existence of internal modules
|
||||
ctx.ModuleForTests("foo-shared_library.xml", "android_common")
|
||||
result.ModuleForTests("foo-shared_library.xml", "android_common")
|
||||
|
||||
testCases := []struct {
|
||||
moduleName string
|
||||
|
@ -158,8 +158,8 @@ func TestJavaSdkLibrary_RequireXmlPermissionFile(t *testing.T) {
|
|||
{"foo-no_shared_library", nil},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
mod := ctx.ModuleForTests(tc.moduleName, "android_common").Module()
|
||||
entries := android.AndroidMkEntriesForTest(t, ctx, mod)[0]
|
||||
mod := result.ModuleForTests(tc.moduleName, "android_common").Module()
|
||||
entries := android.AndroidMkEntriesForTest(t, result.TestContext, mod)[0]
|
||||
actual := entries.EntryMap["LOCAL_REQUIRED_MODULES"]
|
||||
if !reflect.DeepEqual(tc.expected, actual) {
|
||||
t.Errorf("Unexpected required modules - expected: %q, actual: %q", tc.expected, actual)
|
||||
|
|
|
@ -369,13 +369,9 @@ func TestSimple(t *testing.T) {
|
|||
barTurbine := filepath.Join(buildDir, ".intermediates", "bar", "android_common", "turbine-combined", "bar.jar")
|
||||
bazTurbine := filepath.Join(buildDir, ".intermediates", "baz", "android_common", "turbine-combined", "baz.jar")
|
||||
|
||||
if !strings.Contains(javac.Args["classpath"], barTurbine) {
|
||||
t.Errorf("foo classpath %v does not contain %q", javac.Args["classpath"], barTurbine)
|
||||
}
|
||||
android.AssertStringDoesContain(t, "foo classpath", javac.Args["classpath"], barTurbine)
|
||||
|
||||
if !strings.Contains(javac.Args["classpath"], bazTurbine) {
|
||||
t.Errorf("foo classpath %v does not contain %q", javac.Args["classpath"], bazTurbine)
|
||||
}
|
||||
android.AssertStringDoesContain(t, "foo classpath", javac.Args["classpath"], bazTurbine)
|
||||
|
||||
if len(combineJar.Inputs) != 2 || combineJar.Inputs[1].String() != baz {
|
||||
t.Errorf("foo combineJar inputs %v does not contain %q", combineJar.Inputs, baz)
|
||||
|
@ -745,7 +741,7 @@ prebuilt_stubs_sources {
|
|||
}
|
||||
|
||||
func TestJavaSdkLibraryImport(t *testing.T) {
|
||||
ctx, _ := testJava(t, `
|
||||
result := javaFixtureFactory.RunTestWithBp(t, `
|
||||
java_library {
|
||||
name: "foo",
|
||||
srcs: ["a.java"],
|
||||
|
@ -783,16 +779,14 @@ func TestJavaSdkLibraryImport(t *testing.T) {
|
|||
`)
|
||||
|
||||
for _, scope := range []string{"", ".system", ".test"} {
|
||||
fooModule := ctx.ModuleForTests("foo"+scope, "android_common")
|
||||
fooModule := result.ModuleForTests("foo"+scope, "android_common")
|
||||
javac := fooModule.Rule("javac")
|
||||
|
||||
sdklibStubsJar := ctx.ModuleForTests("sdklib.stubs"+scope, "android_common").Rule("combineJar").Output
|
||||
if !strings.Contains(javac.Args["classpath"], sdklibStubsJar.String()) {
|
||||
t.Errorf("foo classpath %v does not contain %q", javac.Args["classpath"], sdklibStubsJar.String())
|
||||
}
|
||||
sdklibStubsJar := result.ModuleForTests("sdklib.stubs"+scope, "android_common").Rule("combineJar").Output
|
||||
android.AssertStringDoesContain(t, "foo classpath", javac.Args["classpath"], sdklibStubsJar.String())
|
||||
}
|
||||
|
||||
CheckModuleDependencies(t, ctx, "sdklib", "android_common", []string{
|
||||
CheckModuleDependencies(t, result.TestContext, "sdklib", "android_common", []string{
|
||||
`prebuilt_sdklib.stubs`,
|
||||
`prebuilt_sdklib.stubs.source.test`,
|
||||
`prebuilt_sdklib.stubs.system`,
|
||||
|
@ -801,7 +795,7 @@ func TestJavaSdkLibraryImport(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestJavaSdkLibraryImport_WithSource(t *testing.T) {
|
||||
ctx, _ := testJava(t, `
|
||||
result := javaFixtureFactory.RunTestWithBp(t, `
|
||||
java_sdk_library {
|
||||
name: "sdklib",
|
||||
srcs: ["a.java"],
|
||||
|
@ -820,7 +814,7 @@ func TestJavaSdkLibraryImport_WithSource(t *testing.T) {
|
|||
}
|
||||
`)
|
||||
|
||||
CheckModuleDependencies(t, ctx, "sdklib", "android_common", []string{
|
||||
CheckModuleDependencies(t, result.TestContext, "sdklib", "android_common", []string{
|
||||
`dex2oatd`,
|
||||
`prebuilt_sdklib`,
|
||||
`sdklib.impl`,
|
||||
|
@ -829,7 +823,7 @@ func TestJavaSdkLibraryImport_WithSource(t *testing.T) {
|
|||
`sdklib.xml`,
|
||||
})
|
||||
|
||||
CheckModuleDependencies(t, ctx, "prebuilt_sdklib", "android_common", []string{
|
||||
CheckModuleDependencies(t, result.TestContext, "prebuilt_sdklib", "android_common", []string{
|
||||
`prebuilt_sdklib.stubs`,
|
||||
`sdklib.impl`,
|
||||
// This should be prebuilt_sdklib.stubs but is set to sdklib.stubs because the
|
||||
|
@ -840,7 +834,7 @@ func TestJavaSdkLibraryImport_WithSource(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestJavaSdkLibraryImport_Preferred(t *testing.T) {
|
||||
ctx, _ := testJava(t, `
|
||||
result := javaFixtureFactory.RunTestWithBp(t, `
|
||||
java_sdk_library {
|
||||
name: "sdklib",
|
||||
srcs: ["a.java"],
|
||||
|
@ -860,7 +854,7 @@ func TestJavaSdkLibraryImport_Preferred(t *testing.T) {
|
|||
}
|
||||
`)
|
||||
|
||||
CheckModuleDependencies(t, ctx, "sdklib", "android_common", []string{
|
||||
CheckModuleDependencies(t, result.TestContext, "sdklib", "android_common", []string{
|
||||
`dex2oatd`,
|
||||
`prebuilt_sdklib`,
|
||||
`sdklib.impl`,
|
||||
|
@ -869,7 +863,7 @@ func TestJavaSdkLibraryImport_Preferred(t *testing.T) {
|
|||
`sdklib.xml`,
|
||||
})
|
||||
|
||||
CheckModuleDependencies(t, ctx, "prebuilt_sdklib", "android_common", []string{
|
||||
CheckModuleDependencies(t, result.TestContext, "prebuilt_sdklib", "android_common", []string{
|
||||
`prebuilt_sdklib.stubs`,
|
||||
`sdklib.impl`,
|
||||
`sdklib.xml`,
|
||||
|
@ -1844,7 +1838,7 @@ func TestJavaImport(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestJavaSdkLibrary(t *testing.T) {
|
||||
ctx, _ := testJava(t, `
|
||||
result := javaFixtureFactory.RunTestWithBp(t, `
|
||||
droiddoc_exported_dir {
|
||||
name: "droiddoc-templates-sdk",
|
||||
path: ".",
|
||||
|
@ -1921,68 +1915,48 @@ func TestJavaSdkLibrary(t *testing.T) {
|
|||
`)
|
||||
|
||||
// check the existence of the internal modules
|
||||
ctx.ModuleForTests("foo", "android_common")
|
||||
ctx.ModuleForTests(apiScopePublic.stubsLibraryModuleName("foo"), "android_common")
|
||||
ctx.ModuleForTests(apiScopeSystem.stubsLibraryModuleName("foo"), "android_common")
|
||||
ctx.ModuleForTests(apiScopeTest.stubsLibraryModuleName("foo"), "android_common")
|
||||
ctx.ModuleForTests(apiScopePublic.stubsSourceModuleName("foo"), "android_common")
|
||||
ctx.ModuleForTests(apiScopeSystem.stubsSourceModuleName("foo"), "android_common")
|
||||
ctx.ModuleForTests(apiScopeTest.stubsSourceModuleName("foo"), "android_common")
|
||||
ctx.ModuleForTests("foo"+sdkXmlFileSuffix, "android_common")
|
||||
ctx.ModuleForTests("foo.api.public.28", "")
|
||||
ctx.ModuleForTests("foo.api.system.28", "")
|
||||
ctx.ModuleForTests("foo.api.test.28", "")
|
||||
result.ModuleForTests("foo", "android_common")
|
||||
result.ModuleForTests(apiScopePublic.stubsLibraryModuleName("foo"), "android_common")
|
||||
result.ModuleForTests(apiScopeSystem.stubsLibraryModuleName("foo"), "android_common")
|
||||
result.ModuleForTests(apiScopeTest.stubsLibraryModuleName("foo"), "android_common")
|
||||
result.ModuleForTests(apiScopePublic.stubsSourceModuleName("foo"), "android_common")
|
||||
result.ModuleForTests(apiScopeSystem.stubsSourceModuleName("foo"), "android_common")
|
||||
result.ModuleForTests(apiScopeTest.stubsSourceModuleName("foo"), "android_common")
|
||||
result.ModuleForTests("foo"+sdkXmlFileSuffix, "android_common")
|
||||
result.ModuleForTests("foo.api.public.28", "")
|
||||
result.ModuleForTests("foo.api.system.28", "")
|
||||
result.ModuleForTests("foo.api.test.28", "")
|
||||
|
||||
bazJavac := ctx.ModuleForTests("baz", "android_common").Rule("javac")
|
||||
bazJavac := result.ModuleForTests("baz", "android_common").Rule("javac")
|
||||
// tests if baz is actually linked to the stubs lib
|
||||
if !strings.Contains(bazJavac.Args["classpath"], "foo.stubs.system.jar") {
|
||||
t.Errorf("baz javac classpath %v does not contain %q", bazJavac.Args["classpath"],
|
||||
"foo.stubs.system.jar")
|
||||
}
|
||||
android.AssertStringDoesContain(t, "baz javac classpath", bazJavac.Args["classpath"], "foo.stubs.system.jar")
|
||||
// ... and not to the impl lib
|
||||
if strings.Contains(bazJavac.Args["classpath"], "foo.jar") {
|
||||
t.Errorf("baz javac classpath %v should not contain %q", bazJavac.Args["classpath"],
|
||||
"foo.jar")
|
||||
}
|
||||
android.AssertStringDoesNotContain(t, "baz javac classpath", bazJavac.Args["classpath"], "foo.jar")
|
||||
// test if baz is not linked to the system variant of foo
|
||||
if strings.Contains(bazJavac.Args["classpath"], "foo.stubs.jar") {
|
||||
t.Errorf("baz javac classpath %v should not contain %q", bazJavac.Args["classpath"],
|
||||
"foo.stubs.jar")
|
||||
}
|
||||
android.AssertStringDoesNotContain(t, "baz javac classpath", bazJavac.Args["classpath"], "foo.stubs.jar")
|
||||
|
||||
bazTestJavac := ctx.ModuleForTests("baz-test", "android_common").Rule("javac")
|
||||
bazTestJavac := result.ModuleForTests("baz-test", "android_common").Rule("javac")
|
||||
// tests if baz-test is actually linked to the test stubs lib
|
||||
if !strings.Contains(bazTestJavac.Args["classpath"], "foo.stubs.test.jar") {
|
||||
t.Errorf("baz-test javac classpath %v does not contain %q", bazTestJavac.Args["classpath"],
|
||||
"foo.stubs.test.jar")
|
||||
}
|
||||
android.AssertStringDoesContain(t, "baz-test javac classpath", bazTestJavac.Args["classpath"], "foo.stubs.test.jar")
|
||||
|
||||
baz29Javac := ctx.ModuleForTests("baz-29", "android_common").Rule("javac")
|
||||
baz29Javac := result.ModuleForTests("baz-29", "android_common").Rule("javac")
|
||||
// tests if baz-29 is actually linked to the system 29 stubs lib
|
||||
if !strings.Contains(baz29Javac.Args["classpath"], "prebuilts/sdk/29/system/foo.jar") {
|
||||
t.Errorf("baz-29 javac classpath %v does not contain %q", baz29Javac.Args["classpath"],
|
||||
"prebuilts/sdk/29/system/foo.jar")
|
||||
}
|
||||
android.AssertStringDoesContain(t, "baz-29 javac classpath", baz29Javac.Args["classpath"], "prebuilts/sdk/29/system/foo.jar")
|
||||
|
||||
bazModule30Javac := ctx.ModuleForTests("baz-module-30", "android_common").Rule("javac")
|
||||
bazModule30Javac := result.ModuleForTests("baz-module-30", "android_common").Rule("javac")
|
||||
// tests if "baz-module-30" is actually linked to the module 30 stubs lib
|
||||
if !strings.Contains(bazModule30Javac.Args["classpath"], "prebuilts/sdk/30/module-lib/foo.jar") {
|
||||
t.Errorf("baz-module-30 javac classpath %v does not contain %q", bazModule30Javac.Args["classpath"],
|
||||
"prebuilts/sdk/30/module-lib/foo.jar")
|
||||
}
|
||||
android.AssertStringDoesContain(t, "baz-module-30 javac classpath", bazModule30Javac.Args["classpath"], "prebuilts/sdk/30/module-lib/foo.jar")
|
||||
|
||||
// test if baz has exported SDK lib names foo and bar to qux
|
||||
qux := ctx.ModuleForTests("qux", "android_common")
|
||||
qux := result.ModuleForTests("qux", "android_common")
|
||||
if quxLib, ok := qux.Module().(*Library); ok {
|
||||
sdkLibs := quxLib.ClassLoaderContexts().UsesLibs()
|
||||
if w := []string{"foo", "bar", "fred", "quuz"}; !reflect.DeepEqual(w, sdkLibs) {
|
||||
t.Errorf("qux should export %q but exports %q", w, sdkLibs)
|
||||
}
|
||||
android.AssertDeepEquals(t, "qux exports", []string{"foo", "bar", "fred", "quuz"}, sdkLibs)
|
||||
}
|
||||
}
|
||||
|
||||
func TestJavaSdkLibrary_StubOrImplOnlyLibs(t *testing.T) {
|
||||
ctx, _ := testJava(t, `
|
||||
result := javaFixtureFactory.RunTestWithBp(t, `
|
||||
java_sdk_library {
|
||||
name: "sdklib",
|
||||
srcs: ["a.java"],
|
||||
|
@ -2002,20 +1976,20 @@ func TestJavaSdkLibrary_StubOrImplOnlyLibs(t *testing.T) {
|
|||
`)
|
||||
|
||||
for _, implName := range []string{"sdklib", "sdklib.impl"} {
|
||||
implJavacCp := ctx.ModuleForTests(implName, "android_common").Rule("javac").Args["classpath"]
|
||||
implJavacCp := result.ModuleForTests(implName, "android_common").Rule("javac").Args["classpath"]
|
||||
if !strings.Contains(implJavacCp, "/foo.jar") || strings.Contains(implJavacCp, "/bar.jar") {
|
||||
t.Errorf("%v javac classpath %v does not contain foo and not bar", implName, implJavacCp)
|
||||
}
|
||||
}
|
||||
stubName := apiScopePublic.stubsLibraryModuleName("sdklib")
|
||||
stubsJavacCp := ctx.ModuleForTests(stubName, "android_common").Rule("javac").Args["classpath"]
|
||||
stubsJavacCp := result.ModuleForTests(stubName, "android_common").Rule("javac").Args["classpath"]
|
||||
if strings.Contains(stubsJavacCp, "/foo.jar") || !strings.Contains(stubsJavacCp, "/bar.jar") {
|
||||
t.Errorf("stubs javac classpath %v does not contain bar and not foo", stubsJavacCp)
|
||||
}
|
||||
}
|
||||
|
||||
func TestJavaSdkLibrary_DoNotAccessImplWhenItIsNotBuilt(t *testing.T) {
|
||||
ctx, _ := testJava(t, `
|
||||
result := javaFixtureFactory.RunTestWithBp(t, `
|
||||
java_sdk_library {
|
||||
name: "foo",
|
||||
srcs: ["a.java"],
|
||||
|
@ -2033,14 +2007,14 @@ func TestJavaSdkLibrary_DoNotAccessImplWhenItIsNotBuilt(t *testing.T) {
|
|||
`)
|
||||
|
||||
// The bar library should depend on the stubs jar.
|
||||
barLibrary := ctx.ModuleForTests("bar", "android_common").Rule("javac")
|
||||
barLibrary := result.ModuleForTests("bar", "android_common").Rule("javac")
|
||||
if expected, actual := `^-classpath .*:/[^:]*/turbine-combined/foo\.stubs\.jar$`, barLibrary.Args["classpath"]; !regexp.MustCompile(expected).MatchString(actual) {
|
||||
t.Errorf("expected %q, found %#q", expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestJavaSdkLibrary_UseSourcesFromAnotherSdkLibrary(t *testing.T) {
|
||||
testJava(t, `
|
||||
javaFixtureFactory.RunTestWithBp(t, `
|
||||
java_sdk_library {
|
||||
name: "foo",
|
||||
srcs: ["a.java"],
|
||||
|
@ -2058,7 +2032,9 @@ func TestJavaSdkLibrary_UseSourcesFromAnotherSdkLibrary(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestJavaSdkLibrary_AccessOutputFiles_MissingScope(t *testing.T) {
|
||||
testJavaError(t, `"foo" does not provide api scope system`, `
|
||||
javaFixtureFactory.
|
||||
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`"foo" does not provide api scope system`)).
|
||||
RunTestWithBp(t, `
|
||||
java_sdk_library {
|
||||
name: "foo",
|
||||
srcs: ["a.java"],
|
||||
|
@ -2076,7 +2052,7 @@ func TestJavaSdkLibrary_AccessOutputFiles_MissingScope(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestJavaSdkLibrary_Deps(t *testing.T) {
|
||||
ctx, _ := testJava(t, `
|
||||
result := javaFixtureFactory.RunTestWithBp(t, `
|
||||
java_sdk_library {
|
||||
name: "sdklib",
|
||||
srcs: ["a.java"],
|
||||
|
@ -2088,7 +2064,7 @@ func TestJavaSdkLibrary_Deps(t *testing.T) {
|
|||
}
|
||||
`)
|
||||
|
||||
CheckModuleDependencies(t, ctx, "sdklib", "android_common", []string{
|
||||
CheckModuleDependencies(t, result.TestContext, "sdklib", "android_common", []string{
|
||||
`dex2oatd`,
|
||||
`sdklib.impl`,
|
||||
`sdklib.stubs`,
|
||||
|
@ -2098,7 +2074,7 @@ func TestJavaSdkLibrary_Deps(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestJavaSdkLibraryImport_AccessOutputFiles(t *testing.T) {
|
||||
testJava(t, `
|
||||
javaFixtureFactory.RunTestWithBp(t, `
|
||||
java_sdk_library_import {
|
||||
name: "foo",
|
||||
public: {
|
||||
|
@ -2131,63 +2107,71 @@ func TestJavaSdkLibraryImport_AccessOutputFiles_Invalid(t *testing.T) {
|
|||
`
|
||||
|
||||
t.Run("stubs.source", func(t *testing.T) {
|
||||
testJavaError(t, `stubs.source not available for api scope public`, bp+`
|
||||
java_library {
|
||||
name: "bar",
|
||||
srcs: [":foo{.public.stubs.source}"],
|
||||
java_resources: [
|
||||
":foo{.public.api.txt}",
|
||||
":foo{.public.removed-api.txt}",
|
||||
],
|
||||
}
|
||||
`)
|
||||
javaFixtureFactory.
|
||||
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`stubs.source not available for api scope public`)).
|
||||
RunTestWithBp(t, bp+`
|
||||
java_library {
|
||||
name: "bar",
|
||||
srcs: [":foo{.public.stubs.source}"],
|
||||
java_resources: [
|
||||
":foo{.public.api.txt}",
|
||||
":foo{.public.removed-api.txt}",
|
||||
],
|
||||
}
|
||||
`)
|
||||
})
|
||||
|
||||
t.Run("api.txt", func(t *testing.T) {
|
||||
testJavaError(t, `api.txt not available for api scope public`, bp+`
|
||||
java_library {
|
||||
name: "bar",
|
||||
srcs: ["a.java"],
|
||||
java_resources: [
|
||||
":foo{.public.api.txt}",
|
||||
],
|
||||
}
|
||||
`)
|
||||
javaFixtureFactory.
|
||||
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`api.txt not available for api scope public`)).
|
||||
RunTestWithBp(t, bp+`
|
||||
java_library {
|
||||
name: "bar",
|
||||
srcs: ["a.java"],
|
||||
java_resources: [
|
||||
":foo{.public.api.txt}",
|
||||
],
|
||||
}
|
||||
`)
|
||||
})
|
||||
|
||||
t.Run("removed-api.txt", func(t *testing.T) {
|
||||
testJavaError(t, `removed-api.txt not available for api scope public`, bp+`
|
||||
java_library {
|
||||
name: "bar",
|
||||
srcs: ["a.java"],
|
||||
java_resources: [
|
||||
":foo{.public.removed-api.txt}",
|
||||
],
|
||||
}
|
||||
`)
|
||||
javaFixtureFactory.
|
||||
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`removed-api.txt not available for api scope public`)).
|
||||
RunTestWithBp(t, bp+`
|
||||
java_library {
|
||||
name: "bar",
|
||||
srcs: ["a.java"],
|
||||
java_resources: [
|
||||
":foo{.public.removed-api.txt}",
|
||||
],
|
||||
}
|
||||
`)
|
||||
})
|
||||
}
|
||||
|
||||
func TestJavaSdkLibrary_InvalidScopes(t *testing.T) {
|
||||
testJavaError(t, `module "foo": enabled api scope "system" depends on disabled scope "public"`, `
|
||||
java_sdk_library {
|
||||
name: "foo",
|
||||
srcs: ["a.java", "b.java"],
|
||||
api_packages: ["foo"],
|
||||
// Explicitly disable public to test the check that ensures the set of enabled
|
||||
// scopes is consistent.
|
||||
public: {
|
||||
enabled: false,
|
||||
},
|
||||
system: {
|
||||
enabled: true,
|
||||
},
|
||||
}
|
||||
javaFixtureFactory.
|
||||
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`module "foo": enabled api scope "system" depends on disabled scope "public"`)).
|
||||
RunTestWithBp(t, `
|
||||
java_sdk_library {
|
||||
name: "foo",
|
||||
srcs: ["a.java", "b.java"],
|
||||
api_packages: ["foo"],
|
||||
// Explicitly disable public to test the check that ensures the set of enabled
|
||||
// scopes is consistent.
|
||||
public: {
|
||||
enabled: false,
|
||||
},
|
||||
system: {
|
||||
enabled: true,
|
||||
},
|
||||
}
|
||||
`)
|
||||
}
|
||||
|
||||
func TestJavaSdkLibrary_SdkVersion_ForScope(t *testing.T) {
|
||||
testJava(t, `
|
||||
javaFixtureFactory.RunTestWithBp(t, `
|
||||
java_sdk_library {
|
||||
name: "foo",
|
||||
srcs: ["a.java", "b.java"],
|
||||
|
@ -2201,7 +2185,7 @@ func TestJavaSdkLibrary_SdkVersion_ForScope(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestJavaSdkLibrary_ModuleLib(t *testing.T) {
|
||||
testJava(t, `
|
||||
javaFixtureFactory.RunTestWithBp(t, `
|
||||
java_sdk_library {
|
||||
name: "foo",
|
||||
srcs: ["a.java", "b.java"],
|
||||
|
@ -2217,7 +2201,7 @@ func TestJavaSdkLibrary_ModuleLib(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestJavaSdkLibrary_SystemServer(t *testing.T) {
|
||||
testJava(t, `
|
||||
javaFixtureFactory.RunTestWithBp(t, `
|
||||
java_sdk_library {
|
||||
name: "foo",
|
||||
srcs: ["a.java", "b.java"],
|
||||
|
@ -2233,26 +2217,28 @@ func TestJavaSdkLibrary_SystemServer(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestJavaSdkLibrary_MissingScope(t *testing.T) {
|
||||
testJavaError(t, `requires api scope module-lib from foo but it only has \[\] available`, `
|
||||
java_sdk_library {
|
||||
name: "foo",
|
||||
srcs: ["a.java"],
|
||||
public: {
|
||||
enabled: false,
|
||||
},
|
||||
}
|
||||
javaFixtureFactory.
|
||||
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`requires api scope module-lib from foo but it only has \[\] available`)).
|
||||
RunTestWithBp(t, `
|
||||
java_sdk_library {
|
||||
name: "foo",
|
||||
srcs: ["a.java"],
|
||||
public: {
|
||||
enabled: false,
|
||||
},
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "baz",
|
||||
srcs: ["a.java"],
|
||||
libs: ["foo"],
|
||||
sdk_version: "module_current",
|
||||
}
|
||||
java_library {
|
||||
name: "baz",
|
||||
srcs: ["a.java"],
|
||||
libs: ["foo"],
|
||||
sdk_version: "module_current",
|
||||
}
|
||||
`)
|
||||
}
|
||||
|
||||
func TestJavaSdkLibrary_FallbackScope(t *testing.T) {
|
||||
testJava(t, `
|
||||
javaFixtureFactory.RunTestWithBp(t, `
|
||||
java_sdk_library {
|
||||
name: "foo",
|
||||
srcs: ["a.java"],
|
||||
|
@ -2272,7 +2258,7 @@ func TestJavaSdkLibrary_FallbackScope(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestJavaSdkLibrary_DefaultToStubs(t *testing.T) {
|
||||
ctx, _ := testJava(t, `
|
||||
result := javaFixtureFactory.RunTestWithBp(t, `
|
||||
java_sdk_library {
|
||||
name: "foo",
|
||||
srcs: ["a.java"],
|
||||
|
@ -2292,7 +2278,7 @@ func TestJavaSdkLibrary_DefaultToStubs(t *testing.T) {
|
|||
}
|
||||
`)
|
||||
// The baz library should depend on the system stubs jar.
|
||||
bazLibrary := ctx.ModuleForTests("baz", "android_common").Rule("javac")
|
||||
bazLibrary := result.ModuleForTests("baz", "android_common").Rule("javac")
|
||||
if expected, actual := `^-classpath .*:/[^:]*/turbine-combined/foo\.stubs.system\.jar$`, bazLibrary.Args["classpath"]; !regexp.MustCompile(expected).MatchString(actual) {
|
||||
t.Errorf("expected %q, found %#q", expected, actual)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue