Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Do not sleep when feature test fails #598

Merged
merged 1 commit into from
Apr 2, 2024
Merged
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
12 changes: 10 additions & 2 deletions test/feature/spqr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ func (tctx *testContext) stepErrorShouldMatch(host string, matcher string, body
}

// nolint: unused
func InitializeScenario(s *godog.ScenarioContext, t *testing.T) {
func InitializeScenario(s *godog.ScenarioContext, t *testing.T, debug bool) {
tctx, err := newTestContext(t)
if err != nil {
// TODO: how to report errors in godog
Expand All @@ -785,6 +785,9 @@ func InitializeScenario(s *godog.ScenarioContext, t *testing.T) {
})
s.StepContext().After(func(ctx context.Context, step *godog.Step, status godog.StepResultStatus, err error) (context.Context, error) {
if err != nil {
if !debug {
return ctx, err
}
log.Println(err)
log.Println("sleeping")
time.Sleep(time.Hour)
Expand Down Expand Up @@ -865,9 +868,14 @@ func TestSpqr(t *testing.T) {
paths = append(paths, featureDir)
}

debug := false
if debugEnv, ok := os.LookupEnv("FEATURE_DEBUG"); ok && strings.ToLower(debugEnv) == "true" {
debug = true
}

suite := godog.TestSuite{
ScenarioInitializer: func(s *godog.ScenarioContext) {
InitializeScenario(s, t)
InitializeScenario(s, t, debug)
},
Options: &godog.Options{
Format: "pretty",
Expand Down
Loading