closes #60 allows custom formatters to run concurrently

Этот коммит содержится в:
gedi 2017-01-16 13:52:58 +02:00
родитель 380fc85cb9
коммит 5a471a7e2f

18
run.go
Просмотреть файл

@ -13,7 +13,7 @@ type initializer func(*Suite)
type runner struct {
stopOnFailure bool
features []*feature
fmt Formatter // needs to support concurrency
fmt Formatter
initializer initializer
}
@ -97,8 +97,8 @@ func RunWithOptions(suite string, contextInitializer func(suite *Suite), opt Opt
}
}
if opt.Concurrency > 1 && opt.Format != "progress" {
fatal(fmt.Errorf("when concurrency level is higher than 1, only progress format is supported"))
if opt.Concurrency > 1 && !supportsConcurrency(opt.Format) {
fatal(fmt.Errorf("format \"%s\" does not support concurrent execution", opt.Format))
}
formatter, err := findFmt(opt.Format)
fatal(err)
@ -148,3 +148,15 @@ func Run(suite string, contextInitializer func(suite *Suite)) int {
return RunWithOptions(suite, contextInitializer, opt)
}
func supportsConcurrency(format string) bool {
switch format {
case "events":
return false
case "junit":
return false
case "pretty":
return false
}
return true // all custom formatters are treated as supporting concurrency
}