Этот коммит содержится в:
Viacheslav Poturaev 2023-06-06 16:52:06 +02:00 коммит произвёл GitHub
родитель 7f75c5d4ee
коммит ea50e4bdfc
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
8 изменённых файлов: 30 добавлений и 61 удалений

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

@ -29,13 +29,13 @@ jobs:
- name: Run gofmt - name: Run gofmt
run: gofmt -d -e . 2>&1 | tee outfile && test -z "$(cat outfile)" && rm outfile run: gofmt -d -e . 2>&1 | tee outfile && test -z "$(cat outfile)" && rm outfile
- name: Run staticcheck - name: Run staticcheck
if: matrix.go-version == '1.17.x' if: matrix.go-version == '1.20.x'
run: | uses: dominikh/staticcheck-action@v1.3.0
bin/staticcheck_linux_amd64_2021.1.2 github.com/cucumber/godog with:
bin/staticcheck_linux_amd64_2021.1.2 github.com/cucumber/godog/cmd/godog version: "2023.1.3"
# Disable for now because of failing checks install-go: false
# TODO: Add back in when fixes are made cache-key: ${{ matrix.go }}
# bin/staticcheck_linux_amd64_2021.1.2 ./...
- name: Run go vet - name: Run go vet
run: | run: |
go vet ./... go vet ./...

Двоичные данные
bin/staticcheck_linux_amd64_2021.1.2

Двоичный файл не отображается.

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

@ -164,13 +164,13 @@ func (f *Base) Summary() {
if totalSc == 0 { if totalSc == 0 {
fmt.Fprintln(f.out, "No scenarios") fmt.Fprintln(f.out, "No scenarios")
} else { } else {
fmt.Fprintln(f.out, fmt.Sprintf("%d scenarios (%s)", totalSc, strings.Join(scenarios, ", "))) fmt.Fprintf(f.out, "%d scenarios (%s)\n", totalSc, strings.Join(scenarios, ", "))
} }
if totalSt == 0 { if totalSt == 0 {
fmt.Fprintln(f.out, "No steps") fmt.Fprintln(f.out, "No steps")
} else { } else {
fmt.Fprintln(f.out, fmt.Sprintf("%d steps (%s)", totalSt, strings.Join(steps, ", "))) fmt.Fprintf(f.out, "%d steps (%s)\n", totalSt, strings.Join(steps, ", "))
} }
elapsedString := elapsed.String() elapsedString := elapsed.String()

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

@ -51,34 +51,6 @@ const (
ansiForegroundCyan = "36" ansiForegroundCyan = "36"
ansiForegroundWhite = "37" ansiForegroundWhite = "37"
ansiForegroundDefault = "39" ansiForegroundDefault = "39"
ansiBackgroundBlack = "40"
ansiBackgroundRed = "41"
ansiBackgroundGreen = "42"
ansiBackgroundYellow = "43"
ansiBackgroundBlue = "44"
ansiBackgroundMagenta = "45"
ansiBackgroundCyan = "46"
ansiBackgroundWhite = "47"
ansiBackgroundDefault = "49"
ansiLightForegroundGray = "90"
ansiLightForegroundRed = "91"
ansiLightForegroundGreen = "92"
ansiLightForegroundYellow = "93"
ansiLightForegroundBlue = "94"
ansiLightForegroundMagenta = "95"
ansiLightForegroundCyan = "96"
ansiLightForegroundWhite = "97"
ansiLightBackgroundGray = "100"
ansiLightBackgroundRed = "101"
ansiLightBackgroundGreen = "102"
ansiLightBackgroundYellow = "103"
ansiLightBackgroundBlue = "104"
ansiLightBackgroundMagenta = "105"
ansiLightBackgroundCyan = "106"
ansiLightBackgroundWhite = "107"
) )
var colorMap = map[string]string{ var colorMap = map[string]string{
@ -93,10 +65,6 @@ var colorMap = map[string]string{
ansiForegroundDefault: "", ansiForegroundDefault: "",
} }
func (cw *tagColorWriter) flushBuffer() (int, error) {
return cw.flushTo(cw.w)
}
func (cw *tagColorWriter) resetBuffer() (int, error) { func (cw *tagColorWriter) resetBuffer() (int, error) {
return cw.flushTo(nil) return cw.flushTo(nil)
} }
@ -147,7 +115,6 @@ func (cw *tagColorWriter) Write(p []byte) (int, error) {
switch ch { switch ch {
case firstCsiChar: case firstCsiChar:
cw.paramStartBuf.WriteByte(ch) cw.paramStartBuf.WriteByte(ch)
break
case secondeCsiChar: case secondeCsiChar:
cw.paramStartBuf.WriteByte(ch) cw.paramStartBuf.WriteByte(ch)
cw.state = secondCsiCode cw.state = secondCsiCode

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

@ -15,9 +15,8 @@ type MultiFormatter struct {
} }
type formatter struct { type formatter struct {
fmt formatters.FormatterFunc fmt formatters.FormatterFunc
out io.Writer out io.Writer
close bool
} }
type repeater []formatters.Formatter type repeater []formatters.Formatter

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

@ -11,10 +11,10 @@ import (
) )
// some snippet formatting regexps // some snippet formatting regexps
var snippetExprCleanup = regexp.MustCompile("([\\/\\[\\]\\(\\)\\\\^\\$\\.\\|\\?\\*\\+\\'])") var snippetExprCleanup = regexp.MustCompile(`([\/\[\]\(\)\\^\$\.\|\?\*\+\'])`)
var snippetExprQuoted = regexp.MustCompile("(\\W|^)\"(?:[^\"]*)\"(\\W|$)") var snippetExprQuoted = regexp.MustCompile(`(\W|^)"(?:[^"]*)"(\W|$)`)
var snippetMethodName = regexp.MustCompile("[^a-zA-Z\\_\\ ]") var snippetMethodName = regexp.MustCompile(`[^a-zA-Z\_\ ]`)
var snippetNumbers = regexp.MustCompile("(\\d+)") var snippetNumbers = regexp.MustCompile(`(\d+)`)
var snippetHelperFuncs = template.FuncMap{ var snippetHelperFuncs = template.FuncMap{
"backticked": func(s string) string { "backticked": func(s string) string {

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

@ -16,13 +16,15 @@ import (
messages "github.com/cucumber/messages/go/v21" messages "github.com/cucumber/messages/go/v21"
) )
type ctxKey string
func TestShouldSupportContext(t *testing.T) { func TestShouldSupportContext(t *testing.T) {
ctx := context.WithValue(context.Background(), "original", 123) ctx := context.WithValue(context.Background(), ctxKey("original"), 123)
fn := func(ctx context.Context, a int64, b int32, c int16, d int8) context.Context { fn := func(ctx context.Context, a int64, b int32, c int16, d int8) context.Context {
assert.Equal(t, 123, ctx.Value("original")) assert.Equal(t, 123, ctx.Value(ctxKey("original")))
return context.WithValue(ctx, "updated", 321) return context.WithValue(ctx, ctxKey("updated"), 321)
} }
def := &models.StepDefinition{ def := &models.StepDefinition{
@ -35,17 +37,18 @@ func TestShouldSupportContext(t *testing.T) {
def.Args = []interface{}{"1", "1", "1", "1"} def.Args = []interface{}{"1", "1", "1", "1"}
ctx, err := def.Run(ctx) ctx, err := def.Run(ctx)
assert.Nil(t, err) assert.Nil(t, err)
assert.Equal(t, 123, ctx.Value("original")) assert.Equal(t, 123, ctx.Value(ctxKey("original")))
assert.Equal(t, 321, ctx.Value("updated")) assert.Equal(t, 321, ctx.Value(ctxKey("updated")))
} }
func TestShouldSupportContextAndError(t *testing.T) { func TestShouldSupportContextAndError(t *testing.T) {
ctx := context.WithValue(context.Background(), "original", 123)
ctx := context.WithValue(context.Background(), ctxKey("original"), 123)
fn := func(ctx context.Context, a int64, b int32, c int16, d int8) (context.Context, error) { fn := func(ctx context.Context, a int64, b int32, c int16, d int8) (context.Context, error) {
assert.Equal(t, 123, ctx.Value("original")) assert.Equal(t, 123, ctx.Value(ctxKey("original")))
return context.WithValue(ctx, "updated", 321), nil return context.WithValue(ctx, ctxKey("updated"), 321), nil
} }
def := &models.StepDefinition{ def := &models.StepDefinition{
@ -58,8 +61,8 @@ func TestShouldSupportContextAndError(t *testing.T) {
def.Args = []interface{}{"1", "1", "1", "1"} def.Args = []interface{}{"1", "1", "1", "1"}
ctx, err := def.Run(ctx) ctx, err := def.Run(ctx)
assert.Nil(t, err) assert.Nil(t, err)
assert.Equal(t, 123, ctx.Value("original")) assert.Equal(t, 123, ctx.Value(ctxKey("original")))
assert.Equal(t, 321, ctx.Value("updated")) assert.Equal(t, 321, ctx.Value(ctxKey("updated")))
} }
func TestShouldSupportEmptyHandlerReturn(t *testing.T) { func TestShouldSupportEmptyHandlerReturn(t *testing.T) {
@ -374,7 +377,7 @@ func TestStepDefinition_Run_StringConversionToFunctionType(t *testing.T) {
// } // }
type testStruct struct { type testStruct struct {
a string _ string
} }
func TestShouldSupportDocStringToStringConversion(t *testing.T) { func TestShouldSupportDocStringToStringConversion(t *testing.T) {

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

@ -303,7 +303,7 @@ func (s *Storage) mustFirst(table, index string, args ...interface{}) interface{
if err != nil { if err != nil {
panic(err) panic(err)
} else if v == nil { } else if v == nil {
err = fmt.Errorf("Couldn't find index: %q in table: %q with args: %+v", index, table, args) err = fmt.Errorf("couldn't find index: %q in table: %q with args: %+v", index, table, args)
panic(err) panic(err)
} }