|
|
|
|
@ -416,6 +416,33 @@ TS_LINK_FAIL_REFLECT=0 (was <nil>)`, |
|
|
|
|
"./cmd/tailcontrol", |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "linux_amd64_to_linux_amd64_go_run_tags", |
|
|
|
|
|
|
|
|
|
argv: []string{"go", "run", "./cmd/mkctr", "--tags=foo"}, |
|
|
|
|
goroot: "/goroot", |
|
|
|
|
nativeGOOS: "linux", |
|
|
|
|
nativeGOARCH: "amd64", |
|
|
|
|
|
|
|
|
|
envDiff: `CC=cc (was <nil>) |
|
|
|
|
CGO_CFLAGS=-O3 -std=gnu11 (was <nil>) |
|
|
|
|
CGO_ENABLED=1 (was <nil>) |
|
|
|
|
CGO_LDFLAGS= (was <nil>) |
|
|
|
|
GOARCH=amd64 (was <nil>) |
|
|
|
|
GOARM=5 (was <nil>) |
|
|
|
|
GOMIPS=softfloat (was <nil>) |
|
|
|
|
GOOS=linux (was <nil>) |
|
|
|
|
GOROOT=/goroot (was <nil>) |
|
|
|
|
TS_LINK_FAIL_REFLECT=0 (was <nil>)`, |
|
|
|
|
wantArgv: []string{ |
|
|
|
|
"go", "run", |
|
|
|
|
"-trimpath", |
|
|
|
|
"-tags=tailscale_go,osusergo,netgo", |
|
|
|
|
"-ldflags", "-X tailscale.com/version.longStamp=1.2.3-long -X tailscale.com/version.shortStamp=1.2.3 -X tailscale.com/version.gitCommitStamp=abcd -X tailscale.com/version.extraGitCommitStamp=defg '-extldflags=-static'", |
|
|
|
|
"./cmd/mkctr", |
|
|
|
|
"--tags=foo", |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for _, test := range tests { |
|
|
|
|
@ -442,61 +469,76 @@ func TestExtractTags(t *testing.T) { |
|
|
|
|
s := func(ss ...string) []string { return ss } |
|
|
|
|
tests := []struct { |
|
|
|
|
name string |
|
|
|
|
cmd string |
|
|
|
|
in []string |
|
|
|
|
filt []string // want filtered
|
|
|
|
|
tags []string // want tags
|
|
|
|
|
}{ |
|
|
|
|
{ |
|
|
|
|
name: "one_hyphen_tags", |
|
|
|
|
cmd: "build", |
|
|
|
|
in: s("foo", "-tags=a,b", "bar"), |
|
|
|
|
filt: s("foo", "bar"), |
|
|
|
|
tags: s("a", "b"), |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "two_hyphen_tags", |
|
|
|
|
cmd: "build", |
|
|
|
|
in: s("foo", "--tags=a,b", "bar"), |
|
|
|
|
filt: s("foo", "bar"), |
|
|
|
|
tags: s("a", "b"), |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "one_hypen_separate_arg", |
|
|
|
|
cmd: "build", |
|
|
|
|
in: s("foo", "-tags", "a,b", "bar"), |
|
|
|
|
filt: s("foo", "bar"), |
|
|
|
|
tags: s("a", "b"), |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "two_hypen_separate_arg", |
|
|
|
|
cmd: "build", |
|
|
|
|
in: s("foo", "--tags", "a,b", "bar"), |
|
|
|
|
filt: s("foo", "bar"), |
|
|
|
|
tags: s("a", "b"), |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "equal_empty", |
|
|
|
|
cmd: "build", |
|
|
|
|
in: s("foo", "--tags=", "bar"), |
|
|
|
|
filt: s("foo", "bar"), |
|
|
|
|
tags: s(), |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "arg_empty", |
|
|
|
|
cmd: "build", |
|
|
|
|
in: s("foo", "--tags", "", "bar"), |
|
|
|
|
filt: s("foo", "bar"), |
|
|
|
|
tags: s(), |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "arg_empty_truncated", |
|
|
|
|
cmd: "build", |
|
|
|
|
in: s("foo", "--tags"), |
|
|
|
|
filt: s("foo"), |
|
|
|
|
tags: s(), |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "go_run_with_program_tags", |
|
|
|
|
cmd: "run", |
|
|
|
|
in: s("--foo", "--tags", "bar", "my/package/name", "--tags", "qux"), |
|
|
|
|
filt: s("--foo", "my/package/name", "--tags", "qux"), |
|
|
|
|
tags: s("bar"), |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
for _, tt := range tests { |
|
|
|
|
t.Run(tt.name, func(t *testing.T) { |
|
|
|
|
filt, tags := extractTags(tt.in) |
|
|
|
|
filt, tags := extractTags(tt.cmd, tt.in) |
|
|
|
|
if !reflect.DeepEqual(filt, tt.filt) { |
|
|
|
|
t.Errorf("extractTags(%q) filtered = %q; want %q", tt.in, filt, tt.filt) |
|
|
|
|
t.Errorf("extractTags(%q, %q) filtered = %q; want %q", tt.cmd, tt.in, filt, tt.filt) |
|
|
|
|
} |
|
|
|
|
if !reflect.DeepEqual(tags, tt.tags) { |
|
|
|
|
t.Errorf("extractTags(%q) tags = %q; want %q", tt.in, tags, tt.tags) |
|
|
|
|
t.Errorf("extractTags(%q, %q) tags = %q; want %q", tt.cmd, tt.in, tags, tt.tags) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|