@@ -17,7 +17,7 @@ var ReportCmd = &cobra.Command{
1717 RunE : func (cmd * cobra.Command , args []string ) error {
1818 fs := reports.OSFileSystem {}
1919
20- // Get flag values directly using cmd.Flags().Get* methods
20+ // Get flag values
2121 reportResultsPath , _ := cmd .Flags ().GetString ("results-path" )
2222 reportOutputPath , _ := cmd .Flags ().GetString ("output-path" )
2323 reportFormats , _ := cmd .Flags ().GetString ("format" )
@@ -104,18 +104,19 @@ var ReportCmd = &cobra.Command{
104104 }
105105 fmt .Printf ("All tests report saved to %s\n " , allTestsReportPath )
106106
107- // Generate and save the reports (all tests) in specified formats
107+ // Generate and save the summary reports (all tests) in specified formats
108108 for _ , format := range formats {
109+ format = strings .ToLower (strings .TrimSpace (format ))
109110 s = spinner .New (spinner .CharSets [11 ], 100 * time .Millisecond )
110- s .Suffix = fmt .Sprintf (" Generating all tests report in format %s..." , format )
111+ s .Suffix = fmt .Sprintf (" Generating all tests summary in format %s..." , format )
111112 s .Start ()
112113
113114 if err := generateReport (aggregatedReport , format , filepath .Join (outputDir , "all-tests" )); err != nil {
114115 s .Stop ()
115- return fmt .Errorf ("error generating all tests report in format %s: %w" , format , err )
116+ return fmt .Errorf ("error generating all tests summary in format %s: %w" , format , err )
116117 }
117118 s .Stop ()
118- fmt .Printf ("All tests report in format %s generated successfully.\n " , format )
119+ fmt .Printf ("All tests summary in format %s generated successfully.\n " , format )
119120 }
120121
121122 // Filter failed tests (PassRatio < maxPassRatio and not skipped)
@@ -153,20 +154,6 @@ var ReportCmd = &cobra.Command{
153154 }
154155 fmt .Printf ("Failed tests report saved to %s\n " , failedTestsReportPath )
155156
156- // Generate and save the reports for failed tests in specified formats
157- for _ , format := range formats {
158- s = spinner .New (spinner .CharSets [11 ], 100 * time .Millisecond )
159- s .Suffix = fmt .Sprintf (" Generating failed tests report in format %s..." , format )
160- s .Start ()
161-
162- if err := generateReport (failedReport , format , filepath .Join (outputDir , "failed-tests" )); err != nil {
163- s .Stop ()
164- return fmt .Errorf ("error generating failed tests report in format %s: %w" , format , err )
165- }
166- s .Stop ()
167- fmt .Printf ("Failed tests report in format %s generated successfully.\n " , format )
168- }
169-
170157 fmt .Printf ("Reports generated at: %s\n " , reportOutputPath )
171158
172159 return nil
@@ -176,7 +163,7 @@ var ReportCmd = &cobra.Command{
176163func init () {
177164 ReportCmd .Flags ().StringP ("results-path" , "p" , "" , "Path to the folder containing JSON test result files (required)" )
178165 ReportCmd .Flags ().StringP ("output-path" , "o" , "./report" , "Path to output the generated report files" )
179- ReportCmd .Flags ().StringP ("format" , "f" , "markdown,json" , "Comma-separated list of report formats (markdown,json)" )
166+ ReportCmd .Flags ().StringP ("format" , "f" , "markdown,json" , "Comma-separated list of summary report formats (markdown,json)" )
180167 ReportCmd .Flags ().Float64P ("max-pass-ratio" , "" , 1.0 , "The maximum pass ratio threshold for a test to be considered flaky" )
181168 ReportCmd .Flags ().StringP ("codeowners-path" , "" , "" , "Path to the CODEOWNERS file" )
182169 ReportCmd .Flags ().StringP ("repo-path" , "" , "." , "The path to the root of the repository/project" )
@@ -186,29 +173,26 @@ func init() {
186173func generateReport (report * reports.TestReport , format , outputPath string ) error {
187174 fs := reports.OSFileSystem {}
188175 format = strings .ToLower (strings .TrimSpace (format ))
176+
189177 switch format {
190178 case "markdown" :
191- mdFileName := outputPath + ".md"
179+ // Adjust the markdown filename to include "-summary"
180+ mdFileName := outputPath + "-summary.md"
192181 mdFile , err := fs .Create (mdFileName )
193182 if err != nil {
194183 return fmt .Errorf ("error creating markdown file: %w" , err )
195184 }
196185 defer mdFile .Close ()
197186 reports .GenerateMarkdownSummary (mdFile , report , 1.0 )
198187 case "json" :
199- jsonFileName := outputPath + ".json"
200- if err := reports .SaveReportNoLogs (fs , jsonFileName , * report ); err != nil {
201- return fmt .Errorf ("error saving JSON report: %w" , err )
188+ // Generate summary JSON
189+ summaryData := reports .GenerateSummaryData (report .Results , 1.0 )
190+ summaryFileName := outputPath + "-summary.json"
191+ if err := reports .SaveSummaryAsJSON (fs , summaryFileName , summaryData ); err != nil {
192+ return fmt .Errorf ("error saving summary JSON: %w" , err )
202193 }
203194 default :
204- return fmt .Errorf ("unsupported report format: %s" , format )
205- }
206-
207- // Generate summary JSON
208- summaryData := reports .GenerateSummaryData (report .Results , 1.0 )
209- summaryFileName := outputPath + "-summary.json"
210- if err := reports .SaveSummaryAsJSON (fs , summaryFileName , summaryData ); err != nil {
211- return fmt .Errorf ("error saving summary JSON: %w" , err )
195+ return fmt .Errorf ("unsupported summary report format: %s" , format )
212196 }
213197
214198 return nil
0 commit comments