@@ -72,19 +72,17 @@ type runner struct {
72
72
workDir string // Directory for running tests
73
73
log log.Logger
74
74
runID string
75
- timeout time.Duration // Test timeout
76
- goBinary string // Path to the Go binary
77
- allowSkips bool // Whether to allow skipping tests when preconditions are not met
75
+ goBinary string // Path to the Go binary
76
+ allowSkips bool // Whether to allow skipping tests when preconditions are not met
78
77
}
79
78
80
79
type Config struct {
81
80
Registry * registry.Registry
82
81
TargetGate string
83
82
WorkDir string
84
83
Log log.Logger
85
- Timeout time.Duration // Test timeout
86
- GoBinary string // path to the Go binary
87
- AllowSkips bool // Whether to allow skipping tests when preconditions are not met
84
+ GoBinary string // path to the Go binary
85
+ AllowSkips bool // Whether to allow skipping tests when preconditions are not met
88
86
}
89
87
90
88
// NewTestRunner creates a new test runner instance
@@ -111,10 +109,6 @@ func NewTestRunner(cfg Config) (TestRunner, error) {
111
109
return nil , fmt .Errorf ("no validators found" )
112
110
}
113
111
114
- if cfg .Timeout == 0 {
115
- cfg .Timeout = 5 * time .Minute // Default timeout
116
- }
117
-
118
112
if cfg .GoBinary == "" {
119
113
cfg .GoBinary = "go" // Default to "go" if not specified
120
114
}
@@ -124,7 +118,6 @@ func NewTestRunner(cfg Config) (TestRunner, error) {
124
118
validators : validators ,
125
119
workDir : cfg .WorkDir ,
126
120
log : cfg .Log ,
127
- timeout : cfg .Timeout ,
128
121
goBinary : cfg .GoBinary ,
129
122
allowSkips : cfg .AllowSkips ,
130
123
}, nil
@@ -504,8 +497,13 @@ type TestEvent struct {
504
497
505
498
// runSingleTest runs a specific test
506
499
func (r * runner ) runSingleTest (metadata types.ValidatorMetadata ) (* types.TestResult , error ) {
507
- ctx , cancel := context .WithTimeout (context .Background (), r .timeout )
508
- defer cancel ()
500
+
501
+ ctx := context .Background ()
502
+ if metadata .Timeout != 0 {
503
+ var cancel func ()
504
+ ctx , cancel = context .WithTimeout (ctx , metadata .Timeout )
505
+ defer cancel ()
506
+ }
509
507
510
508
args := r .buildTestArgs (metadata )
511
509
cmd := exec .CommandContext (ctx , r .goBinary , args ... )
@@ -528,7 +526,7 @@ func (r *runner) runSingleTest(metadata types.ValidatorMetadata) (*types.TestRes
528
526
"package" , metadata .Package ,
529
527
"test" , metadata .FuncName ,
530
528
"command" , cmd .String (),
531
- "timeout" , r . timeout ,
529
+ "timeout" , metadata . Timeout ,
532
530
"allowSkips" , r .allowSkips )
533
531
534
532
// Run the command
@@ -539,7 +537,7 @@ func (r *runner) runSingleTest(metadata types.ValidatorMetadata) (*types.TestRes
539
537
return & types.TestResult {
540
538
Metadata : metadata ,
541
539
Status : types .TestStatusFail ,
542
- Error : fmt .Errorf ("test timed out after %v" , r . timeout ),
540
+ Error : fmt .Errorf ("test timed out after %v" , metadata . Timeout ),
543
541
}, nil
544
542
}
545
543
@@ -763,6 +761,11 @@ func (r *runner) buildTestArgs(metadata types.ValidatorMetadata) []string {
763
761
// Always disable caching
764
762
args = append (args , "-count" , "1" )
765
763
764
+ // Add timeout if it's not 0
765
+ if metadata .Timeout != 0 {
766
+ args = append (args , "-timeout" , metadata .Timeout .String ())
767
+ }
768
+
766
769
// Always use verbose output
767
770
args = append (args , "-v" )
768
771
0 commit comments