@@ -11,24 +11,16 @@ import (
1111 "github.com/smartcontractkit/chainlink-testing-framework/tools/flakeguard/reports"
1212 "github.com/smartcontractkit/chainlink-testing-framework/tools/flakeguard/runner/executor"
1313 "github.com/smartcontractkit/chainlink-testing-framework/tools/flakeguard/runner/parser"
14- // No parser import needed if files are in the same package
1514)
1615
1716const (
1817 RawOutputDir = "./flakeguard_raw_output"
19- // Removed RawOutputTransformedDir - belongs in parser.go
20- )
21-
22- var (
23- // buildErr remains defined in the parser package
24- // Consider defining shared errors in a common errors package if needed elsewhere
2518)
2619
2720// Runner describes the test run parameters and manages test execution and result parsing.
28- // It now delegates command execution to an Executor and result parsing to a Parser.
21+ // It delegates command execution to an Executor and result parsing to a Parser.
2922type Runner struct {
30- // Configuration fields (consider grouping into a Config struct if it grows larger)
31- // Keep only fields relevant to Runner's orchestration role or executor config
23+ // Configuration fields
3224 ProjectPath string
3325 Verbose bool
3426 RunCount int
@@ -42,10 +34,9 @@ type Runner struct {
4234 SkipTests []string
4335 SelectTests []string
4436
45- // Configuration for the parser
46- OmitOutputsOnSuccess bool
47- MaxPassRatio float64 // TODO: Is this still used by Runner or belongs elsewhere?
37+ // Configuration passed down to the parser
4838 IgnoreParentFailuresOnSubtests bool
39+ OmitOutputsOnSuccess bool
4940
5041 // Dependencies
5142 exec executor.Executor // Injected Executor
@@ -68,10 +59,9 @@ func NewRunner(
6859 failFast bool ,
6960 skipTests []string ,
7061 selectTests []string ,
71- // Parser specific config
62+ // Parser specific config (passed during initialization)
63+ ignoreParentFailuresOnSubtests bool ,
7264 omitOutputsOnSuccess bool ,
73- maxPassRatio float64 , // Note: MaxPassRatio currently unused after refactor, belongs in reporting?
74- ignoreParentFailuresOnSubtests bool , // Passed to parser
7565 // Dependencies (allow injection for testing)
7666 exec executor.Executor ,
7767 p parser.Parser , // Use interface type directly
@@ -95,9 +85,8 @@ func NewRunner(
9585 FailFast : failFast ,
9686 SkipTests : skipTests ,
9787 SelectTests : selectTests ,
98- OmitOutputsOnSuccess : omitOutputsOnSuccess ,
99- MaxPassRatio : maxPassRatio ,
10088 IgnoreParentFailuresOnSubtests : ignoreParentFailuresOnSubtests ,
89+ OmitOutputsOnSuccess : omitOutputsOnSuccess ,
10190 exec : exec ,
10291 parser : p ,
10392 }
@@ -120,6 +109,14 @@ func (r *Runner) getExecutorConfig() executor.Config {
120109 }
121110}
122111
112+ // Helper function to create parser.Config from Runner fields
113+ func (r * Runner ) getParserConfig () parser.Config {
114+ return parser.Config {
115+ IgnoreParentFailuresOnSubtests : r .IgnoreParentFailuresOnSubtests ,
116+ OmitOutputsOnSuccess : r .OmitOutputsOnSuccess ,
117+ }
118+ }
119+
123120// RunTestPackages executes the tests for each provided package and aggregates all results.
124121func (r * Runner ) RunTestPackages (packages []string ) ([]reports.TestResult , error ) {
125122 rawOutputFiles := make ([]string , 0 ) // Collect output file paths for this run
@@ -151,12 +148,12 @@ ParseResults:
151148 }
152149
153150 log .Info ().Int ("file_count" , len (rawOutputFiles )).Msg ("Parsing output files" )
151+ // Create parser config and pass it
152+ parserCfg := r .getParserConfig ()
154153 // Ignore the returned file paths here, as they aren't used in this flow
155- results , _ , err := r .parser .ParseFiles (rawOutputFiles , "run" , len (rawOutputFiles ), r . IgnoreParentFailuresOnSubtests , r . OmitOutputsOnSuccess )
154+ results , _ , err := r .parser .ParseFiles (rawOutputFiles , "run" , len (rawOutputFiles ), parserCfg )
156155 if err != nil {
157156 // Check if it's a build error from the parser
158- // Use errors.Is with the error defined in the parser package (or a shared error package)
159- // Assuming parser.ErrBuild is exported:
160157 if errors .Is (err , parser .ErrBuild ) { // Updated check
161158 // No extra wrapping needed if buildErr already provides enough context
162159 return nil , err
@@ -195,8 +192,10 @@ func (r *Runner) RunTestCmd(testCmd []string) ([]reports.TestResult, error) {
195192 }
196193
197194 log .Info ().Int ("file_count" , len (rawOutputFiles )).Msg ("Parsing output files from custom command" )
195+ // Create parser config and pass it
196+ parserCfg := r .getParserConfig ()
198197 // Ignore the returned file paths here as well
199- results , _ , err := r .parser .ParseFiles (rawOutputFiles , "run" , len (rawOutputFiles ), r . IgnoreParentFailuresOnSubtests , r . OmitOutputsOnSuccess )
198+ results , _ , err := r .parser .ParseFiles (rawOutputFiles , "run" , len (rawOutputFiles ), parserCfg )
200199 if err != nil {
201200 if errors .Is (err , parser .ErrBuild ) { // Updated check
202201 return nil , err
@@ -287,19 +286,24 @@ func (r *Runner) RerunFailedTests(failedTests []reports.TestResult, rerunCount i
287286 }
288287
289288 log .Info ().Int ("file_count" , len (rerunOutputFiles )).Msg ("Parsing rerun output files" )
289+ // Create parser config and pass it
290+ parserCfg := r .getParserConfig ()
290291 // For parsing reruns, the effective number of runs *per test included in the output* is `rerunCount`.
291292 // The parser's `expectedRuns` helps adjust for potential overcounting within each file, using `rerunCount` seems correct here.
292- rerunResults , parsedFilePaths , err := r .parser .ParseFiles (rerunOutputFiles , "rerun" , rerunCount , r . IgnoreParentFailuresOnSubtests , r . OmitOutputsOnSuccess )
293+ rerunResults , parsedFilePaths , err := r .parser .ParseFiles (rerunOutputFiles , "rerun" , rerunCount , parserCfg )
293294 if err != nil {
294295 // Check for build error specifically?
295296 if errors .Is (err , parser .ErrBuild ) { // Updated check
296297 log .Error ().Err (err ).Msg ("Build error occurred unexpectedly during test reruns" )
297298 // Fallthrough to return wrapped error
298299 }
300+ // Return the file paths even if parsing failed? No, the report wouldn't be useful.
299301 return nil , nil , fmt .Errorf ("failed to parse rerun results: %w" , err )
300302 }
301303
302304 // 5. Return Results
303305 log .Info ().Int ("result_count" , len (rerunResults )).Msg ("Finished parsing rerun results" )
306+ // Return the parsed results AND the list of files parsed.
307+ // Note: The function signature needs to change back to return []string
304308 return rerunResults , parsedFilePaths , nil
305309}
0 commit comments