Replace RuleBuilder usages with static rules in app_import.go
RuleBuilder creates a new rule in the ninja file every time it's used, but in this case the rules were all exactly the same except that the input/output file paths were different. This can be converted to a single static rule instead. Bug: 262629589 Test: m nothing Change-Id: Iaa887c66a757da13293a3614c000d3be02a2a1b0
This commit is contained in:
@@ -17,7 +17,6 @@ package java
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -294,7 +293,6 @@ func TestAndroidAppImport_DpiVariants(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
jniRuleRe := regexp.MustCompile("^if \\(zipinfo (\\S+)")
|
||||
for _, test := range testCases {
|
||||
result := android.GroupFixturePreparers(
|
||||
PrepareForTestWithJavaDefaultModules,
|
||||
@@ -305,13 +303,9 @@ func TestAndroidAppImport_DpiVariants(t *testing.T) {
|
||||
).RunTestWithBp(t, bp)
|
||||
|
||||
variant := result.ModuleForTests("foo", "android_common")
|
||||
jniRuleCommand := variant.Output("jnis-uncompressed/foo.apk").RuleParams.Command
|
||||
matches := jniRuleRe.FindStringSubmatch(jniRuleCommand)
|
||||
if len(matches) != 2 {
|
||||
t.Errorf("failed to extract the src apk path from %q", jniRuleCommand)
|
||||
}
|
||||
if strings.HasSuffix(matches[1], test.expected) {
|
||||
t.Errorf("wrong src apk, expected: %q got: %q", test.expected, matches[1])
|
||||
input := variant.Output("jnis-uncompressed/foo.apk").Input.String()
|
||||
if strings.HasSuffix(input, test.expected) {
|
||||
t.Errorf("wrong src apk, expected: %q got: %q", test.expected, input)
|
||||
}
|
||||
|
||||
provenanceMetaDataRule := variant.Rule("genProvenanceMetaData")
|
||||
@@ -456,7 +450,6 @@ func TestAndroidAppImport_ArchVariants(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
jniRuleRe := regexp.MustCompile("^if \\(zipinfo (\\S+)")
|
||||
for _, test := range testCases {
|
||||
ctx, _ := testJava(t, test.bp)
|
||||
|
||||
@@ -469,13 +462,9 @@ func TestAndroidAppImport_ArchVariants(t *testing.T) {
|
||||
android.AssertDeepEquals(t, "Provenance metadata is not empty", android.TestingBuildParams{}, rule)
|
||||
continue
|
||||
}
|
||||
jniRuleCommand := variant.Output("jnis-uncompressed/foo.apk").RuleParams.Command
|
||||
matches := jniRuleRe.FindStringSubmatch(jniRuleCommand)
|
||||
if len(matches) != 2 {
|
||||
t.Errorf("failed to extract the src apk path from %q", jniRuleCommand)
|
||||
}
|
||||
if strings.HasSuffix(matches[1], test.expected) {
|
||||
t.Errorf("wrong src apk, expected: %q got: %q", test.expected, matches[1])
|
||||
input := variant.Output("jnis-uncompressed/foo.apk").Input.String()
|
||||
if strings.HasSuffix(input, test.expected) {
|
||||
t.Errorf("wrong src apk, expected: %q got: %q", test.expected, input)
|
||||
}
|
||||
rule := variant.Rule("genProvenanceMetaData")
|
||||
android.AssertStringEquals(t, "Invalid input", test.artifactPath, rule.Inputs[0].String())
|
||||
@@ -686,8 +675,8 @@ func TestAndroidTestImport_NoJinUncompressForPresigned(t *testing.T) {
|
||||
`)
|
||||
|
||||
variant := ctx.ModuleForTests("foo", "android_common")
|
||||
jniRule := variant.Output("jnis-uncompressed/foo.apk").RuleParams.Command
|
||||
if !strings.HasPrefix(jniRule, "if (zipinfo") {
|
||||
jniRule := variant.Output("jnis-uncompressed/foo.apk").BuildParams.Rule.String()
|
||||
if jniRule == android.Cp.String() {
|
||||
t.Errorf("Unexpected JNI uncompress rule command: " + jniRule)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user