MCPcopy
hub / github.com/perkeep/perkeep / TestNoTestingLinking

Function TestNoTestingLinking

pkg/test/integration/camlistore_test.go:147–166  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

145}
146
147func TestNoTestingLinking(t *testing.T) {
148 w, err := test.NewWorld()
149 if err != nil {
150 t.Fatal(err)
151 }
152 help, err := w.Help()
153 if err != nil {
154 t.Fatalf("Error running perkeepd -help: %v, %v", string(help), err)
155 }
156 sc := bufio.NewScanner(bytes.NewReader(help))
157 for sc.Scan() {
158 l := strings.TrimSpace(sc.Text())
159 if strings.HasPrefix(l, "-test.") {
160 t.Fatal("test flag detected in help output of perkeepd, because testing pkg got linked into binary")
161 }
162 }
163 if err := sc.Err(); err != nil {
164 t.Fatal(err)
165 }
166}
167
168func mustWriteFile(t *testing.T, path, contents string) {
169 err := os.WriteFile(path, []byte(contents), 0644)

Callers

nothing calls this directly

Calls 7

HelpMethod · 0.95
NewWorldFunction · 0.92
FatalMethod · 0.80
HasPrefixMethod · 0.80
FatalfMethod · 0.65
TextMethod · 0.65
ErrMethod · 0.45

Tested by

no test coverage detected