@@ -5,65 +5,37 @@ import (
55 "time"
66
77 "github.com/onsi/ginkgo/v2/types"
8- "github.com/openshift-eng/openshift-tests-extension/ pkg/extension/extensiontests "
9- "k8s.io/apimachinery/pkg/util/errors "
8+ "github.com/pkg/errors "
9+ "github.com/sirupsen/logrus "
1010
1111 "github.com/openshift/origin/pkg/test/extensions"
1212)
1313
14- func internalTestSpecsToOriginTestCases (suite * TestSuite , specs extensiontests.ExtensionTestSpecs ) ([]* testCase , error ) {
15- var tests []* testCase
16- var errs []error
17-
18- specs .Walk (func (spec * extensiontests.ExtensionTestSpec ) {
19- tc := & testCase {
20- name : spec .Name ,
21- rawName : spec .Name ,
22- }
23- if suite != nil && suite .TestTimeout > 0 {
24- tc .testTimeout = suite .TestTimeout
25- }
26-
27- tests = append (tests , tc )
28- })
29- if len (errs ) > 0 {
30- return nil , errors .NewAggregate (errs )
31- }
32-
33- return tests , nil
34- }
35-
3614var re = regexp .MustCompile (`.*\[Timeout:(.[^\]]*)\]` )
3715
38- func externalBinaryTestsToOriginTestCases (specs extensions.ExtensionTestSpecs ) []* testCase {
16+ func extensionTestSpecsToOriginTestCases (specs extensions.ExtensionTestSpecs ) ( []* testCase , error ) {
3917 var tests []* testCase
4018 for _ , spec := range specs {
41- tests = append ( tests , & testCase {
19+ tc := & testCase {
4220 name : spec .Name ,
4321 rawName : spec .Name ,
4422 binary : spec .Binary ,
45- })
46- }
47- return tests
48- }
49-
50- func newTestCaseFromGinkgoSpec (spec types.TestSpec ) (* testCase , error ) {
51- name := spec .Text ()
52- tc := & testCase {
53- name : name ,
54- locations : spec .CodeLocations (),
55- spec : spec ,
56- }
23+ }
5724
58- if match := re .FindStringSubmatch (name ); match != nil {
59- testTimeOut , err := time .ParseDuration (match [1 ])
60- if err != nil {
61- return nil , err
25+ // Override timeout from suite with `[Timeout:X]` duration
26+ if match := re .FindStringSubmatch (tc .name ); match != nil {
27+ testTimeOut , err := time .ParseDuration (match [1 ])
28+ if err != nil {
29+ return nil , errors .WithMessage (err , "failed to parse test timeout" )
30+ }
31+ logrus .WithField ("test" , tc .name ).Debugf ("Overriding test timeout to %s" , testTimeOut )
32+ tc .testTimeout = testTimeOut
6233 }
63- tc .testTimeout = testTimeOut
34+
35+ tests = append (tests , tc )
6436 }
6537
66- return tc , nil
38+ return tests , nil
6739}
6840
6941type testCase struct {
@@ -161,8 +133,6 @@ type TestSuite struct {
161133 Extension * extensions.Extension `json:"-"`
162134}
163135
164-
165-
166136type TestMatchFunc func (name string ) bool
167137
168138func (s * TestSuite ) Filter (tests []* testCase ) []* testCase {
0 commit comments