Merge "Make CheckHiddenAPIRuleInputs more reusable"
This commit is contained in:
@@ -319,10 +319,9 @@ func TestPlatformBootclasspath_HiddenAPIMonolithicFiles(t *testing.T) {
|
||||
// creates the index.csv file.
|
||||
platformBootclasspath := result.ModuleForTests("myplatform-bootclasspath", "android_common")
|
||||
indexRule := platformBootclasspath.Rule("monolithic_hidden_API_index")
|
||||
CheckHiddenAPIRuleInputs(t, `
|
||||
.intermediates/bar/android_common/javac/bar.jar
|
||||
.intermediates/foo-hiddenapi-annotations/android_common/javac/foo-hiddenapi-annotations.jar
|
||||
.intermediates/foo/android_common/javac/foo.jar
|
||||
`,
|
||||
indexRule)
|
||||
CheckHiddenAPIRuleInputs(t, "index", `
|
||||
out/soong/.intermediates/bar/android_common/javac/bar.jar
|
||||
out/soong/.intermediates/foo-hiddenapi-annotations/android_common/javac/foo-hiddenapi-annotations.jar
|
||||
out/soong/.intermediates/foo/android_common/javac/foo.jar
|
||||
`, indexRule)
|
||||
}
|
||||
|
@@ -17,6 +17,7 @@ package java
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -393,12 +394,20 @@ func CheckPlatformBootclasspathFragments(t *testing.T, result *android.TestResul
|
||||
android.AssertDeepEquals(t, fmt.Sprintf("%s fragments", "platform-bootclasspath"), expected, pairs)
|
||||
}
|
||||
|
||||
func CheckHiddenAPIRuleInputs(t *testing.T, expected string, hiddenAPIRule android.TestingBuildParams) {
|
||||
func CheckHiddenAPIRuleInputs(t *testing.T, message string, expected string, hiddenAPIRule android.TestingBuildParams) {
|
||||
t.Helper()
|
||||
actual := strings.TrimSpace(strings.Join(android.NormalizePathsForTesting(hiddenAPIRule.Implicits), "\n"))
|
||||
expected = strings.TrimSpace(expected)
|
||||
inputs := android.Paths{}
|
||||
if hiddenAPIRule.Input != nil {
|
||||
inputs = append(inputs, hiddenAPIRule.Input)
|
||||
}
|
||||
inputs = append(inputs, hiddenAPIRule.Inputs...)
|
||||
inputs = append(inputs, hiddenAPIRule.Implicits...)
|
||||
inputs = android.SortedUniquePaths(inputs)
|
||||
actual := strings.TrimSpace(strings.Join(inputs.RelativeToTop().Strings(), "\n"))
|
||||
re := regexp.MustCompile(`\n\s+`)
|
||||
expected = strings.TrimSpace(re.ReplaceAllString(expected, "\n"))
|
||||
if actual != expected {
|
||||
t.Errorf("Expected hiddenapi rule inputs:\n%s\nactual inputs:\n%s", expected, actual)
|
||||
t.Errorf("Expected hiddenapi rule inputs - %s:\n%s\nactual inputs:\n%s", message, expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user