From 4b1f2ae382ea7737a50764a0b6685b0f3d601a51 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Tue, 13 Jul 2021 17:02:48 -0700 Subject: [PATCH] tstest/integration: generate deps for all platforms in deps generator We have different deps depending on the platform. If we pick a privileged platform, we'll miss some deps. If we use the union of all platforms, the integration test won't compile on some platforms, because it'll import packages that don't compile on that platform. Give in to the madness and give each platform its own deps file. Signed-off-by: Josh Bleecher Snyder --- tstest/integration/gen_deps.go | 16 ++++- .../tailscaled_deps_test_darwin.go | 60 +++++++++++++++++ ...est.go => tailscaled_deps_test_freebsd.go} | 0 .../integration/tailscaled_deps_test_linux.go | 58 +++++++++++++++++ .../tailscaled_deps_test_openbsd.go | 58 +++++++++++++++++ .../tailscaled_deps_test_windows.go | 65 +++++++++++++++++++ 6 files changed, 254 insertions(+), 3 deletions(-) create mode 100644 tstest/integration/tailscaled_deps_test_darwin.go rename tstest/integration/{tailscaled_deps_test.go => tailscaled_deps_test_freebsd.go} (100%) create mode 100644 tstest/integration/tailscaled_deps_test_linux.go create mode 100644 tstest/integration/tailscaled_deps_test_openbsd.go create mode 100644 tstest/integration/tailscaled_deps_test_windows.go diff --git a/tstest/integration/gen_deps.go b/tstest/integration/gen_deps.go index 5027d101e..cf5a034e6 100644 --- a/tstest/integration/gen_deps.go +++ b/tstest/integration/gen_deps.go @@ -12,16 +12,25 @@ import ( "fmt" "io/ioutil" "log" + "os" "os/exec" ) func main() { + for _, goos := range []string{"windows", "linux", "darwin", "freebsd", "openbsd"} { + generate(goos) + } +} + +func generate(goos string) { var x struct { Imports []string } - j, err := exec.Command("go", "list", "-json", "tailscale.com/cmd/tailscaled").Output() + cmd := exec.Command("go", "list", "-json", "tailscale.com/cmd/tailscaled") + cmd.Env = append(os.Environ(), "GOOS="+goos, "GOARCH=amd64") + j, err := cmd.Output() if err != nil { - log.Fatal(err) + log.Fatalf("GOOS=%s GOARCH=amd64 %s: %v", goos, cmd, err) } if err := json.Unmarshal(j, &x); err != nil { log.Fatal(err) @@ -46,7 +55,8 @@ import ( } fmt.Fprintf(&out, ")\n") - err = ioutil.WriteFile("tailscaled_deps_test.go", out.Bytes(), 0644) + filename := fmt.Sprintf("tailscaled_deps_test_%s.go", goos) + err = ioutil.WriteFile(filename, out.Bytes(), 0644) if err != nil { log.Fatal(err) } diff --git a/tstest/integration/tailscaled_deps_test_darwin.go b/tstest/integration/tailscaled_deps_test_darwin.go new file mode 100644 index 000000000..29a5880ca --- /dev/null +++ b/tstest/integration/tailscaled_deps_test_darwin.go @@ -0,0 +1,60 @@ +// Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Code generated by gen_deps.go; DO NOT EDIT. + +package integration + +import ( + // And depend on a bunch of tailscaled innards, for Go's test caching. + // Otherwise cmd/go never sees that we depend on these packages' + // transitive deps when we run "go install tailscaled" in a child + // process and can cache a prior success when a dependency changes. + _ "context" + _ "crypto/tls" + _ "encoding/json" + _ "errors" + _ "flag" + _ "fmt" + _ "github.com/go-multierror/multierror" + _ "io" + _ "io/ioutil" + _ "log" + _ "net" + _ "net/http" + _ "net/http/httptrace" + _ "net/http/pprof" + _ "net/url" + _ "os" + _ "os/exec" + _ "os/signal" + _ "path/filepath" + _ "runtime" + _ "runtime/debug" + _ "strconv" + _ "strings" + _ "syscall" + _ "tailscale.com/derp/derphttp" + _ "tailscale.com/ipn" + _ "tailscale.com/ipn/ipnserver" + _ "tailscale.com/logpolicy" + _ "tailscale.com/net/dns" + _ "tailscale.com/net/interfaces" + _ "tailscale.com/net/socks5/tssocks" + _ "tailscale.com/net/tshttpproxy" + _ "tailscale.com/net/tstun" + _ "tailscale.com/paths" + _ "tailscale.com/tailcfg" + _ "tailscale.com/types/flagtype" + _ "tailscale.com/types/key" + _ "tailscale.com/types/logger" + _ "tailscale.com/util/osshare" + _ "tailscale.com/version" + _ "tailscale.com/version/distro" + _ "tailscale.com/wgengine" + _ "tailscale.com/wgengine/monitor" + _ "tailscale.com/wgengine/netstack" + _ "tailscale.com/wgengine/router" + _ "time" +) diff --git a/tstest/integration/tailscaled_deps_test.go b/tstest/integration/tailscaled_deps_test_freebsd.go similarity index 100% rename from tstest/integration/tailscaled_deps_test.go rename to tstest/integration/tailscaled_deps_test_freebsd.go diff --git a/tstest/integration/tailscaled_deps_test_linux.go b/tstest/integration/tailscaled_deps_test_linux.go new file mode 100644 index 000000000..84b35b592 --- /dev/null +++ b/tstest/integration/tailscaled_deps_test_linux.go @@ -0,0 +1,58 @@ +// Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Code generated by gen_deps.go; DO NOT EDIT. + +package integration + +import ( + // And depend on a bunch of tailscaled innards, for Go's test caching. + // Otherwise cmd/go never sees that we depend on these packages' + // transitive deps when we run "go install tailscaled" in a child + // process and can cache a prior success when a dependency changes. + _ "context" + _ "crypto/tls" + _ "encoding/json" + _ "errors" + _ "flag" + _ "fmt" + _ "github.com/go-multierror/multierror" + _ "io" + _ "io/ioutil" + _ "log" + _ "net" + _ "net/http" + _ "net/http/httptrace" + _ "net/http/pprof" + _ "net/url" + _ "os" + _ "os/signal" + _ "runtime" + _ "runtime/debug" + _ "strconv" + _ "strings" + _ "syscall" + _ "tailscale.com/derp/derphttp" + _ "tailscale.com/ipn" + _ "tailscale.com/ipn/ipnserver" + _ "tailscale.com/logpolicy" + _ "tailscale.com/net/dns" + _ "tailscale.com/net/interfaces" + _ "tailscale.com/net/socks5/tssocks" + _ "tailscale.com/net/tshttpproxy" + _ "tailscale.com/net/tstun" + _ "tailscale.com/paths" + _ "tailscale.com/tailcfg" + _ "tailscale.com/types/flagtype" + _ "tailscale.com/types/key" + _ "tailscale.com/types/logger" + _ "tailscale.com/util/osshare" + _ "tailscale.com/version" + _ "tailscale.com/version/distro" + _ "tailscale.com/wgengine" + _ "tailscale.com/wgengine/monitor" + _ "tailscale.com/wgengine/netstack" + _ "tailscale.com/wgengine/router" + _ "time" +) diff --git a/tstest/integration/tailscaled_deps_test_openbsd.go b/tstest/integration/tailscaled_deps_test_openbsd.go new file mode 100644 index 000000000..84b35b592 --- /dev/null +++ b/tstest/integration/tailscaled_deps_test_openbsd.go @@ -0,0 +1,58 @@ +// Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Code generated by gen_deps.go; DO NOT EDIT. + +package integration + +import ( + // And depend on a bunch of tailscaled innards, for Go's test caching. + // Otherwise cmd/go never sees that we depend on these packages' + // transitive deps when we run "go install tailscaled" in a child + // process and can cache a prior success when a dependency changes. + _ "context" + _ "crypto/tls" + _ "encoding/json" + _ "errors" + _ "flag" + _ "fmt" + _ "github.com/go-multierror/multierror" + _ "io" + _ "io/ioutil" + _ "log" + _ "net" + _ "net/http" + _ "net/http/httptrace" + _ "net/http/pprof" + _ "net/url" + _ "os" + _ "os/signal" + _ "runtime" + _ "runtime/debug" + _ "strconv" + _ "strings" + _ "syscall" + _ "tailscale.com/derp/derphttp" + _ "tailscale.com/ipn" + _ "tailscale.com/ipn/ipnserver" + _ "tailscale.com/logpolicy" + _ "tailscale.com/net/dns" + _ "tailscale.com/net/interfaces" + _ "tailscale.com/net/socks5/tssocks" + _ "tailscale.com/net/tshttpproxy" + _ "tailscale.com/net/tstun" + _ "tailscale.com/paths" + _ "tailscale.com/tailcfg" + _ "tailscale.com/types/flagtype" + _ "tailscale.com/types/key" + _ "tailscale.com/types/logger" + _ "tailscale.com/util/osshare" + _ "tailscale.com/version" + _ "tailscale.com/version/distro" + _ "tailscale.com/wgengine" + _ "tailscale.com/wgengine/monitor" + _ "tailscale.com/wgengine/netstack" + _ "tailscale.com/wgengine/router" + _ "time" +) diff --git a/tstest/integration/tailscaled_deps_test_windows.go b/tstest/integration/tailscaled_deps_test_windows.go new file mode 100644 index 000000000..69a11257c --- /dev/null +++ b/tstest/integration/tailscaled_deps_test_windows.go @@ -0,0 +1,65 @@ +// Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Code generated by gen_deps.go; DO NOT EDIT. + +package integration + +import ( + // And depend on a bunch of tailscaled innards, for Go's test caching. + // Otherwise cmd/go never sees that we depend on these packages' + // transitive deps when we run "go install tailscaled" in a child + // process and can cache a prior success when a dependency changes. + _ "context" + _ "crypto/tls" + _ "encoding/json" + _ "errors" + _ "flag" + _ "fmt" + _ "github.com/go-multierror/multierror" + _ "golang.org/x/sys/windows" + _ "golang.org/x/sys/windows/svc" + _ "golang.org/x/sys/windows/svc/mgr" + _ "golang.zx2c4.com/wireguard/windows/tunnel/winipcfg" + _ "inet.af/netaddr" + _ "io" + _ "io/ioutil" + _ "log" + _ "net" + _ "net/http" + _ "net/http/httptrace" + _ "net/http/pprof" + _ "net/url" + _ "os" + _ "os/signal" + _ "runtime" + _ "runtime/debug" + _ "strconv" + _ "strings" + _ "syscall" + _ "tailscale.com/derp/derphttp" + _ "tailscale.com/ipn" + _ "tailscale.com/ipn/ipnserver" + _ "tailscale.com/logpolicy" + _ "tailscale.com/logtail/backoff" + _ "tailscale.com/net/dns" + _ "tailscale.com/net/interfaces" + _ "tailscale.com/net/socks5/tssocks" + _ "tailscale.com/net/tshttpproxy" + _ "tailscale.com/net/tstun" + _ "tailscale.com/paths" + _ "tailscale.com/tailcfg" + _ "tailscale.com/types/flagtype" + _ "tailscale.com/types/key" + _ "tailscale.com/types/logger" + _ "tailscale.com/util/osshare" + _ "tailscale.com/version" + _ "tailscale.com/version/distro" + _ "tailscale.com/wf" + _ "tailscale.com/wgengine" + _ "tailscale.com/wgengine/monitor" + _ "tailscale.com/wgengine/netstack" + _ "tailscale.com/wgengine/router" + _ "time" +)