(t *testing.T)
| 256 | } |
| 257 | |
| 258 | func TestCheckmake_WithJSONOutputFlag(t *testing.T) { |
| 259 | out := captureOutput(func() { |
| 260 | cmd := newRootCmd() |
| 261 | cmd.SilenceErrors = true |
| 262 | cmd.SetArgs([]string{ |
| 263 | "--output", "json", |
| 264 | "../../fixtures/missing_phony.make", |
| 265 | }) |
| 266 | _ = cmd.Execute() |
| 267 | }) |
| 268 | |
| 269 | require.NotEmpty(t, out, "output should not be empty for JSON format") |
| 270 | |
| 271 | // Verify it's valid JSON |
| 272 | var violations []struct { |
| 273 | Rule string `json:"rule"` |
| 274 | Violation string `json:"violation"` |
| 275 | FileName string `json:"file_name"` |
| 276 | LineNumber int `json:"line_number"` |
| 277 | } |
| 278 | |
| 279 | err := json.Unmarshal([]byte(out), &violations) |
| 280 | require.NoError(t, err, "output should be valid JSON") |
| 281 | } |
| 282 | |
| 283 | func TestCheckmake_WithTextOutput(t *testing.T) { |
| 284 | out := captureOutput(func() { |
nothing calls this directly
no test coverage detected