Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pkg/test/ginkgo/ginkgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ func testsForSuite(cfg config.GinkgoConfigType) ([]*testCase, error) {
}
return nil, err
}
tests = append(tests, newTestCase(spec))
tc, err := newTestCase(spec)
if err != nil {
return nil, err
}
tests = append(tests, tc)
}
return tests, nil
}
Expand Down
8 changes: 7 additions & 1 deletion pkg/test/ginkgo/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,13 @@ func (s *testStatus) Run(ctx context.Context, test *testCase) {
c := exec.Command(os.Args[0], "run-test", test.name)
c.Env = append(os.Environ(), s.env...)
s.fprintf(fmt.Sprintf("started: (%s) %q\n\n", "%d/%d/%d", test.name))
out, err := runWithTimeout(ctx, c, s.timeout)

timeout := s.timeout
if test.testTimeout != 0 {
timeout = test.testTimeout
}

out, err := runWithTimeout(ctx, c, timeout)
test.end = time.Now()

duration := test.end.Sub(test.start).Round(time.Second / 10)
Expand Down
19 changes: 17 additions & 2 deletions pkg/test/ginkgo/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ type testCase struct {

// identifies which tests can be run in parallel (ginkgo runs suites linearly)
testExclusion string
// specific timeout for the current test. When set, it overrides the current
// suite timeout
testTimeout time.Duration

start time.Time
end time.Time
Expand All @@ -35,15 +38,27 @@ type testCase struct {
previous *testCase
}

func newTestCase(spec ginkgoSpec) *testCase {
func newTestCase(spec ginkgoSpec) (*testCase, error) {
name := spec.ConcatenatedString()
name = strings.TrimPrefix(name, "[Top Level] ")

summary := spec.Summary("")
return &testCase{
tc := &testCase{
name: name,
spec: spec,
location: summary.ComponentCodeLocations[len(summary.ComponentCodeLocations)-1],
}

re := regexp.MustCompile(`.*\[Timeout:(.[^\]]*)\]`)
if match := re.FindStringSubmatch(name); match != nil {
testTimeOut, err := time.ParseDuration(match[1])
if err != nil {
return nil, err
}
tc.testTimeout = testTimeOut
}

return tc, nil
}

func (t *testCase) Retry() *testCase {
Expand Down