Skip to content

Commit

Permalink
ARMADA-2343 minor testsuite usability improvements (#35) (#3188)
Browse files Browse the repository at this point in the history
Co-authored-by: Robert Smith <[email protected]>
  • Loading branch information
robertdavidsmith and robdsmith authored Dec 11, 2023
1 parent 6a62b18 commit 67be041
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions cmd/testsuite/cmd/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 == "" {
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion internal/testsuite/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 67be041

Please sign in to comment.