Debian Codegraph @

internal/bisect/bisect_test.go

raw symbols SCIP
1 // Copyright 2023 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package bisect
6
7 import (
8 "os"
9 "path/filepath"
10 "strings"
11 "testing"
12 )
13
14 // In order for package bisect to be copied into the standard library
15 // and used by very low-level packages such as internal/godebug,
16 // it needs to have no imports at all.
17 func TestNoImports(t *testing.T) {
18 files, err := filepath.Glob("*.go")
19 if err != nil {
20 t.Fatal(err)
21 }
22 for _, file := range files {
23 if strings.HasSuffix(file, "_test.go") {
24 continue
25 }
26 data, err := os.ReadFile(file)
27 if err != nil {
28 t.Error(err)
29 continue
30 }
31 if strings.Contains(string(data), "\nimport") {
32 t.Errorf("%s contains imports; package bisect must not import other packages", file)
33 }
34 }
35 }