Skip to content

Commit

Permalink
Update CI for go1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
vearutop committed Mar 30, 2023
1 parent 6ce2b86 commit 0bd17bf
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.17.x
go-version: 1.20.x
- name: Checkout code
uses: actions/checkout@v3
- name: Build artifacts
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
test:
strategy:
matrix:
go-version: [ 1.16.x, 1.17.x ]
go-version: [ 1.16.x, 1.17.x, 1.19.x, 1.20.x ] # Lowest supported and current stable versions.
runs-on: ubuntu-latest
steps:
- name: Install Go
Expand Down
1 change: 1 addition & 0 deletions godog.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ For example, imagine you're about to create the famous UNIX ls command.
Before you begin, you describe how the feature should work, see the example below..
Example:
Feature: ls
In order to see the directory structure
As a UNIX user
Expand Down
5 changes: 3 additions & 2 deletions internal/builder/builder_go113_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ func testWithVendoredGodogAndMod(t *testing.T) {
"go.mod": builderModFile,
}

builderTC.goModCmds = make([]*exec.Cmd, 1)
builderTC.goModCmds[0] = exec.Command("go", "mod", "vendor")
builderTC.goModCmds = make([]*exec.Cmd, 2)
builderTC.goModCmds[0] = exec.Command("go", "mod", "tidy")
builderTC.goModCmds[1] = exec.Command("go", "mod", "vendor")
builderTC.testCmdEnv = append(envVarsWithoutGopath(), "GOPATH="+gopath)

builderTC.run(t)
Expand Down
6 changes: 1 addition & 5 deletions internal/builder/builder_go_module_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package builder_test

import (
"fmt"
"os"
"os/exec"
"path/filepath"
"testing"

"github.com/cucumber/godog"
)

func testOutsideGopathAndHavingOnlyFeature(t *testing.T) {
Expand All @@ -21,8 +18,7 @@ func testOutsideGopathAndHavingOnlyFeature(t *testing.T) {
builderTC.goModCmds = make([]*exec.Cmd, 2)
builderTC.goModCmds[0] = exec.Command("go", "mod", "init", "godogs")

godogDependency := fmt.Sprintf("github.com/cucumber/godog@%s", godog.Version)
builderTC.goModCmds[1] = exec.Command("go", "mod", "edit", "-require", godogDependency)
builderTC.goModCmds[1] = exec.Command("go", "mod", "tidy")

builderTC.run(t)
}
Expand Down
5 changes: 3 additions & 2 deletions internal/storage/fs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"strings"
"testing"
"testing/fstest"

Expand Down Expand Up @@ -72,7 +73,7 @@ func TestStorage_Open_OS(t *testing.T) {
expData: []byte("hello worlds"),
},
"nil fs falls back on os": {
expError: errors.New("open /tmp/TestStorage_Open_OS/nil_fs_falls_back_on_os/godogs/testfile: no such file or directory"),
expError: errors.New("open %baseDir%/testfile: no such file or directory"),
},
}

Expand All @@ -95,7 +96,7 @@ func TestStorage_Open_OS(t *testing.T) {
f, err := (storage.FS{}).Open(filepath.Join(baseDir, "testfile"))
if test.expError != nil {
assert.Error(t, err)
assert.EqualError(t, err, test.expError.Error())
assert.EqualError(t, err, strings.ReplaceAll(test.expError.Error(), "%baseDir%", baseDir))
return
}

Expand Down
12 changes: 6 additions & 6 deletions stacktrace.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ func (f stackFrame) line() int {

// Format formats the frame according to the fmt.Formatter interface.
//
// %s source file
// %d source line
// %n function name
// %v equivalent to %s:%d
// %s source file
// %d source line
// %n function name
// %v equivalent to %s:%d
//
// Format accepts flags that alter the printing of some verbs, as follows:
//
// %+s path of source file relative to the compile time GOPATH
// %+v equivalent to %+s:%d
// %+s path of source file relative to the compile time GOPATH
// %+v equivalent to %+s:%d
func (f stackFrame) Format(s fmt.State, verb rune) {
funcname := func(name string) string {
i := strings.LastIndex(name, "/")
Expand Down
19 changes: 12 additions & 7 deletions suite_context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -704,13 +704,13 @@ func (tc *godogFeaturesScenario) theseEventsHadToBeFiredForNumberOfTimes(tbl *Ta

func (tc *godogFeaturesScenario) theRenderJSONWillBe(docstring *DocString) error {
expectedSuiteCtxReg := regexp.MustCompile(`suite_context.go:\d+`)
actualSuiteCtxReg := regexp.MustCompile(`suite_context_test.go:\d+`)
actualSuiteCtxReg := regexp.MustCompile(`(suite_context_test\.go|\\u003cautogenerated\\u003e):\d+`)

expectedString := docstring.Content
expectedString = expectedSuiteCtxReg.ReplaceAllString(expectedString, `suite_context_test.go:0`)
expectedString = expectedSuiteCtxReg.ReplaceAllString(expectedString, `<autogenerated>:0`)

actualString := tc.out.String()
actualString = actualSuiteCtxReg.ReplaceAllString(actualString, `suite_context_test.go:0`)
actualString = actualSuiteCtxReg.ReplaceAllString(actualString, `<autogenerated>:0`)

var expected []formatters.CukeFeatureJSON
if err := json.Unmarshal([]byte(expectedString), &expected); err != nil {
Expand All @@ -726,8 +726,8 @@ func (tc *godogFeaturesScenario) theRenderJSONWillBe(docstring *DocString) error
}

func (tc *godogFeaturesScenario) theRenderOutputWillBe(docstring *DocString) error {
expectedSuiteCtxReg := regexp.MustCompile(`suite_context.go:\d+`)
actualSuiteCtxReg := regexp.MustCompile(`suite_context_test.go:\d+`)
expectedSuiteCtxReg := regexp.MustCompile(`(suite_context\.go|suite_context_test\.go):\d+`)
actualSuiteCtxReg := regexp.MustCompile(`(suite_context_test\.go|\<autogenerated\>):\d+`)

expectedSuiteCtxFuncReg := regexp.MustCompile(`SuiteContext.func(\d+)`)
actualSuiteCtxFuncReg := regexp.MustCompile(`github.com/cucumber/godog.InitializeScenario.func(\d+)`)
Expand All @@ -736,12 +736,12 @@ func (tc *godogFeaturesScenario) theRenderOutputWillBe(docstring *DocString) err

expected := docstring.Content
expected = trimAllLines(expected)
expected = expectedSuiteCtxReg.ReplaceAllString(expected, "suite_context_test.go:0")
expected = expectedSuiteCtxReg.ReplaceAllString(expected, "<autogenerated>:0")
expected = expectedSuiteCtxFuncReg.ReplaceAllString(expected, "InitializeScenario.func$1")
expected = suiteCtxPtrReg.ReplaceAllString(expected, "*godogFeaturesScenario")

actual := tc.out.String()
actual = actualSuiteCtxReg.ReplaceAllString(actual, "suite_context_test.go:0")
actual = actualSuiteCtxReg.ReplaceAllString(actual, "<autogenerated>:0")
actual = actualSuiteCtxFuncReg.ReplaceAllString(actual, "InitializeScenario.func$1")
actualTrimmed := actual
actual = trimAllLines(actual)
Expand Down Expand Up @@ -769,6 +769,11 @@ func (tc *godogFeaturesScenario) theRenderXMLWillBe(docstring *DocString) error
func assertExpectedAndActual(a expectedAndActualAssertion, expected, actual interface{}, msgAndArgs ...interface{}) error {
var t asserter
a(&t, expected, actual, msgAndArgs...)

if t.err != nil {
return t.err
}

return t.err
}

Expand Down

0 comments on commit 0bd17bf

Please sign in to comment.