tstest/integration: help bust cmd/go's test caching

It was caching too aggressively, as it didn't see our deps due to our
running "go install tailscaled" as a child process.

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/2352/head
Brad Fitzpatrick 3 years ago committed by Brad Fitzpatrick
parent 3dcd18b6c8
commit 7d417586a8

@ -0,0 +1,53 @@
// 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.
// +build ignore
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"os/exec"
)
func main() {
var x struct {
Imports []string
}
j, err := exec.Command("go", "list", "-json", "tailscale.com/cmd/tailscaled").Output()
if err != nil {
log.Fatal(err)
}
if err := json.Unmarshal(j, &x); err != nil {
log.Fatal(err)
}
var out bytes.Buffer
out.WriteString(`// 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.
`)
for _, dep := range x.Imports {
fmt.Fprintf(&out, "\t_ %q\n", dep)
}
fmt.Fprintf(&out, ")\n")
err = ioutil.WriteFile("tailscaled_deps_test.go", out.Bytes(), 0644)
if err != nil {
log.Fatal(err)
}
}

@ -4,6 +4,8 @@
package integration package integration
//go:generate go run gen_deps.go
import ( import (
"bytes" "bytes"
"context" "context"

@ -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"
)
Loading…
Cancel
Save