Skip to content

Commit

Permalink
Bypass summary printing if any of the group is pass-fail (#236)
Browse files Browse the repository at this point in the history
* Bypass summary printing if any of the group if pass-fail

* Add helper function to check if group if Passed or Failed

Co-authored-by: ccoVeille <[email protected]>

* Replace with helper function call

Co-authored-by: ccoVeille <[email protected]>

---------

Co-authored-by: ccoVeille <[email protected]>
  • Loading branch information
siddharthkoli and ccoVeille authored Jan 20, 2025
1 parent fd9a05d commit 2a4c4af
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions pkg/reporter/stdout_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ func PrintSingleGroupStdout(groupReport map[string][]Report) error {
totalSuccessCount += stdoutReport.Summary.Passed
totalFailureCount += stdoutReport.Summary.Failed
fmt.Println(stdoutReport.Text)
fmt.Printf("Summary: %d succeeded, %d failed\n\n", stdoutReport.Summary.Passed, stdoutReport.Summary.Failed)
if checkGroupsForPassFail(group) {
fmt.Printf("Summary: %d succeeded, %d failed\n\n", stdoutReport.Summary.Passed, stdoutReport.Summary.Failed)
}
}

fmt.Printf("Total Summary: %d succeeded, %d failed\n", totalSuccessCount, totalFailureCount)
Expand All @@ -70,7 +72,9 @@ func PrintDoubleGroupStdout(groupReport map[string]map[string][]Report) error {
totalSuccessCount += stdoutReport.Summary.Passed
totalFailureCount += stdoutReport.Summary.Failed
fmt.Println(stdoutReport.Text)
fmt.Printf(" Summary: %d succeeded, %d failed\n\n", stdoutReport.Summary.Passed, stdoutReport.Summary.Failed)
if checkGroupsForPassFail(group, group2) {
fmt.Printf(" Summary: %d succeeded, %d failed\n\n", stdoutReport.Summary.Passed, stdoutReport.Summary.Failed)
}
}
}

Expand All @@ -94,7 +98,9 @@ func PrintTripleGroupStdout(groupReport map[string]map[string]map[string][]Repor
totalSuccessCount += stdoutReport.Summary.Passed
totalFailureCount += stdoutReport.Summary.Failed
fmt.Println(stdoutReport.Text)
fmt.Printf(" Summary: %d succeeded, %d failed\n\n", stdoutReport.Summary.Passed, stdoutReport.Summary.Failed)
if checkGroupsForPassFail(groupOne, groupTwo, groupThree) {
fmt.Printf(" Summary: %d succeeded, %d failed\n\n", stdoutReport.Summary.Passed, stdoutReport.Summary.Failed)
}
}
}
}
Expand All @@ -103,6 +109,16 @@ func PrintTripleGroupStdout(groupReport map[string]map[string]map[string][]Repor
return nil
}

// Checks if any of the provided groups are "Passed" or "Failed".
func checkGroupsForPassFail(groups ...string) bool {
for _, group := range groups {
if group == "Passed" || group == "Failed" {
return false
}
}
return true
}

// Creates the standard text report
func createStdoutReport(reports []Report, indentSize int) reportStdout {
result := reportStdout{}
Expand Down

0 comments on commit 2a4c4af

Please sign in to comment.