| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | package buildutil_test |
| 6 | |
| 7 | import ( |
| 8 | "flag" |
| 9 | "go/build" |
| 10 | "reflect" |
| 11 | "testing" |
| 12 | |
| 13 | "golang.org/x/tools/go/buildutil" |
| 14 | ) |
| 15 | |
| 16 | func TestTags(t *testing.T) { |
| 17 | f := flag.NewFlagSet("TestTags", flag.PanicOnError) |
| 18 | var ctxt build.Context |
| 19 | f.Var((*buildutil.TagsFlag)(&ctxt.BuildTags), "tags", buildutil.TagsFlagDoc) |
| 20 | f.Parse([]string{"-tags", ` 'one'"two" 'three "four"'`, "rest"}) |
| 21 | |
| 22 | |
| 23 | want := []string{"one", "two", "three \"four\""} |
| 24 | if !reflect.DeepEqual(ctxt.BuildTags, want) { |
| 25 | t.Errorf("BuildTags = %q, want %q", ctxt.BuildTags, want) |
| 26 | } |
| 27 | |
| 28 | |
| 29 | if want := []string{"rest"}; !reflect.DeepEqual(f.Args(), want) { |
| 30 | t.Errorf("f.Args() = %q, want %q", f.Args(), want) |
| 31 | } |
| 32 | } |
| 33 | |