Merge changes from topic "fix-stubs-source-snapshot"

* changes:
  Fix prebuilt_stubs_sources to work with no stubs sources
  Revert "Use glob for java_sdk_library_import stub_srcs"
This commit is contained in:
Paul Duffin
2020-11-19 18:39:02 +00:00
committed by Gerrit Code Review
4 changed files with 78 additions and 43 deletions

View File

@@ -15,6 +15,7 @@
package java
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
@@ -622,6 +623,35 @@ func assertDeepEquals(t *testing.T, message string, expected interface{}, actual
}
}
func TestPrebuiltStubsSources(t *testing.T) {
test := func(t *testing.T, sourcesPath string, expectedInputs []string) {
ctx, _ := testJavaWithFS(t, fmt.Sprintf(`
prebuilt_stubs_sources {
name: "stubs-source",
srcs: ["%s"],
}`, sourcesPath), map[string][]byte{
"stubs/sources/pkg/A.java": nil,
"stubs/sources/pkg/B.java": nil,
})
zipSrc := ctx.ModuleForTests("stubs-source", "android_common").Rule("zip_src")
if expected, actual := expectedInputs, zipSrc.Inputs.Strings(); !reflect.DeepEqual(expected, actual) {
t.Errorf("mismatch of inputs to soong_zip: expected %q, actual %q", expected, actual)
}
}
t.Run("empty/missing directory", func(t *testing.T) {
test(t, "empty-directory", []string{})
})
t.Run("non-empty set of sources", func(t *testing.T) {
test(t, "stubs/sources", []string{
"stubs/sources/pkg/A.java",
"stubs/sources/pkg/B.java",
})
})
}
func TestJavaSdkLibraryImport(t *testing.T) {
ctx, _ := testJava(t, `
java_library {