| 145 | } |
| 146 | |
| 147 | func 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 | |
| 168 | func mustWriteFile(t *testing.T, path, contents string) { |
| 169 | err := os.WriteFile(path, []byte(contents), 0644) |