reporting

package
v0.0.0-...-b5d9cbe Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2024 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Overview

Package reporting implements test result reporting.

Index

Constants

View Source
const JUnitXMLFilename = "results.xml"

JUnitXMLFilename is a file name to be used with WriteJUnitXMLResults.

View Source
const LegacyResultsFilename = "results.json"

LegacyResultsFilename is a file name to be used with WriteLegacyResults.

View Source
const StreamedResultsFilename = "streamed_results.jsonl"

StreamedResultsFilename is a file name to be used with StreamedWriter.

Variables

View Source
var ErrTerminate = errors.New("reporting service requested to terminate")

ErrTerminate is returned by ReportResult when the reporting gRPC service requested us to terminate testing.

Functions

func WriteJUnitXMLResults

func WriteJUnitXMLResults(path string, results []*resultsjson.Result) error

WriteJUnitXMLResults saves Tast test results to path in the JUnit XML format.

func WriteLegacyResults

func WriteLegacyResults(path string, results []*resultsjson.Result) error

WriteLegacyResults writes results to path in the Tast's legacy results.json format.

func WriteResultsToLogs

func WriteResultsToLogs(ctx context.Context, results []*resultsjson.Result, resDir string, complete, cmdTimeoutPast bool)

WriteResultsToLogs writes test results to the console via ctx. resDir is the directory where test result files have been saved. complete indicates whether we could run all tests.

Types

type RPCClient

type RPCClient struct {
	// contains filtered or unexported fields
}

RPCClient implements a client of the reporting gRPC service. nil is a valid RPCClient that discards all reports.

func NewRPCClient

func NewRPCClient(ctx context.Context, addr string) (cl *RPCClient, retErr error)

NewRPCClient creates a new RPCClient that reports test results to the server at addr. If addr is an empty string, this function returns nil, which is a valid RPCClient that discards all reports.

func (*RPCClient) Close

func (c *RPCClient) Close() error

Close waits until the server acknowledges delivery of all logs messages, and closes the underlying connection of the RPCClient.

func (*RPCClient) NewTestLogWriter

func (c *RPCClient) NewTestLogWriter(testName, logPath string) *RPCTestLogWriter

NewTestLogWriter returns an RPCTestLogWriter that reports written data as test logs via the reporting gRPC service.

func (*RPCClient) ReportResult

func (c *RPCClient) ReportResult(ctx context.Context, r *resultsjson.Result) error

ReportResult reports a test result to the reporting gRPC service. It may return ErrTerminate if the server responded with a request to terminate testing.

type RPCTestLogWriter

type RPCTestLogWriter struct {
	// contains filtered or unexported fields
}

RPCTestLogWriter is an io.Writer that reports written data as test logs via the reporting gRPC service. nil is a valid RPCTestLogWriter that silently discards all written data.

func (*RPCTestLogWriter) Write

func (w *RPCTestLogWriter) Write(p []byte) (n int, err error)

Write sends given bytes to the reporting gRPC service.

type StreamedWriter

type StreamedWriter struct {
	// contains filtered or unexported fields
}

StreamedWriter writes a stream of JSON-marshaled jsonresults.Result objects to a file.

func NewStreamedWriter

func NewStreamedWriter(path string) (*StreamedWriter, error)

NewStreamedWriter creates and returns a new StreamedWriter for writing to a file at path. If the file already exists, new results are appended to it.

func (*StreamedWriter) Close

func (w *StreamedWriter) Close()

Close closes the underlying file.

func (*StreamedWriter) Write

func (w *StreamedWriter) Write(res *resultsjson.Result, update bool) error

Write writes the JSON-marshaled representation of res to the file. If update is true, the previous result that was written by this instance is overwritten. Concurrent calls are not supported (note that tests are run serially, and runners send control messages to the tast process serially as well).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL