Merge pull request #278 from cucumber/concurrent-runs-only
Updated so that we run all tests concurrent now
Этот коммит содержится в:
коммит
eb36b99512
3 изменённых файлов: 31 добавлений и 55 удалений
|
@ -82,7 +82,8 @@ func FeatureContext(s *godog.Suite) {
|
||||||
|
|
||||||
`
|
`
|
||||||
|
|
||||||
require.True(t, r.run())
|
failed := r.concurrent(1, func() Formatter { return progressFunc("progress", w) })
|
||||||
|
require.True(t, failed)
|
||||||
|
|
||||||
actual := buf.String()
|
actual := buf.String()
|
||||||
assert.Equal(t, expected, actual)
|
assert.Equal(t, expected, actual)
|
||||||
|
@ -107,10 +108,11 @@ func TestProgressFormatterWhenStepPanics(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
require.True(t, r.run())
|
failed := r.concurrent(1, func() Formatter { return progressFunc("progress", w) })
|
||||||
|
require.True(t, failed)
|
||||||
|
|
||||||
actual := buf.String()
|
actual := buf.String()
|
||||||
assert.Contains(t, actual, "godog/fmt_progress_test.go:106")
|
assert.Contains(t, actual, "godog/fmt_progress_test.go:107")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestProgressFormatterWithPassingMultisteps(t *testing.T) {
|
func TestProgressFormatterWithPassingMultisteps(t *testing.T) {
|
||||||
|
@ -135,7 +137,8 @@ func TestProgressFormatterWithPassingMultisteps(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.False(t, r.run())
|
failed := r.concurrent(1, func() Formatter { return progressFunc("progress", w) })
|
||||||
|
require.False(t, failed)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestProgressFormatterWithFailingMultisteps(t *testing.T) {
|
func TestProgressFormatterWithFailingMultisteps(t *testing.T) {
|
||||||
|
@ -160,7 +163,8 @@ func TestProgressFormatterWithFailingMultisteps(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
require.True(t, r.run())
|
failed := r.concurrent(1, func() Formatter { return progressFunc("progress", w) })
|
||||||
|
require.True(t, failed)
|
||||||
|
|
||||||
expected := `.F 2
|
expected := `.F 2
|
||||||
|
|
||||||
|
@ -202,7 +206,8 @@ func TestProgressFormatterWithPanicInMultistep(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.True(t, r.run())
|
failed := r.concurrent(1, func() Formatter { return progressFunc("progress", w) })
|
||||||
|
require.True(t, failed)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestProgressFormatterMultistepTemplates(t *testing.T) {
|
func TestProgressFormatterMultistepTemplates(t *testing.T) {
|
||||||
|
@ -226,7 +231,8 @@ func TestProgressFormatterMultistepTemplates(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
require.False(t, r.run())
|
failed := r.concurrent(1, func() Formatter { return progressFunc("progress", w) })
|
||||||
|
require.False(t, failed)
|
||||||
|
|
||||||
expected := `.U 2
|
expected := `.U 2
|
||||||
|
|
||||||
|
@ -291,7 +297,8 @@ Feature: basic
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.False(t, r.run())
|
failed := r.concurrent(1, func() Formatter { return progressFunc("progress", w) })
|
||||||
|
require.False(t, failed)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestProgressFormatterWhenMultiStepHasStepWithArgument(t *testing.T) {
|
func TestProgressFormatterWhenMultiStepHasStepWithArgument(t *testing.T) {
|
||||||
|
@ -326,7 +333,8 @@ Feature: basic
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
require.True(t, r.run())
|
failed := r.concurrent(1, func() Formatter { return progressFunc("progress", w) })
|
||||||
|
require.True(t, failed)
|
||||||
|
|
||||||
expected := `.F 2
|
expected := `.F 2
|
||||||
|
|
||||||
|
|
45
run.go
45
run.go
|
@ -110,23 +110,6 @@ func (r *runner) concurrent(rate int, formatterFn func() Formatter) (failed bool
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *runner) run() bool {
|
|
||||||
suite := &Suite{
|
|
||||||
fmt: r.fmt,
|
|
||||||
randomSeed: r.randomSeed,
|
|
||||||
stopOnFailure: r.stopOnFailure,
|
|
||||||
strict: r.strict,
|
|
||||||
features: r.features,
|
|
||||||
}
|
|
||||||
r.initializer(suite)
|
|
||||||
|
|
||||||
r.fmt.TestRunStarted()
|
|
||||||
suite.run()
|
|
||||||
r.fmt.Summary()
|
|
||||||
|
|
||||||
return suite.failed
|
|
||||||
}
|
|
||||||
|
|
||||||
// RunWithOptions is same as Run function, except
|
// RunWithOptions is same as Run function, except
|
||||||
// it uses Options provided in order to run the
|
// it uses Options provided in order to run the
|
||||||
// test suite without parsing flags
|
// test suite without parsing flags
|
||||||
|
@ -169,10 +152,10 @@ func RunWithOptions(suite string, contextInitializer func(suite *Suite), opt Opt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if opt.Concurrency > 1 && !supportsConcurrency(opt.Format) {
|
if opt.Concurrency < 1 {
|
||||||
fmt.Fprintln(os.Stderr, fmt.Errorf("format \"%s\" does not support concurrent execution", opt.Format))
|
opt.Concurrency = 1
|
||||||
return exitOptionError
|
|
||||||
}
|
}
|
||||||
|
|
||||||
formatter := FindFmt(opt.Format)
|
formatter := FindFmt(opt.Format)
|
||||||
if nil == formatter {
|
if nil == formatter {
|
||||||
var names []string
|
var names []string
|
||||||
|
@ -214,12 +197,7 @@ func RunWithOptions(suite string, contextInitializer func(suite *Suite), opt Opt
|
||||||
_, filename, _, _ := runtime.Caller(1)
|
_, filename, _, _ := runtime.Caller(1)
|
||||||
os.Setenv("GODOG_TESTED_PACKAGE", runsFromPackage(filename))
|
os.Setenv("GODOG_TESTED_PACKAGE", runsFromPackage(filename))
|
||||||
|
|
||||||
var failed bool
|
failed := r.concurrent(opt.Concurrency, func() Formatter { return formatter(suite, output) })
|
||||||
if opt.Concurrency > 1 {
|
|
||||||
failed = r.concurrent(opt.Concurrency, func() Formatter { return formatter(suite, output) })
|
|
||||||
} else {
|
|
||||||
failed = r.run()
|
|
||||||
}
|
|
||||||
|
|
||||||
// @TODO: should prevent from having these
|
// @TODO: should prevent from having these
|
||||||
os.Setenv("GODOG_SEED", "")
|
os.Setenv("GODOG_SEED", "")
|
||||||
|
@ -275,18 +253,3 @@ func Run(suite string, contextInitializer func(suite *Suite)) int {
|
||||||
|
|
||||||
return RunWithOptions(suite, contextInitializer, opt)
|
return RunWithOptions(suite, contextInitializer, opt)
|
||||||
}
|
}
|
||||||
|
|
||||||
func supportsConcurrency(format string) bool {
|
|
||||||
switch format {
|
|
||||||
case "progress", "junit":
|
|
||||||
return true
|
|
||||||
case "events":
|
|
||||||
return true
|
|
||||||
case "cucumber":
|
|
||||||
return true
|
|
||||||
case "pretty":
|
|
||||||
return true
|
|
||||||
default:
|
|
||||||
return true // enables concurrent custom formatters to work
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
15
run_test.go
15
run_test.go
|
@ -75,10 +75,12 @@ func TestFailsOrPassesBasedOnStrictModeWhenHasPendingSteps(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.False(t, r.run())
|
failed := r.concurrent(1, func() Formatter { return progressFunc("progress", ioutil.Discard) })
|
||||||
|
require.False(t, failed)
|
||||||
|
|
||||||
r.strict = true
|
r.strict = true
|
||||||
assert.True(t, r.run())
|
failed = r.concurrent(1, func() Formatter { return progressFunc("progress", ioutil.Discard) })
|
||||||
|
require.True(t, failed)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFailsOrPassesBasedOnStrictModeWhenHasUndefinedSteps(t *testing.T) {
|
func TestFailsOrPassesBasedOnStrictModeWhenHasUndefinedSteps(t *testing.T) {
|
||||||
|
@ -98,10 +100,12 @@ func TestFailsOrPassesBasedOnStrictModeWhenHasUndefinedSteps(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.False(t, r.run())
|
failed := r.concurrent(1, func() Formatter { return progressFunc("progress", ioutil.Discard) })
|
||||||
|
require.False(t, failed)
|
||||||
|
|
||||||
r.strict = true
|
r.strict = true
|
||||||
assert.True(t, r.run())
|
failed = r.concurrent(1, func() Formatter { return progressFunc("progress", ioutil.Discard) })
|
||||||
|
require.True(t, failed)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestShouldFailOnError(t *testing.T) {
|
func TestShouldFailOnError(t *testing.T) {
|
||||||
|
@ -121,7 +125,8 @@ func TestShouldFailOnError(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.True(t, r.run())
|
failed := r.concurrent(1, func() Formatter { return progressFunc("progress", ioutil.Discard) })
|
||||||
|
require.True(t, failed)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFailsWithUnknownFormatterOptionError(t *testing.T) {
|
func TestFailsWithUnknownFormatterOptionError(t *testing.T) {
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче