Merge "Improve java_sdk_library handling of test_current"

This commit is contained in:
Treehugger Robot 2020-02-01 08:42:27 +00:00 committed by Gerrit Code Review
commit b708108b60
2 changed files with 19 additions and 3 deletions

View File

@ -1043,6 +1043,12 @@ func TestJavaSdkLibrary(t *testing.T) {
libs: ["baz"], libs: ["baz"],
sdk_version: "system_current", sdk_version: "system_current",
} }
java_library {
name: "baz-test",
srcs: ["c.java"],
libs: ["foo"],
sdk_version: "test_current",
}
`) `)
// check the existence of the internal modules // check the existence of the internal modules
@ -1075,6 +1081,13 @@ func TestJavaSdkLibrary(t *testing.T) {
"foo.stubs.jar") "foo.stubs.jar")
} }
bazTestJavac := ctx.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")
}
// test if baz has exported SDK lib names foo and bar to qux // test if baz has exported SDK lib names foo and bar to qux
qux := ctx.ModuleForTests("qux", "android_common") qux := ctx.ModuleForTests("qux", "android_common")
if quxLib, ok := qux.Module().(*Library); ok { if quxLib, ok := qux.Module().(*Library); ok {

View File

@ -689,16 +689,19 @@ func (module *SdkLibrary) sdkJars(
return module.Library.ImplementationJars() return module.Library.ImplementationJars()
} }
} }
var paths *scopePaths var apiScope *apiScope
switch sdkVersion.kind { switch sdkVersion.kind {
case sdkSystem: case sdkSystem:
paths = module.getScopePaths(apiScopeSystem) apiScope = apiScopeSystem
case sdkTest:
apiScope = apiScopeTest
case sdkPrivate: case sdkPrivate:
return module.Library.HeaderJars() return module.Library.HeaderJars()
default: default:
paths = module.getScopePaths(apiScopePublic) apiScope = apiScopePublic
} }
paths := module.getScopePaths(apiScope)
if headerJars { if headerJars {
return paths.stubsHeaderPath return paths.stubsHeaderPath
} else { } else {