-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from jaypipes/issue45
check go test -timeout before running scenario
- Loading branch information
Showing
13 changed files
with
257 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Use and distribution licensed under the Apache license version 2. | ||
// | ||
// See the COPYING file in the root project directory for full text. | ||
|
||
package api | ||
|
||
import ( | ||
"time" | ||
) | ||
|
||
type SetOn int | ||
|
||
const ( | ||
SetOnNone SetOn = iota | ||
SetOnSpec // a test spec override | ||
SetOnPlugin // a plugin override | ||
SetOnPluginDefault // a plugin default | ||
SetOnDefault // a scenario default | ||
) | ||
|
||
// Timings contains information about a test scenario's maximum wait and | ||
// timeout duration and what aspect of the scenario (the scenario defaults, a | ||
// plugin default, a test spec override, etc) had the maximum timeout or wait | ||
// value. | ||
// | ||
// We use this information when initially assessing whether the Go test tool's | ||
// overall timeout is shorter than this maximum in order to inform the user to | ||
// increase the Go test tool timeout. | ||
type Timings struct { | ||
// GoTestTimeout will be the duration of the timeout specified (or | ||
// defaulted) by the Go test tool | ||
GoTestTimeout time.Duration | ||
// TotalWait will be non-zero when there is a wait specified for either the | ||
// scenario or a test spec and will contain the aggregate duration of all | ||
// waits | ||
TotalWait time.Duration | ||
// MaxTimeout will be non-zero when there is a timeout specified for either | ||
// the scenario or a test spec and will contain the duration of the maximum | ||
// timeout | ||
MaxTimeout time.Duration | ||
//TimeoutSetOn indicates where the MaxTimeout value was found | ||
MaxTimeoutSetOn SetOn | ||
// TimeoutSpecIndex indicates the test spec's index within the scenario where | ||
// the max timeout was found | ||
MaxTimeoutSpecIndex int | ||
} | ||
|
||
// AddWait adds a wait duration to the Timings and (re)-calculates the Timings' | ||
// MaxWait attributes | ||
func (t *Timings) AddWait( | ||
d time.Duration, | ||
) { | ||
t.TotalWait += d | ||
} | ||
|
||
// AddTimeout adds a timeout duration to the Timings and (re)-calculates the | ||
// Timings' MaxTimeout attributes | ||
func (t *Timings) AddTimeout( | ||
d time.Duration, | ||
on SetOn, | ||
specIndex int, | ||
) { | ||
if d == 0 { | ||
return | ||
} | ||
if d.Abs() > t.MaxTimeout { | ||
t.MaxTimeout = d | ||
t.MaxTimeoutSetOn = on | ||
t.MaxTimeoutSpecIndex = specIndex | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,3 @@ fixtures: | |
- start-error | ||
tests: | ||
- foo: bar | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
name: timeout-conflict-default-timeout | ||
description: a scenario with a default timeout greater than the go test tool timeout | ||
defaults: | ||
timeout: 1m | ||
tests: | ||
- foo: baz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name: timeout-conflict-spec-timeout | ||
description: a scenario with a spec timeout greater than the go test tool timeout | ||
tests: | ||
- timeout: 1m | ||
foo: baz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
name: timeout-conflict-total-wait | ||
description: a scenario with total wait times greater than the go test tool timeout | ||
tests: | ||
- wait: | ||
before: 1m | ||
foo: baz |