gtest

package
v0.0.0-...-683b059 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package gtest provides utilities to run gtest binary on Tast. TODO(hidehiko): Merge chromiumos/tast/local/chrome/bintest package into this.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ARC

func ARC(a *arc.ARC) option

ARC returns an option to run the test in ARC.

func ExtraArgs

func ExtraArgs(args ...string) option

ExtraArgs returns an option to pass more arguments than gtest arguments for execution.

func Filter

func Filter(pattern string) option

Filter returns an option to set gtest_filter.

func ListTests

func ListTests(ctx context.Context, exec string) ([]string, error)

ListTests returns a list of tests in the gtest executable.

func Logfile

func Logfile(path string) option

Logfile returns an option to set logfile path of GTest.

func Repeat

func Repeat(repeat int) option

Repeat returns an option to set gtest_repeat.

func TempLogfile

func TempLogfile(path string) option

TempLogfile returns an option to set logfile path of GTest. The file is created by using ioutil.TempFile to avoid conflict, so its special pattern is usable here.

func UID

func UID(uid int) option

UID returns an option to specify the user to run the gtest.

Types

type Failure

type Failure struct {
	Message string `xml:"message,attr"`
}

Failure represents a test validation failure in TestCase.

type GTest

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

GTest is a struct to run gtest binary.

func New

func New(exec string, opts ...option) *GTest

New creates GTest instance with given options.

func (*GTest) Args

func (t *GTest) Args() ([]string, error)

Args returns an array of string for execution.

func (*GTest) Run

func (t *GTest) Run(ctx context.Context) (*Report, error)

Run executes the gtest, and returns the parsed Report. Note that the returned Report may not be nil even if test command execution returns an error. E.g., if test case in the gtest fails, the command will return an error, but the report file should be created. This function also handles the case, and returns it.

func (*GTest) Start

func (t *GTest) Start(ctx context.Context) (*testexec.Cmd, error)

Start executes the gtest asynchronously, and returns the testexec.Cmd instance to talk to the process.

type Report

type Report struct {
	Suites []*TestSuite `xml:"testsuite"`
}

Report is a parsed gtest output report. See https://github.com/google/googletest/blob/master/googletest/docs/advanced.md#generating-an-xml-report for details. // nocheck Note: at the moment, only a subset of the report is parsed. More can be added upon requirements. TODO(crbug.com/940320): Consider switching to use JSON, which is supported gtest 1.8.1 or later.

func ParseReport

func ParseReport(path string) (*Report, error)

ParseReport parses the XML gtest output report at path.

func (*Report) FailedTestNames

func (r *Report) FailedTestNames() []string

FailedTestNames returns an array of failed test names, in the "TestSuite.TestCase" format. If no error is found, returns nil. This walks through whole the report.

func (*Report) PassedTestNames

func (r *Report) PassedTestNames() []string

PassedTestNames returns an array of passed test names, in the "TestSuite.TestCase" format. If no passed tests are found, returns nil. This walks through whole the report.

type TestCase

type TestCase struct {
	Name     string    `xml:"name,attr"`
	Failures []Failure `xml:"failure"`
}

TestCase represents a testcase run in TestSuite.

type TestSuite

type TestSuite struct {
	Name  string      `xml:"name,attr"`
	Cases []*TestCase `xml:"testcase"`
}

TestSuite represents a testsuite run in Report.

Jump to

Keyboard shortcuts

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