(t *testing.T, f *FlagSet, args []string)
| 1154 | } |
| 1155 | |
| 1156 | func parseReturnStderr(t *testing.T, f *FlagSet, args []string) (string, error) { |
| 1157 | oldStderr := os.Stderr |
| 1158 | r, w, _ := os.Pipe() |
| 1159 | os.Stderr = w |
| 1160 | |
| 1161 | err := f.Parse(args) |
| 1162 | |
| 1163 | outC := make(chan string) |
| 1164 | // copy the output in a separate goroutine so printing can't block indefinitely |
| 1165 | go func() { |
| 1166 | var buf bytes.Buffer |
| 1167 | io.Copy(&buf, r) |
| 1168 | outC <- buf.String() |
| 1169 | }() |
| 1170 | |
| 1171 | w.Close() |
| 1172 | os.Stderr = oldStderr |
| 1173 | out := <-outC |
| 1174 | |
| 1175 | return out, err |
| 1176 | } |
| 1177 | |
| 1178 | func TestDeprecatedFlagUsage(t *testing.T) { |
| 1179 | f := NewFlagSet("bob", ContinueOnError) |
no test coverage detected