github.com/0xKiwi/rules_go@v0.24.3/tests/core/cgo/tag_test.go (about) 1 package tag 2 3 import ( 4 "os/exec" 5 "strings" 6 "testing" 7 8 "github.com/bazelbuild/rules_go/go/tools/bazel" 9 ) 10 11 func Test(t *testing.T) { 12 for _, tc := range []struct { 13 name, path, want string 14 }{ 15 { 16 name: "tag_pure_bin", 17 want: "pure", 18 }, { 19 name: "tag_cgo_bin", 20 want: "cgo", 21 }, 22 } { 23 t.Run(tc.name, func(t *testing.T) { 24 path, ok := bazel.FindBinary("tests/core/cgo", tc.name) 25 if !ok { 26 t.Fatalf("could not find binary: %s", tc.name) 27 } 28 out, err := exec.Command(path).Output() 29 if err != nil { 30 t.Fatal(err) 31 } 32 got := strings.TrimSpace(string(out)) 33 if got != tc.want { 34 t.Errorf("got %s; want %s", got, tc.want) 35 } 36 }) 37 } 38 }