diff options
author | gVisor bot <gvisor-bot@google.com> | 2021-09-11 18:01:51 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-09-11 18:04:15 -0700 |
commit | 63b1c736b3bbb71cc7019fddec0e706133a2f61e (patch) | |
tree | ca162e811328b732f678b6daeb7f78b984dd5315 /test/runner | |
parent | 28853599c45d0b1ea78d79e5ff700a9c763cf60d (diff) |
Internal change.
PiperOrigin-RevId: 396155387
Diffstat (limited to 'test/runner')
-rw-r--r-- | test/runner/gtest/gtest.go | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/test/runner/gtest/gtest.go b/test/runner/gtest/gtest.go index 38e57d62f..affbf1973 100644 --- a/test/runner/gtest/gtest.go +++ b/test/runner/gtest/gtest.go @@ -133,17 +133,28 @@ func ParseTestCases(testBin string, benchmarks bool, extraArgs ...string) ([]Tes } // Run again to extract benchmarks. - args = append([]string{listBenchmarkFlag}, extraArgs...) - cmd = exec.Command(testBin, args...) - out, err = cmd.Output() + tb, err := ParseBenchmarks(testBin, extraArgs...) + if err != nil { + return nil, err + } + t = append(t, tb...) + return t, nil +} + +// ParseBenchmarks returns each benchmark in a third_party/benchmark binary's list as a single test case. +func ParseBenchmarks(binary string, extraArgs ...string) ([]TestCase, error) { + var t []TestCase + args := append([]string{listBenchmarkFlag}, extraArgs...) + cmd := exec.Command(binary, args...) + out, err := cmd.Output() if err != nil { // We were able to enumerate tests above, but not benchmarks? // We requested them, so we return an error in this case. exitErr, ok := err.(*exec.ExitError) if !ok { - return nil, fmt.Errorf("could not enumerate gtest benchmarks: %v", err) + return nil, fmt.Errorf("could not enumerate benchmarks: %v", err) } - return nil, fmt.Errorf("could not enumerate gtest benchmarks: %v\nstderr\n%s", err, exitErr.Stderr) + return nil, fmt.Errorf("could not enumerate benchmarks: %v\nstderr\n%s", err, exitErr.Stderr) } benches := strings.Trim(string(out), "\n") |