github.com/coreos/mantle@v0.13.0/harness/reporters/reporter.go (about)

     1  // Copyright 2017 CoreOS, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package reporters
    16  
    17  import (
    18  	"time"
    19  
    20  	"github.com/coreos/mantle/harness/testresult"
    21  )
    22  
    23  type Reporters []Reporter
    24  
    25  func (reps Reporters) ReportTest(name string, result testresult.TestResult, duration time.Duration, b []byte) {
    26  	for _, r := range reps {
    27  		r.ReportTest(name, result, duration, b)
    28  	}
    29  }
    30  
    31  func (reps Reporters) Output(path string) error {
    32  	for _, r := range reps {
    33  		err := r.Output(path)
    34  		if err != nil {
    35  			return err
    36  		}
    37  	}
    38  	return nil
    39  }
    40  
    41  func (reps Reporters) SetResult(s testresult.TestResult) {
    42  	for _, r := range reps {
    43  		r.SetResult(s)
    44  	}
    45  }
    46  
    47  type Reporter interface {
    48  	ReportTest(string, testresult.TestResult, time.Duration, []byte)
    49  	Output(string) error
    50  	SetResult(testresult.TestResult)
    51  }