use Options in FlagSet
Этот коммит содержится в:
родитель
bfb741f6c7
коммит
2e189ad0f9
5 изменённых файлов: 20 добавлений и 27 удалений
|
@ -62,11 +62,11 @@ func buildAndRun() (int, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var vers, defs, sof, noclr bool
|
var vers bool
|
||||||
var tags, format, output string
|
var output string
|
||||||
var concurrency int
|
|
||||||
|
|
||||||
flagSet := godog.FlagSet(colors.Colored(os.Stdout), &format, &tags, &defs, &sof, &noclr, &concurrency)
|
opt := godog.Options{Output: colors.Colored(os.Stdout)}
|
||||||
|
flagSet := godog.FlagSet(&opt)
|
||||||
flagSet.BoolVar(&vers, "version", false, "Show current version.")
|
flagSet.BoolVar(&vers, "version", false, "Show current version.")
|
||||||
flagSet.StringVar(&output, "o", "", "Build and output test runner executable to given target path.")
|
flagSet.StringVar(&output, "o", "", "Build and output test runner executable to given target path.")
|
||||||
flagSet.StringVar(&output, "output", "", "Build and output test runner executable to given target path.")
|
flagSet.StringVar(&output, "output", "", "Build and output test runner executable to given target path.")
|
||||||
|
|
|
@ -20,6 +20,6 @@ Feature: get version
|
||||||
And the response should match json:
|
And the response should match json:
|
||||||
"""
|
"""
|
||||||
{
|
{
|
||||||
"version": "v0.6.0"
|
"version": "v0.6.1"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
24
flags.go
24
flags.go
|
@ -27,7 +27,7 @@ var descTagsOption = "Filter scenarios by tags. Expression can be:\n" +
|
||||||
s(4) + "- " + colors.Yellow(`"@wip,@undone"`) + ": run wip or undone scenarios"
|
s(4) + "- " + colors.Yellow(`"@wip,@undone"`) + ": run wip or undone scenarios"
|
||||||
|
|
||||||
// FlagSet allows to manage flags by external suite runner
|
// FlagSet allows to manage flags by external suite runner
|
||||||
func FlagSet(w io.Writer, format, tags *string, defs, sof, noclr *bool, cr *int) *flag.FlagSet {
|
func FlagSet(opt *Options) *flag.FlagSet {
|
||||||
descFormatOption := "How to format tests output. Available formats:\n"
|
descFormatOption := "How to format tests output. Available formats:\n"
|
||||||
// @TODO: sort by name
|
// @TODO: sort by name
|
||||||
for name, desc := range AvailableFormatters() {
|
for name, desc := range AvailableFormatters() {
|
||||||
|
@ -36,17 +36,17 @@ func FlagSet(w io.Writer, format, tags *string, defs, sof, noclr *bool, cr *int)
|
||||||
descFormatOption = strings.TrimSpace(descFormatOption)
|
descFormatOption = strings.TrimSpace(descFormatOption)
|
||||||
|
|
||||||
set := flag.NewFlagSet("godog", flag.ExitOnError)
|
set := flag.NewFlagSet("godog", flag.ExitOnError)
|
||||||
set.StringVar(format, "format", "pretty", descFormatOption)
|
set.StringVar(&opt.Format, "format", "pretty", descFormatOption)
|
||||||
set.StringVar(format, "f", "pretty", descFormatOption)
|
set.StringVar(&opt.Format, "f", "pretty", descFormatOption)
|
||||||
set.StringVar(tags, "tags", "", descTagsOption)
|
set.StringVar(&opt.Tags, "tags", "", descTagsOption)
|
||||||
set.StringVar(tags, "t", "", descTagsOption)
|
set.StringVar(&opt.Tags, "t", "", descTagsOption)
|
||||||
set.IntVar(cr, "concurrency", 1, descConcurrencyOption)
|
set.IntVar(&opt.Concurrency, "concurrency", 1, descConcurrencyOption)
|
||||||
set.IntVar(cr, "c", 1, descConcurrencyOption)
|
set.IntVar(&opt.Concurrency, "c", 1, descConcurrencyOption)
|
||||||
set.BoolVar(defs, "definitions", false, "Print all available step definitions.")
|
set.BoolVar(&opt.ShowStepDefinitions, "definitions", false, "Print all available step definitions.")
|
||||||
set.BoolVar(defs, "d", false, "Print all available step definitions.")
|
set.BoolVar(&opt.ShowStepDefinitions, "d", false, "Print all available step definitions.")
|
||||||
set.BoolVar(sof, "stop-on-failure", false, "Stop processing on first failed scenario.")
|
set.BoolVar(&opt.StopOnFailure, "stop-on-failure", false, "Stop processing on first failed scenario.")
|
||||||
set.BoolVar(noclr, "no-colors", false, "Disable ansi colors.")
|
set.BoolVar(&opt.NoColors, "no-colors", false, "Disable ansi colors.")
|
||||||
set.Usage = usage(set, w)
|
set.Usage = usage(set, opt.Output)
|
||||||
return set
|
return set
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
godog.go
2
godog.go
|
@ -42,4 +42,4 @@ Godog was inspired by Behat and Cucumber the above description is taken from it'
|
||||||
package godog
|
package godog
|
||||||
|
|
||||||
// Version of package - based on Semantic Versioning 2.0.0 http://semver.org/
|
// Version of package - based on Semantic Versioning 2.0.0 http://semver.org/
|
||||||
const Version = "v0.6.0"
|
const Version = "v0.6.1"
|
||||||
|
|
11
run.go
11
run.go
|
@ -139,15 +139,8 @@ func RunWithOptions(suite string, contextInitializer func(suite *Suite), opt Opt
|
||||||
// the step definitions and event handlers.
|
// the step definitions and event handlers.
|
||||||
func Run(suite string, contextInitializer func(suite *Suite)) int {
|
func Run(suite string, contextInitializer func(suite *Suite)) int {
|
||||||
var opt Options
|
var opt Options
|
||||||
flagSet := FlagSet(
|
opt.Output = colors.Colored(os.Stdout)
|
||||||
colors.Colored(os.Stdout),
|
flagSet := FlagSet(&opt)
|
||||||
&opt.Format,
|
|
||||||
&opt.Tags,
|
|
||||||
&opt.ShowStepDefinitions,
|
|
||||||
&opt.StopOnFailure,
|
|
||||||
&opt.NoColors,
|
|
||||||
&opt.Concurrency,
|
|
||||||
)
|
|
||||||
err := flagSet.Parse(os.Args[1:])
|
err := flagSet.Parse(os.Args[1:])
|
||||||
fatal(err)
|
fatal(err)
|
||||||
|
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче