Этот коммит содержится в:
Viacheslav Poturaev 2023-04-04 00:11:09 +02:00 коммит произвёл GitHub
родитель dc8c9c4378
коммит aba6a689a4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
8 изменённых файлов: 28 добавлений и 24 удалений

2
.github/workflows/release-assets.yml предоставленный
Просмотреть файл

@ -15,7 +15,7 @@ jobs:
- name: Install Go - name: Install Go
uses: actions/setup-go@v4 uses: actions/setup-go@v4
with: with:
go-version: 1.17.x go-version: 1.20.x
- name: Checkout code - name: Checkout code
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Build artifacts - name: Build artifacts

2
.github/workflows/test.yml предоставленный
Просмотреть файл

@ -8,7 +8,7 @@ jobs:
test: test:
strategy: strategy:
matrix: 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 runs-on: ubuntu-latest
steps: steps:
- name: Install Go - name: Install Go

Просмотреть файл

@ -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.. Before you begin, you describe how the feature should work, see the example below..
Example: Example:
Feature: ls Feature: ls
In order to see the directory structure In order to see the directory structure
As a UNIX user As a UNIX user

Просмотреть файл

@ -24,8 +24,9 @@ func testWithVendoredGodogAndMod(t *testing.T) {
"go.mod": builderModFile, "go.mod": builderModFile,
} }
builderTC.goModCmds = make([]*exec.Cmd, 1) builderTC.goModCmds = make([]*exec.Cmd, 2)
builderTC.goModCmds[0] = exec.Command("go", "mod", "vendor") builderTC.goModCmds[0] = exec.Command("go", "mod", "tidy")
builderTC.goModCmds[1] = exec.Command("go", "mod", "vendor")
builderTC.testCmdEnv = append(envVarsWithoutGopath(), "GOPATH="+gopath) builderTC.testCmdEnv = append(envVarsWithoutGopath(), "GOPATH="+gopath)
builderTC.run(t) builderTC.run(t)

Просмотреть файл

@ -1,13 +1,10 @@
package builder_test package builder_test
import ( import (
"fmt"
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"testing" "testing"
"github.com/cucumber/godog"
) )
func testOutsideGopathAndHavingOnlyFeature(t *testing.T) { func testOutsideGopathAndHavingOnlyFeature(t *testing.T) {
@ -21,8 +18,7 @@ func testOutsideGopathAndHavingOnlyFeature(t *testing.T) {
builderTC.goModCmds = make([]*exec.Cmd, 2) builderTC.goModCmds = make([]*exec.Cmd, 2)
builderTC.goModCmds[0] = exec.Command("go", "mod", "init", "godogs") 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", "tidy")
builderTC.goModCmds[1] = exec.Command("go", "mod", "edit", "-require", godogDependency)
builderTC.run(t) builderTC.run(t)
} }

Просмотреть файл

@ -6,6 +6,7 @@ import (
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"strings"
"testing" "testing"
"testing/fstest" "testing/fstest"
@ -72,7 +73,7 @@ func TestStorage_Open_OS(t *testing.T) {
expData: []byte("hello worlds"), expData: []byte("hello worlds"),
}, },
"nil fs falls back on os": { "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"),
}, },
} }
@ -95,7 +96,7 @@ func TestStorage_Open_OS(t *testing.T) {
f, err := (storage.FS{}).Open(filepath.Join(baseDir, "testfile")) f, err := (storage.FS{}).Open(filepath.Join(baseDir, "testfile"))
if test.expError != nil { if test.expError != nil {
assert.Error(t, err) assert.Error(t, err)
assert.EqualError(t, err, test.expError.Error()) assert.EqualError(t, err, strings.ReplaceAll(test.expError.Error(), "%baseDir%", baseDir))
return return
} }

Просмотреть файл

@ -704,13 +704,13 @@ func (tc *godogFeaturesScenario) theseEventsHadToBeFiredForNumberOfTimes(tbl *Ta
func (tc *godogFeaturesScenario) theRenderJSONWillBe(docstring *DocString) error { func (tc *godogFeaturesScenario) theRenderJSONWillBe(docstring *DocString) error {
expectedSuiteCtxReg := regexp.MustCompile(`suite_context.go:\d+`) 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 := docstring.Content
expectedString = expectedSuiteCtxReg.ReplaceAllString(expectedString, `suite_context_test.go:0`) expectedString = expectedSuiteCtxReg.ReplaceAllString(expectedString, `<autogenerated>:0`)
actualString := tc.out.String() actualString := tc.out.String()
actualString = actualSuiteCtxReg.ReplaceAllString(actualString, `suite_context_test.go:0`) actualString = actualSuiteCtxReg.ReplaceAllString(actualString, `<autogenerated>:0`)
var expected []formatters.CukeFeatureJSON var expected []formatters.CukeFeatureJSON
if err := json.Unmarshal([]byte(expectedString), &expected); err != nil { if err := json.Unmarshal([]byte(expectedString), &expected); err != nil {
@ -726,8 +726,8 @@ func (tc *godogFeaturesScenario) theRenderJSONWillBe(docstring *DocString) error
} }
func (tc *godogFeaturesScenario) theRenderOutputWillBe(docstring *DocString) error { func (tc *godogFeaturesScenario) theRenderOutputWillBe(docstring *DocString) error {
expectedSuiteCtxReg := regexp.MustCompile(`suite_context.go:\d+`) expectedSuiteCtxReg := regexp.MustCompile(`(suite_context\.go|suite_context_test\.go):\d+`)
actualSuiteCtxReg := regexp.MustCompile(`suite_context_test.go:\d+`) actualSuiteCtxReg := regexp.MustCompile(`(suite_context_test\.go|\<autogenerated\>):\d+`)
expectedSuiteCtxFuncReg := regexp.MustCompile(`SuiteContext.func(\d+)`) expectedSuiteCtxFuncReg := regexp.MustCompile(`SuiteContext.func(\d+)`)
actualSuiteCtxFuncReg := regexp.MustCompile(`github.com/cucumber/godog.InitializeScenario.func(\d+)`) actualSuiteCtxFuncReg := regexp.MustCompile(`github.com/cucumber/godog.InitializeScenario.func(\d+)`)
@ -736,12 +736,12 @@ func (tc *godogFeaturesScenario) theRenderOutputWillBe(docstring *DocString) err
expected := docstring.Content expected := docstring.Content
expected = trimAllLines(expected) 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 = expectedSuiteCtxFuncReg.ReplaceAllString(expected, "InitializeScenario.func$1")
expected = suiteCtxPtrReg.ReplaceAllString(expected, "*godogFeaturesScenario") expected = suiteCtxPtrReg.ReplaceAllString(expected, "*godogFeaturesScenario")
actual := tc.out.String() 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") actual = actualSuiteCtxFuncReg.ReplaceAllString(actual, "InitializeScenario.func$1")
actualTrimmed := actual actualTrimmed := actual
actual = trimAllLines(actual) actual = trimAllLines(actual)
@ -769,6 +769,11 @@ func (tc *godogFeaturesScenario) theRenderXMLWillBe(docstring *DocString) error
func assertExpectedAndActual(a expectedAndActualAssertion, expected, actual interface{}, msgAndArgs ...interface{}) error { func assertExpectedAndActual(a expectedAndActualAssertion, expected, actual interface{}, msgAndArgs ...interface{}) error {
var t asserter var t asserter
a(&t, expected, actual, msgAndArgs...) a(&t, expected, actual, msgAndArgs...)
if t.err != nil {
return t.err
}
return t.err return t.err
} }