Beispiel #1
0
func (executor *Executor) processAggregatedResult(resultChannel <-chan *output.Result) int {
	var results []*output.Result
	exitStatus := 0
	formatter := executor.OutputFormatter
	w := executor.OutputWriter
	for r := range resultChannel {
		results = append(results, r)
		if !r.Success {
			exitStatus = 1
		}
	}

	if !executor.ReportOnlyFailures || (exitStatus == 1 && executor.ReportOnlyFailures) {
		reader := formatter.AggregateReader(results)
		writer.WriteToWriter(w, formatter.Header())
		writer.WriteToWriter(w, reader)
		writer.WriteToWriter(w, formatter.Footer())
	}

	if executor.autoclose {
		writer.DoneWithWriter(w)
	}

	return exitStatus
}
Beispiel #2
0
func (executor *Executor) processEachResult(resultChannel <-chan *output.Result) int {
	exitStatus := 0
	counter := 0
	formatter := executor.OutputFormatter
	w := executor.OutputWriter
	for r := range resultChannel {
		if r.Success && executor.ReportOnlyFailures {
			executor.updateState(r)
			continue
		}
		if executor.ReportOnlyStateChanges {
			if !executor.didStateChange(r) {
				//no change... continue
				log.Printf("no change with result")
				executor.updateState(r)
				continue
			}
			log.Printf("found change with result, sending to writer")
			executor.updateState(r)
		}

		if counter == 0 {
			writer.WriteToWriter(w, formatter.Header())
		} else if counter != 0 {
			writer.WriteToWriter(w, formatter.RecordSeparator())
		}
		reader := formatter.Reader(r)
		if !r.Success {
			exitStatus = 1
		}
		writer.WriteToWriter(w, reader)
		counter++
	}
	if counter > 0 {
		writer.WriteToWriter(w, formatter.Footer())
	}

	if executor.autoclose {
		writer.DoneWithWriter(w)
	}

	return exitStatus
}