From 67be041326ce28d32d52ece8818335102b6f0a76 Mon Sep 17 00:00:00 2001 From: robertdavidsmith <34475852+robertdavidsmith@users.noreply.github.com> Date: Mon, 11 Dec 2023 14:19:19 +0000 Subject: [PATCH] ARMADA-2343 minor testsuite usability improvements (#35) (#3188) Co-authored-by: Robert Smith --- cmd/testsuite/cmd/test.go | 11 ++++++++--- internal/testsuite/app.go | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cmd/testsuite/cmd/test.go b/cmd/testsuite/cmd/test.go index d6c931e94ad..93970fdbb59 100644 --- a/cmd/testsuite/cmd/test.go +++ b/cmd/testsuite/cmd/test.go @@ -53,6 +53,10 @@ func testCmdRunE(app *testsuite.App) func(cmd *cobra.Command, args []string) err return errors.WithStack(err) } + if testFilesPattern == "" { + return errors.New("You must specify \"--tests\" on the command line") + } + junitPath, err := cmd.Flags().GetString("junit") if err != nil { return errors.WithStack(err) @@ -109,7 +113,7 @@ func testCmdRunE(app *testsuite.App) func(cmd *cobra.Command, args []string) err numFailures := testSuiteReport.NumFailures() fmt.Printf("\n======= SUMMARY =======\n") w := tabwriter.NewWriter(os.Stdout, 1, 1, 1, ' ', 0) - fmt.Fprint(w, "Test:\tResult:\tElapsed:\n") + fmt.Fprint(w, "Test:\tResult:\tElapsed:\tJobSet:\n") for _, testCaseReport := range testSuiteReport.TestCaseReports { var result string if testCaseReport.FailureReason == "" { @@ -118,11 +122,12 @@ func testCmdRunE(app *testsuite.App) func(cmd *cobra.Command, args []string) err result = "FAILURE" } elapsed := testCaseReport.Finish.Sub(testCaseReport.Start) - fmt.Fprintf(w, "%s\t%s\t%s\n", testCaseReport.TestSpec.Name, result, elapsed) + + fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", testCaseReport.TestSpec.Name, result, elapsed.Round(time.Second), testCaseReport.TestSpec.JobSetId) } _ = w.Flush() fmt.Println() - fmt.Printf("Ran %d test(s) in %s\n", numSuccesses+numFailures, time.Since(start)) + fmt.Printf("Ran %d test(s) in %s\n", numSuccesses+numFailures, time.Since(start).Round(time.Second)) fmt.Printf("Success: %d\n", numSuccesses) fmt.Printf("Failure: %d\n", numFailures) fmt.Println() diff --git a/internal/testsuite/app.go b/internal/testsuite/app.go index 0eb31036370..45da621c0dd 100644 --- a/internal/testsuite/app.go +++ b/internal/testsuite/app.go @@ -90,7 +90,7 @@ func (a *App) TestPattern(ctx context.Context, pattern string) (*TestSuiteReport func TestSpecsFromPattern(pattern string) ([]*api.TestSpec, error) { filePaths, err := zglob.Glob(pattern) if err != nil { - return nil, errors.WithStack(err) + return nil, errors.Wrapf(err, "failed to glob test specs with pattern %s", pattern) } return TestSpecsFromFilePaths(filePaths) }