From f9fab51a1aed6d5aca1e6bd3ba781db6b885c4cf Mon Sep 17 00:00:00 2001 From: gedi Date: Fri, 27 May 2016 14:55:58 +0300 Subject: [PATCH] fixes bug when there is more than one context registered, closes #32 --- builder.go | 4 +++- cmd/godog/main.go | 4 ++-- suite_test.go | 8 -------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/builder.go b/builder.go index 8d2fe85..aea0f11 100644 --- a/builder.go +++ b/builder.go @@ -23,7 +23,9 @@ const GodogSuiteName = "{{ .Name }}" func TestMain(m *testing.M) { status := {{ if ne .Name "godog" }}godog.{{ end }}Run(func (suite *{{ if ne .Name "godog" }}godog.{{ end }}Suite) { - {{range .Contexts}}{{ . }}(suite){{end}} + {{range .Contexts}} + {{ . }}(suite) + {{end}} }) os.Exit(status) }`)) diff --git a/cmd/godog/main.go b/cmd/godog/main.go index 3f37489..1df624a 100644 --- a/cmd/godog/main.go +++ b/cmd/godog/main.go @@ -41,7 +41,7 @@ func buildAndRun() (int, error) { cmdb.Dir = dir cmdb.Env = os.Environ() if details, err := cmdb.CombinedOutput(); err != nil { - fmt.Println(string(details)) + fmt.Fprintln(stderr, string(details)) return 1, err } defer os.Remove(bin) @@ -77,7 +77,7 @@ func buildAndRun() (int, error) { func main() { status, err := buildAndRun() if err != nil { - fmt.Println(err) + fmt.Fprintln(os.Stderr, err) os.Exit(1) } // it might be a case, that status might not be resolved diff --git a/suite_test.go b/suite_test.go index b28da9b..4f0edc0 100644 --- a/suite_test.go +++ b/suite_test.go @@ -1,21 +1,13 @@ package godog import ( - "flag" "fmt" - "os" "strconv" "strings" - "testing" "github.com/DATA-DOG/godog/gherkin" ) -func TestMain(m *testing.M) { - flag.Parse() - os.Exit(m.Run()) -} - func SuiteContext(s *Suite) { c := &suiteContext{}