родитель
943635096a
коммит
4df893dd4a
4 изменённых файлов: 8 добавлений и 5 удалений
7
fmt.go
7
fmt.go
|
@ -53,9 +53,12 @@ type registeredFormatter struct {
|
||||||
|
|
||||||
var formatters []*registeredFormatter
|
var formatters []*registeredFormatter
|
||||||
|
|
||||||
func findFmt(format string) FormatterFunc {
|
// FindFmt searches available formatters registered
|
||||||
|
// and returns FormaterFunc matched by given
|
||||||
|
// format name or nil otherwise
|
||||||
|
func FindFmt(name string) FormatterFunc {
|
||||||
for _, el := range formatters {
|
for _, el := range formatters {
|
||||||
if el.name == format {
|
if el.name == name {
|
||||||
return el.fmt
|
return el.fmt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ func TestShouldFindFormatter(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for name, shouldFind := range cases {
|
for name, shouldFind := range cases {
|
||||||
actual := findFmt(name)
|
actual := FindFmt(name)
|
||||||
if actual == nil && shouldFind {
|
if actual == nil && shouldFind {
|
||||||
t.Fatalf("expected %s formatter should be available", name)
|
t.Fatalf("expected %s formatter should be available", name)
|
||||||
}
|
}
|
||||||
|
|
2
run.go
2
run.go
|
@ -125,7 +125,7 @@ func RunWithOptions(suite string, contextInitializer func(suite *Suite), opt Opt
|
||||||
fmt.Fprintln(os.Stderr, fmt.Errorf("format \"%s\" does not support concurrent execution", opt.Format))
|
fmt.Fprintln(os.Stderr, fmt.Errorf("format \"%s\" does not support concurrent execution", opt.Format))
|
||||||
return exitOptionError
|
return exitOptionError
|
||||||
}
|
}
|
||||||
formatter := findFmt(opt.Format)
|
formatter := FindFmt(opt.Format)
|
||||||
if nil == formatter {
|
if nil == formatter {
|
||||||
var names []string
|
var names []string
|
||||||
for name := range AvailableFormatters() {
|
for name := range AvailableFormatters() {
|
||||||
|
|
|
@ -115,7 +115,7 @@ func (s *suiteContext) ResetBeforeEachScenario(interface{}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *suiteContext) iRunFeatureSuiteWithFormatter(name string) error {
|
func (s *suiteContext) iRunFeatureSuiteWithFormatter(name string) error {
|
||||||
f := findFmt(name)
|
f := FindFmt(name)
|
||||||
if f == nil {
|
if f == nil {
|
||||||
return fmt.Errorf(`formatter "%s" is not available`, name)
|
return fmt.Errorf(`formatter "%s" is not available`, name)
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче