Skip to content

fix: support duplicate reporter output paths#481

Merged
kehoecj merged 1 commit into
Boeing:mainfrom
macayu17:fix/480-duplicate-reporters
May 22, 2026
Merged

fix: support duplicate reporter output paths#481
kehoecj merged 1 commit into
Boeing:mainfrom
macayu17:fix/480-duplicate-reporters

Conversation

@macayu17
Copy link
Copy Markdown
Contributor

Fixes #480

Summary

  • Preserve each --reporter flag instead of keying reporter config by type.
  • Allow repeated reporter types to write to different output paths.
  • Add a regression test for repeated JSON reporters writing two files.

Test

  • go test ./cmd/validator -run "Test_getFlags|Test_getFlagsValues|Test_emptyBoolEnvVarNoParseError|TestScript/ reporters" -count=1 -v
  • go vet ./cmd/validator
  • gofmt -s -l -e cmd\validator\validator.go
  • git diff --check

@macayu17 macayu17 requested a review from a team as a code owner May 21, 2026 20:01
Copilot AI review requested due to automatic review settings May 21, 2026 20:01
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR updates the validator’s reporter configuration to allow specifying the same reporter type multiple times (e.g., multiple JSON outputs), and adds an integration-style test case to verify it.

Changes:

  • Replace reporter configuration map with a slice-based reporterConfig to support duplicates and preserve ordering.
  • Update reporter flag parsing, validation, and reporter construction to use the new representation.
  • Add a txtar test demonstrating duplicate reporter types writing to separate files.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
cmd/validator/validator.go Switch reporter config from map to slice (reporterConfig) and update parsing/validation/building to support duplicate reporters.
cmd/validator/testdata/reporters.txtar Add coverage for passing the same reporter type multiple times with different output files.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/validator/validator.go Outdated
Comment on lines 408 to 419
parts := strings.Split(reportFlag, ":")
switch len(parts) {
case 1:
conf[parts[0]] = ""
conf = append(conf, reporterConfig{reportType: parts[0]})
case 2:
if parts[1] == "-" {
conf[parts[0]] = ""
conf = append(conf, reporterConfig{reportType: parts[0]})
} else {
conf[parts[0]] = parts[1]
conf = append(conf, reporterConfig{reportType: parts[0], outputDest: parts[1]})
}
default:
return nil, errors.New("wrong parameter value format for reporter, expected format is `report_type:optional_file_path`")
Comment thread cmd/validator/validator.go Outdated
Comment on lines 650 to 656
func buildReporters(reportType []reporterConfig) ([]reporter.Reporter, error) {
reporters := make([]reporter.Reporter, 0, len(reportType))
for rt, of := range reportType {
reporters = append(reporters, getReporter(rt, of))
for _, rc := range reportType {
reporters = append(reporters, getReporter(rc.reportType, rc.outputDest))
}
return reporters, nil
}
@macayu17 macayu17 force-pushed the fix/480-duplicate-reporters branch from bea84a8 to 2284cd7 Compare May 22, 2026 10:18
@kehoecj kehoecj added OSS Community Contribution Contributions from the OSS Community waiting-on-maintainer-review PR is waiting to be reviewed and functionally tested by the maintainers labels May 22, 2026
Copy link
Copy Markdown
Collaborator

@kehoecj kehoecj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@macayu17 PR looks solid and passed my local stress testing! I did a big docs refactor ahead of your PR. You'll need to rebase but it shouldn't be a big deal because it was docs only. A few changes you'll need to make:

  • Need a CHANGELOG entry
  • Update the docs with this new feature, probably just here
  • Add a test for duplicate reporters writing to the same file. What happens with --reporter=json:same.json --reporter=json:same.json?

@kehoecj kehoecj added pr-action-requested PR is awaiting feedback from the submitting developer and removed waiting-on-maintainer-review PR is waiting to be reviewed and functionally tested by the maintainers labels May 22, 2026
@macayu17 macayu17 force-pushed the fix/480-duplicate-reporters branch from 2284cd7 to 196951c Compare May 22, 2026 18:24
@macayu17
Copy link
Copy Markdown
Contributor Author

Rebased on main and pushed the requested updates.

I added the changelog entry, documented repeating the same reporter type with different output paths, and added coverage for duplicate JSON reporters writing to the same file.

For the same-file case, both reporters run successfully and the final file remains a single valid JSON report at that path.

@kehoecj kehoecj self-requested a review May 22, 2026 19:15
Copy link
Copy Markdown
Collaborator

@kehoecj kehoecj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. Thanks @macayu17 for the PR!

@kehoecj kehoecj merged commit b86206d into Boeing:main May 22, 2026
14 checks passed
@kehoecj kehoecj removed the pr-action-requested PR is awaiting feedback from the submitting developer label May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OSS Community Contribution Contributions from the OSS Community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support specifying the same reporter type multiple times with different output paths

3 participants