Generate .srcjar for prebuilt_stubs_sources
Changes prebuilt_stubs_sources to generate a .srcjar from its input instead of just exposing the srcs it is given. This ensures that it can be used as a drop in replacement for a droidstubs module. Updates the test for prebuilt_stubs_sources to be more representative of the actual use made of it by sdk snapshot which outputs a directory not a glob pattern. Added some documentation of the prebuilts_stubs_sources srcs property to make it clear that it is supposed to be a set of directories. Extracts common code from sdk/testing.go for normalizing path/paths for testing. Bug: 143678475 Test: m conscrypt-module-sdk conscrypt-module-host-sdk conscrypt-module-test-sdk unzip those in place of external/conscrypt build core-current-stubs-source which expects it to provide a .srcjar. Change-Id: I8204a022557a9b0b45e19eac79ecba98ff95213d
This commit is contained in:
@@ -484,28 +484,24 @@ func TestPrebuilts(t *testing.T) {
|
||||
|
||||
prebuilt_stubs_sources {
|
||||
name: "stubs-source",
|
||||
srcs: ["stubs/sources/**/*.java"],
|
||||
srcs: ["stubs/sources"],
|
||||
}
|
||||
`)
|
||||
|
||||
javac := ctx.ModuleForTests("foo", "android_common").Rule("javac")
|
||||
fooModule := ctx.ModuleForTests("foo", "android_common")
|
||||
javac := fooModule.Rule("javac")
|
||||
combineJar := ctx.ModuleForTests("foo", "android_common").Description("for javac")
|
||||
barJar := ctx.ModuleForTests("bar", "android_common").Rule("combineJar").Output
|
||||
bazJar := ctx.ModuleForTests("baz", "android_common").Rule("combineJar").Output
|
||||
sdklibStubsJar := ctx.ModuleForTests("sdklib.stubs", "android_common").Rule("combineJar").Output
|
||||
|
||||
inputs := []string{}
|
||||
for _, p := range javac.BuildParams.Inputs {
|
||||
inputs = append(inputs, p.String())
|
||||
}
|
||||
fooLibrary := fooModule.Module().(*Library)
|
||||
assertDeepEquals(t, "foo java sources incorrect",
|
||||
[]string{"a.java"}, fooLibrary.compiledJavaSrcs.Strings())
|
||||
|
||||
expected := []string{
|
||||
"a.java",
|
||||
"stubs/sources/foo/Foo.java",
|
||||
}
|
||||
if !reflect.DeepEqual(expected, inputs) {
|
||||
t.Errorf("foo inputs incorrect: expected %q, found %q", expected, inputs)
|
||||
}
|
||||
assertDeepEquals(t, "foo java source jars incorrect",
|
||||
[]string{".intermediates/stubs-source/android_common/stubs-source-stubs.srcjar"},
|
||||
android.NormalizePathsForTesting(fooLibrary.compiledSrcJars))
|
||||
|
||||
if !strings.Contains(javac.Args["classpath"], barJar.String()) {
|
||||
t.Errorf("foo classpath %v does not contain %q", javac.Args["classpath"], barJar.String())
|
||||
@@ -522,6 +518,12 @@ func TestPrebuilts(t *testing.T) {
|
||||
ctx.ModuleForTests("qux", "android_common").Rule("Cp")
|
||||
}
|
||||
|
||||
func assertDeepEquals(t *testing.T, message string, expected interface{}, actual interface{}) {
|
||||
if !reflect.DeepEqual(expected, actual) {
|
||||
t.Errorf("%s: expected %q, found %q", message, expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaults(t *testing.T) {
|
||||
ctx, _ := testJava(t, `
|
||||
java_defaults {
|
||||
|
Reference in New Issue
Block a user