mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-14 06:57:31 +00:00
tstest/deptest: add test-only package to unify negative dep tests
Updates #8658 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:

committed by
Brad Fitzpatrick

parent
32d486e2bf
commit
7560435eb5
@@ -1,38 +1,21 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
// No need to run this on Windows where CI's slow enough. Then we don't need to
|
||||
// worry about "go.exe" etc.
|
||||
|
||||
//go:build !windows
|
||||
|
||||
package iosdeps
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"os/exec"
|
||||
"testing"
|
||||
|
||||
"tailscale.com/tstest/deptest"
|
||||
)
|
||||
|
||||
func TestDeps(t *testing.T) {
|
||||
cmd := exec.Command("go", "list", "-json", ".")
|
||||
cmd.Env = append(os.Environ(), "GOOS=ios", "GOARCH=arm64")
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var res struct {
|
||||
Deps []string
|
||||
}
|
||||
if err := json.Unmarshal(out, &res); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, dep := range res.Deps {
|
||||
switch dep {
|
||||
case "text/template", "html/template":
|
||||
t.Errorf("package %q is not allowed as a dependency on iOS", dep)
|
||||
}
|
||||
}
|
||||
t.Logf("got %d dependencies", len(res.Deps))
|
||||
deptest.DepChecker{
|
||||
GOOS: "ios",
|
||||
GOARCH: "arm64",
|
||||
BadDeps: map[string]string{
|
||||
"text/template": "linker bloat (MethodByName)",
|
||||
"html/template": "linker bloat (MethodByName)",
|
||||
},
|
||||
}.Check(t)
|
||||
}
|
||||
|
Reference in New Issue
Block a user