Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement option for custom output destinations in output.Get() #877

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions output/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type Options struct {
SuppressExceptions bool
ShowSkipped bool
JUnitHideMessage bool
File *os.File
}

// The defined output formats represent all of the supported formats
Expand All @@ -37,23 +38,27 @@ const (

// Get returns a type that can render output in the given format.
func Get(format string, options Options) Outputter {
if options.File == nil {
options.File = os.Stdout
}

switch format {
case OutputStandard:
return &Standard{Writer: os.Stdout, NoColor: options.NoColor, SuppressExceptions: options.SuppressExceptions, Tracing: options.Tracing, ShowSkipped: options.ShowSkipped}
return &Standard{Writer: options.File, NoColor: options.NoColor, SuppressExceptions: options.SuppressExceptions, Tracing: options.Tracing, ShowSkipped: options.ShowSkipped}
case OutputJSON:
return NewJSON(os.Stdout)
return NewJSON(options.File)
case OutputTAP:
return NewTAP(os.Stdout)
return NewTAP(options.File)
case OutputTable:
return NewTable(os.Stdout)
return NewTable(options.File)
case OutputJUnit:
return NewJUnit(os.Stdout, options.JUnitHideMessage)
return NewJUnit(options.File, options.JUnitHideMessage)
case OutputGitHub:
return NewGitHub(os.Stdout)
return NewGitHub(options.File)
case OutputAzureDevOps:
return NewAzureDevOps(os.Stdout)
return NewAzureDevOps(options.File)
default:
return NewStandard(os.Stdout)
return NewStandard(options.File)
}
}

Expand Down
Loading