From 5d33040ab80b5cce7883b2e5965aa17db2e6515a Mon Sep 17 00:00:00 2001 From: Flu0r1ne Date: Fri, 13 Aug 2021 18:25:17 -0500 Subject: Opt to show CLI output over JSON output --- adapters/gtest/adapter.go | 6 ++++-- adapters/gtest/results.go | 1 + cmd/planr/sub/cli.go | 4 ++-- testcase.go | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/adapters/gtest/adapter.go b/adapters/gtest/adapter.go index 3d769e3..8dc333d 100644 --- a/adapters/gtest/adapter.go +++ b/adapters/gtest/adapter.go @@ -85,7 +85,8 @@ func (adapter *GtestAdapter) execTests(cnames []string) ResultFromId { defer cancel() defer os.Remove(f.Name()) - if err := cmd.Run(); err != nil { + out, err := cmd.CombinedOutput() + if err != nil { var exiterr *exec.ExitError if !errors.As(err, &exiterr) { @@ -95,6 +96,7 @@ func (adapter *GtestAdapter) execTests(cnames []string) ResultFromId { } for _, r := range decodeResults(f) { + r.testOutput = string(out) lut[exe + "." + r.id] = r } } @@ -169,6 +171,6 @@ func (adapter *GtestAdapter) Evaluate(tcs []*planr.TestCase) { tc.Result.Status = planr.RUNTIME_FAILURE } - tc.Result.FailureMsg = result.failureMsg + tc.Result.TestOutput = result.testOutput } } diff --git a/adapters/gtest/results.go b/adapters/gtest/results.go index 0e96edc..2991823 100644 --- a/adapters/gtest/results.go +++ b/adapters/gtest/results.go @@ -49,6 +49,7 @@ type Result struct { id string pass bool failureMsg string + testOutput string } func failureMsg(failures []gFailure) string { diff --git a/cmd/planr/sub/cli.go b/cmd/planr/sub/cli.go index da888d9..dff9089 100644 --- a/cmd/planr/sub/cli.go +++ b/cmd/planr/sub/cli.go @@ -97,9 +97,9 @@ func tcPprint(tc planr.TestCase) { } else if res.Status == planr.RUNTIME_FAILURE { - if tc.Result.FailureMsg != "" { + if tc.Result.TestOutput != "" { fmt.Println() - pprintFenced("test output", tc.Result.FailureMsg); + pprintFenced("test output", tc.Result.TestOutput); } } diff --git a/testcase.go b/testcase.go index d3fe8ed..8506b84 100644 --- a/testcase.go +++ b/testcase.go @@ -11,8 +11,8 @@ const ( type TestResult struct { Id string Status TestStatus - FailureMsg string DebugOutput string + TestOutput string } type TestCase struct { -- cgit v1.2.3