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"],
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
@ -1075,6 +1081,13 @@ func TestJavaSdkLibrary(t *testing.T) {
"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
qux := ctx.ModuleForTests("qux", "android_common")
if quxLib, ok := qux.Module().(*Library); ok {

View file

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