Loading bpfix/bpfix/bpfix.go +9 −1 Original line number Diff line number Diff line Loading @@ -392,7 +392,7 @@ func rewriteTestModuleTypes(f *Fixer) error { continue } if !strings.HasPrefix(mod.Type, "java_") && !strings.HasPrefix(mod.Type, "android_") { if !strings.HasPrefix(mod.Type, "java_") && !strings.HasPrefix(mod.Type, "android_") && mod.Type != "cc_binary" { continue } Loading Loading @@ -420,6 +420,14 @@ func rewriteTestModuleTypes(f *Fixer) error { mod.Type = "java_test_host" } } // when a cc_binary module has a nonempty test_suites field, modify the type to cc_test if mod.Type == "cc_binary" { hasTestSuites := hasNonEmptyLiteralListProperty(mod, "test_suites") if hasTestSuites { mod.Type = "cc_test" } } } return nil Loading bpfix/bpfix/bpfix_test.go +48 −0 Original line number Diff line number Diff line Loading @@ -1124,3 +1124,51 @@ func TestRewriteRuntimeResourceOverlay(t *testing.T) { }) } } func TestRewriteTestModuleTypes(t *testing.T) { tests := []struct { name string in string out string }{ { name: "cc_binary with test_suites", in: ` cc_binary { name: "foo", srcs: ["srcs"], test_suites: ["test_suite1"], } `, out: ` cc_test { name: "foo", srcs: ["srcs"], test_suites: ["test_suite1"], } `, }, { name: "cc_binary without test_suites", in: ` cc_binary { name: "foo", srcs: ["srcs"], } `, out: ` cc_binary { name: "foo", srcs: ["srcs"], } `, }, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { runPass(t, test.in, test.out, func(fixer *Fixer) error { return rewriteTestModuleTypes(fixer) }) }) } } Loading
bpfix/bpfix/bpfix.go +9 −1 Original line number Diff line number Diff line Loading @@ -392,7 +392,7 @@ func rewriteTestModuleTypes(f *Fixer) error { continue } if !strings.HasPrefix(mod.Type, "java_") && !strings.HasPrefix(mod.Type, "android_") { if !strings.HasPrefix(mod.Type, "java_") && !strings.HasPrefix(mod.Type, "android_") && mod.Type != "cc_binary" { continue } Loading Loading @@ -420,6 +420,14 @@ func rewriteTestModuleTypes(f *Fixer) error { mod.Type = "java_test_host" } } // when a cc_binary module has a nonempty test_suites field, modify the type to cc_test if mod.Type == "cc_binary" { hasTestSuites := hasNonEmptyLiteralListProperty(mod, "test_suites") if hasTestSuites { mod.Type = "cc_test" } } } return nil Loading
bpfix/bpfix/bpfix_test.go +48 −0 Original line number Diff line number Diff line Loading @@ -1124,3 +1124,51 @@ func TestRewriteRuntimeResourceOverlay(t *testing.T) { }) } } func TestRewriteTestModuleTypes(t *testing.T) { tests := []struct { name string in string out string }{ { name: "cc_binary with test_suites", in: ` cc_binary { name: "foo", srcs: ["srcs"], test_suites: ["test_suite1"], } `, out: ` cc_test { name: "foo", srcs: ["srcs"], test_suites: ["test_suite1"], } `, }, { name: "cc_binary without test_suites", in: ` cc_binary { name: "foo", srcs: ["srcs"], } `, out: ` cc_binary { name: "foo", srcs: ["srcs"], } `, }, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { runPass(t, test.in, test.out, func(fixer *Fixer) error { return rewriteTestModuleTypes(fixer) }) }) } }