Revert "Disallow -warnings-as-errors in tidy_flags"
This reverts commit 2d481842b1
.
Reason for revert: b/235569235#comment4
Change-Id: I5c87b1d5a1bdf0bad7f436c397688fe3fc20d04e
This commit is contained in:
@@ -22,76 +22,6 @@ import (
|
||||
"android/soong/android"
|
||||
)
|
||||
|
||||
func TestTidyFlagsWarningsAsErrors(t *testing.T) {
|
||||
// The "tidy_flags" property should not contain -warnings-as-errors.
|
||||
testCases := []struct {
|
||||
libName, bp string
|
||||
errorMsg string // a negative test; must have error message
|
||||
flags []string // must have substrings in tidyFlags
|
||||
noFlags []string // must not have substrings in tidyFlags
|
||||
}{
|
||||
{
|
||||
"libfoo1",
|
||||
`cc_library_shared { // no warnings-as-errors, good tidy_flags
|
||||
name: "libfoo1",
|
||||
srcs: ["foo.c"],
|
||||
tidy_flags: ["-header-filter=dir1/"],
|
||||
}`,
|
||||
"",
|
||||
[]string{"-header-filter=dir1/"},
|
||||
[]string{"-warnings-as-errors"},
|
||||
},
|
||||
{
|
||||
"libfoo2",
|
||||
`cc_library_shared { // good use of tidy_checks_as_errors
|
||||
name: "libfoo2",
|
||||
srcs: ["foo.c"],
|
||||
tidy_checks_as_errors: ["xyz-*", "abc"],
|
||||
tidy_flags: ["-header-filter=dir2/"],
|
||||
}`,
|
||||
"",
|
||||
[]string{"-header-filter=dir2/", "-warnings-as-errors='xyz-*',abc"},
|
||||
[]string{},
|
||||
},
|
||||
{
|
||||
"libfoo3",
|
||||
`cc_library_shared { // bad use of -warnings-as-errors in tidy_flags
|
||||
name: "libfoo3",
|
||||
srcs: ["foo.c"],
|
||||
tidy_flags: [
|
||||
"-header-filters=.*",
|
||||
"-warnings-as-errors=xyz-*",
|
||||
],
|
||||
}`,
|
||||
`module "libfoo3" .*: tidy_flags: should not contain -warnings-as-errors,` +
|
||||
` use tidy_checks_as_errors instead`,
|
||||
[]string{},
|
||||
[]string{},
|
||||
},
|
||||
}
|
||||
for _, test := range testCases {
|
||||
if test.errorMsg != "" {
|
||||
testCcError(t, test.errorMsg, test.bp)
|
||||
continue
|
||||
}
|
||||
variant := "android_arm64_armv8-a_shared"
|
||||
ctx := testCc(t, test.bp)
|
||||
t.Run("caseTidyFlags", func(t *testing.T) {
|
||||
flags := ctx.ModuleForTests(test.libName, variant).Rule("clangTidy").Args["tidyFlags"]
|
||||
for _, flag := range test.flags {
|
||||
if !strings.Contains(flags, flag) {
|
||||
t.Errorf("tidyFlags for %s does not contain %s.", test.libName, flag)
|
||||
}
|
||||
}
|
||||
for _, flag := range test.noFlags {
|
||||
if strings.Contains(flags, flag) {
|
||||
t.Errorf("tidyFlags for %s should not contain %s.", test.libName, flag)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestTidyChecks(t *testing.T) {
|
||||
// The "tidy_checks" property defines additional checks appended
|
||||
// to global default. But there are some checks disabled after
|
||||
|
Reference in New Issue
Block a user