|
@@ -19,11 +19,10 @@ package bpfix
|
|
|
import (
|
|
|
"bytes"
|
|
|
"fmt"
|
|
|
+ "reflect"
|
|
|
"strings"
|
|
|
"testing"
|
|
|
|
|
|
- "reflect"
|
|
|
-
|
|
|
"github.com/google/blueprint/parser"
|
|
|
"github.com/google/blueprint/pathtools"
|
|
|
)
|
|
@@ -2063,3 +2062,124 @@ func TestHaveSameLicense(t *testing.T) {
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+func TestRemoveResourceAndAssetsIfDefault(t *testing.T) {
|
|
|
+ tests := []struct {
|
|
|
+ name string
|
|
|
+ in string
|
|
|
+ out string
|
|
|
+ }{
|
|
|
+ {
|
|
|
+ name: "resource_dirs default",
|
|
|
+ in: `
|
|
|
+ android_app {
|
|
|
+ name: "foo",
|
|
|
+ resource_dirs: ["res"],
|
|
|
+ }
|
|
|
+ `,
|
|
|
+ out: `
|
|
|
+ android_app {
|
|
|
+ name: "foo",
|
|
|
+
|
|
|
+ }
|
|
|
+ `,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "resource_dirs not default",
|
|
|
+ in: `
|
|
|
+ android_app {
|
|
|
+ name: "foo",
|
|
|
+ resource_dirs: ["reso"],
|
|
|
+ }
|
|
|
+ `,
|
|
|
+ out: `
|
|
|
+ android_app {
|
|
|
+ name: "foo",
|
|
|
+ resource_dirs: ["reso"],
|
|
|
+ }
|
|
|
+ `,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "resource_dirs includes not default",
|
|
|
+ in: `
|
|
|
+ android_app {
|
|
|
+ name: "foo",
|
|
|
+ resource_dirs: ["res", "reso"],
|
|
|
+ }
|
|
|
+ `,
|
|
|
+ out: `
|
|
|
+ android_app {
|
|
|
+ name: "foo",
|
|
|
+ resource_dirs: ["res", "reso"],
|
|
|
+ }
|
|
|
+ `,
|
|
|
+ }, {
|
|
|
+ name: "asset_dirs default",
|
|
|
+ in: `
|
|
|
+ android_app {
|
|
|
+ name: "foo",
|
|
|
+ asset_dirs: ["assets"],
|
|
|
+ }
|
|
|
+ `,
|
|
|
+ out: `
|
|
|
+ android_app {
|
|
|
+ name: "foo",
|
|
|
+
|
|
|
+ }
|
|
|
+ `,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "asset_dirs not default",
|
|
|
+ in: `
|
|
|
+ android_app {
|
|
|
+ name: "foo",
|
|
|
+ asset_dirs: ["assety"],
|
|
|
+ }
|
|
|
+ `,
|
|
|
+ out: `
|
|
|
+ android_app {
|
|
|
+ name: "foo",
|
|
|
+ asset_dirs: ["assety"],
|
|
|
+ }
|
|
|
+ `,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "asset_dirs includes not default",
|
|
|
+ in: `
|
|
|
+ android_app {
|
|
|
+ name: "foo",
|
|
|
+ asset_dirs: ["assets", "assety"],
|
|
|
+ }
|
|
|
+ `,
|
|
|
+ out: `
|
|
|
+ android_app {
|
|
|
+ name: "foo",
|
|
|
+ asset_dirs: ["assets", "assety"],
|
|
|
+ }
|
|
|
+ `,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "resource_dirs and asset_dirs both default",
|
|
|
+ in: `
|
|
|
+ android_app {
|
|
|
+ name: "foo",
|
|
|
+ asset_dirs: ["assets"],
|
|
|
+ resource_dirs: ["res"],
|
|
|
+ }
|
|
|
+ `,
|
|
|
+ out: `
|
|
|
+ android_app {
|
|
|
+ name: "foo",
|
|
|
+
|
|
|
+ }
|
|
|
+ `,
|
|
|
+ },
|
|
|
+ }
|
|
|
+ for _, test := range tests {
|
|
|
+ t.Run(test.name, func(t *testing.T) {
|
|
|
+ runPassOnce(t, test.in, test.out, func(fixer *Fixer) error {
|
|
|
+ return removeResourceAndAssetsIfDefault(fixer)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|