Only include test data in flattened apex 1 time
Previously, if a data source was included in multiple APEX, it would
appear multiple times; however, this caused errors for overriding
commands for targets
Test: apex_test.go
Test: m nothing with change I54d92eca88fc04c949209d490e838d0a92ce8f87
Bug: 155820504
Change-Id: I98f04e0fd9fa3238f2bb0e5da3a86fc0797c38ba
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 9633f27..ced113f 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -184,6 +184,7 @@
"dummy.txt": nil,
"baz": nil,
"bar/baz": nil,
+ "testdata/baz": nil,
}
cc.GatherRequiredFilesForTest(fs)
@@ -274,6 +275,15 @@
}
}
+// ensure that 'result' contains 'expected' exactly one time
+func ensureContainsOnce(t *testing.T, result string, expected string) {
+ t.Helper()
+ count := strings.Count(result, expected)
+ if count != 1 {
+ t.Errorf("%q is found %d times (expected 1 time) in %q", expected, count, result)
+ }
+}
+
// ensures that 'result' does not contain 'notExpected'
func ensureNotContains(t *testing.T, result string, notExpected string) {
t.Helper()
@@ -3423,6 +3433,13 @@
stl: "none",
}
+ filegroup {
+ name: "fg2",
+ srcs: [
+ "testdata/baz"
+ ],
+ }
+
cc_test {
name: "mytests",
gtest: false,
@@ -3436,6 +3453,10 @@
system_shared_libs: [],
static_executable: true,
stl: "none",
+ data: [
+ ":fg",
+ ":fg2",
+ ],
}
`)
@@ -3475,7 +3496,8 @@
data = android.AndroidMkDataForTest(t, config, "", flatBundle)
data.Custom(&builder, name, prefix, "", data)
flatAndroidMk := builder.String()
- ensureContains(t, flatAndroidMk, "LOCAL_TEST_DATA := :baz :bar/baz\n")
+ ensureContainsOnce(t, flatAndroidMk, "LOCAL_TEST_DATA := :baz :bar/baz\n")
+ ensureContainsOnce(t, flatAndroidMk, "LOCAL_TEST_DATA := :testdata/baz\n")
}
func TestInstallExtraFlattenedApexes(t *testing.T) {