Run invocation features and render final reports
This commit is contained in:
34
reporter.go
34
reporter.go
@@ -203,6 +203,32 @@ func (r *Reporter) RenderOutput(write func(io.Writer) error) error {
|
||||
return finishRenderLocked(state, destinationOutput, renderErr, writer.writeError)
|
||||
}
|
||||
|
||||
// renderDiagnosticReport uses the same delivery bookkeeping as output reports,
|
||||
// while always rendering text and treating quiet as delivery suppression only.
|
||||
func (r *Reporter) renderDiagnosticReport(report Report) error {
|
||||
if r == nil || r.state == nil {
|
||||
return ErrReporterClosed
|
||||
}
|
||||
state := r.state
|
||||
state.mu.Lock()
|
||||
defer state.mu.Unlock()
|
||||
if state.closed {
|
||||
return ErrReporterClosed
|
||||
}
|
||||
destination := state.destination(destinationDiagnostics)
|
||||
destination.submitted = true
|
||||
if state.mode == ReportingModeQuiet {
|
||||
destination.suppressed = true
|
||||
return finishRenderLocked(state, destinationDiagnostics, RenderReport(io.Discard, report, FormatText), nil)
|
||||
}
|
||||
writer := &coordinatedWriter{state: state, destination: destinationDiagnostics}
|
||||
err := RenderReport(writer, report, FormatText)
|
||||
if err == nil && writer.writeError == nil {
|
||||
destination.delivered = true
|
||||
}
|
||||
return finishRenderLocked(state, destinationDiagnostics, err, writer.writeError)
|
||||
}
|
||||
|
||||
// Info submits an informational message to the diagnostic destination. Its
|
||||
// visibility follows the selected reporting mode.
|
||||
func (r *Reporter) Info(message string, details ...Detail) error {
|
||||
@@ -287,7 +313,7 @@ func (r DeferredReporter) enqueue(category messageCategory, message string, deta
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *Reporter) finalize(outcome Outcome, completion func(*Reporter)) Outcome {
|
||||
func (r *Reporter) finalize(outcome Outcome, completion func(*Reporter), producers ...func() Report) Outcome {
|
||||
if r == nil || r.state == nil {
|
||||
return normalizeOutcome(outcome)
|
||||
}
|
||||
@@ -314,6 +340,12 @@ func (r *Reporter) finalize(outcome Outcome, completion func(*Reporter)) Outcome
|
||||
completion(r)
|
||||
}
|
||||
|
||||
for _, produce := range producers {
|
||||
if produce != nil {
|
||||
_ = r.renderDiagnosticReport(produce())
|
||||
}
|
||||
}
|
||||
|
||||
state.mu.Lock()
|
||||
if presentationFailedLocked(state) {
|
||||
if outcome.Status == 0 && !hasExplanation(outcome.Explanation) {
|
||||
|
||||
Reference in New Issue
Block a user