From 7a57e63b00603062441c7f334ca4e19517ff3f2f Mon Sep 17 00:00:00 2001 From: gedi Date: Tue, 12 Feb 2019 15:16:30 +0200 Subject: [PATCH] add go.mod --- LICENSE | 2 +- builder_go111_test.go | 2 +- builder_test.go | 37 +++++++------------------------------ go.mod | 1 + stacktrace_test.go | 14 ++------------ 5 files changed, 12 insertions(+), 44 deletions(-) create mode 100644 go.mod diff --git a/LICENSE b/LICENSE index 4a27bd1..c0c4c11 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The three clause BSD license (http://en.wikipedia.org/wiki/BSD_licenses) -Copyright (c) 2015-2018, DATA-DOG team +Copyright (c) 2015-2019, DATA-DOG team All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/builder_go111_test.go b/builder_go111_test.go index 7848ba9..625c4f2 100644 --- a/builder_go111_test.go +++ b/builder_go111_test.go @@ -51,7 +51,7 @@ func TestGodogBuildWithModuleOutsideGopath(t *testing.T) { } } -func TestGodogBuildWithModuleOutsideGopathWithXTest(t *testing.T) { +func TestGodogBuildWithModuleWithXTestOutsideGopath(t *testing.T) { dir := filepath.Join(os.TempDir(), "godogs") err := buildTestPackage(dir, map[string]string{ "godogs.feature": builderFeatureFile, diff --git a/builder_test.go b/builder_test.go index b8d60ba..f61ccdd 100644 --- a/builder_test.go +++ b/builder_test.go @@ -109,6 +109,8 @@ func main() { } ` +var builderModFile = `module godogs` + func buildTestPackage(dir string, files map[string]string) error { if err := os.MkdirAll(dir, 0755); err != nil { return err @@ -144,6 +146,7 @@ func TestGodogBuildWithSourceNotInGoPath(t *testing.T) { "godogs.feature": builderFeatureFile, "godogs.go": builderMainCodeFile, "godogs_test.go": builderTestFile, + "go.mod": builderModFile, }) if err != nil { os.RemoveAll(dir) @@ -178,6 +181,7 @@ func TestGodogBuildWithoutSourceNotInGoPath(t *testing.T) { dir := filepath.Join(os.TempDir(), "godogs") err := buildTestPackage(dir, map[string]string{ "godogs.feature": builderFeatureFile, + "go.mod": builderModFile, }) if err != nil { os.RemoveAll(dir) @@ -213,6 +217,7 @@ func TestGodogBuildWithoutTestSourceNotInGoPath(t *testing.T) { err := buildTestPackage(dir, map[string]string{ "godogs.feature": builderFeatureFile, "godogs.go": builderMainCodeFile, + "go.mod": builderModFile, }) if err != nil { os.RemoveAll(dir) @@ -250,6 +255,7 @@ func TestGodogBuildWithinGopath(t *testing.T) { "godogs.feature": builderFeatureFile, "godogs.go": builderMainCodeFile, "godogs_test.go": builderTestFile, + "go.mod": builderModFile, }) if err != nil { os.RemoveAll(gopath) @@ -299,6 +305,7 @@ func TestGodogBuildWithVendoredGodog(t *testing.T) { "godogs.feature": builderFeatureFile, "godogs.go": builderMainCodeFile, "godogs_test.go": builderTestFile, + "go.mod": builderModFile, }) if err != nil { os.RemoveAll(gopath) @@ -340,33 +347,3 @@ func TestGodogBuildWithVendoredGodog(t *testing.T) { t.Fatal(err) } } - -func TestBuildTestRunner(t *testing.T) { - bin := filepath.Join(os.TempDir(), "godog.test") - if err := Build(bin); err != nil { - t.Fatalf("failed to build godog test binary: %v", err) - } - os.Remove(bin) -} - -func TestBuildTestRunnerWithoutGoFiles(t *testing.T) { - bin := filepath.Join(os.TempDir(), "godog.test") - pwd, err := os.Getwd() - if err != nil { - t.Fatalf("failed to get working directory: %v", err) - } - - wd := filepath.Join(pwd, "features") - if err := os.Chdir(wd); err != nil { - t.Fatalf("failed to change working directory: %v", err) - } - - defer func() { - _ = os.Chdir(pwd) // get back to current dir - }() - - if err := Build(bin); err != nil { - t.Fatalf("failed to build godog test binary: %v", err) - } - os.Remove(bin) -} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..8eec8f7 --- /dev/null +++ b/go.mod @@ -0,0 +1 @@ +module godog diff --git a/stacktrace_test.go b/stacktrace_test.go index 21369aa..88c4b24 100644 --- a/stacktrace_test.go +++ b/stacktrace_test.go @@ -43,18 +43,8 @@ func TestStacktrace(t *testing.T) { t.Fatalf("expected formatted trace error message to be: %s, but got %s", expect, actual) } - expect = trimLineSpaces(`err msg -github.com/DATA-DOG/godog.callstack3 -github.com/DATA-DOG/godog/stacktrace_test.go:29 -github.com/DATA-DOG/godog.callstack2 -github.com/DATA-DOG/godog/stacktrace_test.go:23 -github.com/DATA-DOG/godog.callstack1 -github.com/DATA-DOG/godog/stacktrace_test.go:19 -github.com/DATA-DOG/godog.TestStacktrace -github.com/DATA-DOG/godog/stacktrace_test.go:37`) - actual = trimLineSpaces(fmt.Sprintf("%+v", err)) - if expect != actual { - t.Fatalf("detaily formatted actual: %s", actual) + if strings.Index(actual, "stacktrace_test.go") == -1 { + t.Fatalf("does not have stacktrace in actual: %s", actual) } }