mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-25 19:15:34 +00:00
71029cea2d
This updates all source files to use a new standard header for copyright and license declaration. Notably, copyright no longer includes a date, and we now use the standard SPDX-License-Identifier header. This commit was done almost entirely mechanically with perl, and then some minimal manual fixes. Updates #6865 Signed-off-by: Will Norris <will@tailscale.com>
60 lines
1.3 KiB
Go
60 lines
1.3 KiB
Go
// Copyright (c) Tailscale Inc & AUTHORS
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
package version_test
|
|
|
|
import (
|
|
"flag"
|
|
"os/exec"
|
|
"path/filepath"
|
|
"runtime"
|
|
"strings"
|
|
"testing"
|
|
|
|
"tailscale.com/version"
|
|
)
|
|
|
|
var (
|
|
findModuleInfo = version.ExportFindModuleInfo
|
|
cmdName = version.ExportCmdName
|
|
)
|
|
|
|
func TestFindModuleInfo(t *testing.T) {
|
|
dir := t.TempDir()
|
|
name := filepath.Join(dir, "tailscaled-version-test")
|
|
out, err := exec.Command("go", "build", "-o", name, "tailscale.com/cmd/tailscaled").CombinedOutput()
|
|
if err != nil {
|
|
t.Fatalf("failed to build tailscaled: %v\n%s", err, out)
|
|
}
|
|
modinfo, err := findModuleInfo(name)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
prefix := "path\ttailscale.com/cmd/tailscaled\nmod\ttailscale.com"
|
|
if !strings.HasPrefix(modinfo, prefix) {
|
|
t.Errorf("unexpected modinfo contents %q", modinfo)
|
|
}
|
|
}
|
|
|
|
func exe() string {
|
|
if runtime.GOOS == "windows" {
|
|
return ".exe"
|
|
}
|
|
return ""
|
|
}
|
|
|
|
var findModuleInfoName = flag.String("module-info-file", "", "if non-empty, test findModuleInfo against this filename")
|
|
|
|
func TestFindModuleInfoManual(t *testing.T) {
|
|
exe := *findModuleInfoName
|
|
if exe == "" {
|
|
t.Skip("skipping without --module-info-file filename")
|
|
}
|
|
cmd := cmdName(exe)
|
|
mod, err := findModuleInfo(exe)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Logf("Got %q from: %s", cmd, mod)
|
|
}
|