diff options
author | 2021-06-16 02:04:13 +0100 | |
---|---|---|
committer | 2021-06-20 19:09:09 +0100 | |
commit | 51d7da2c4e62eccc5f0fe11cfa8cdf1cf67aa7c7 (patch) | |
tree | d182d57f8f523b7acd361b9c4b45e3c0f8d08246 /java/testing.go | |
parent | 89f570ac44af4bcf5b78fa8dad3d57f24cd3ca0e (diff) |
Make CheckHiddenAPIRuleInputs more reusable
Adds a message parameter and allows leading spaces in the expected file
string to allow them to be nicely indented.
Bug: 177892522
Test: m nothing
Change-Id: I33df26610738c48879fa0b8250dc377dd04bb07d
Diffstat (limited to 'java/testing.go')
-rw-r--r-- | java/testing.go | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/java/testing.go b/java/testing.go index 1fef337cc..7b452f762 100644 --- a/java/testing.go +++ b/java/testing.go @@ -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) } } |