Merge "add test for ShouldKeepExistingBuldFileForDir()" am: 9478303673 am: 6d7aded12e

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2283373

Change-Id: Ibcd32ff90dec16cddf822cf2a7aaf351dee5ff11
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Usta (Tsering) Shrestha 2022-11-03 03:56:58 +00:00 committed by Automerger Merge Worker
commit de430d1d4d

View file

@ -423,3 +423,21 @@ func TestBp2buildAllowList(t *testing.T) {
}
}
}
func TestShouldKeepExistingBuildFileForDir(t *testing.T) {
allowlist := NewBp2BuildAllowlist()
// entry "a/b2/c2" is moot because of its parent "a/b2"
allowlist.SetKeepExistingBuildFile(map[string]bool{"a": false, "a/b1": false, "a/b2": true, "a/b1/c1": true, "a/b2/c2": false})
truths := []string{"a", "a/b1", "a/b2", "a/b1/c1", "a/b2/c", "a/b2/c2", "a/b2/c2/d"}
falsities := []string{"a1", "a/b", "a/b1/c"}
for _, dir := range truths {
if !allowlist.ShouldKeepExistingBuildFileForDir(dir) {
t.Errorf("%s expected TRUE but was FALSE", dir)
}
}
for _, dir := range falsities {
if allowlist.ShouldKeepExistingBuildFileForDir(dir) {
t.Errorf("%s expected FALSE but was TRUE", dir)
}
}
}