closes #146
Этот коммит содержится в:
родитель
65e5acf2eb
коммит
cb8e8cae52
2 изменённых файлов: 10 добавлений и 5 удалений
7
flags.go
7
flags.go
|
@ -196,14 +196,13 @@ type randomSeed struct {
|
||||||
|
|
||||||
// Choose randomly assigns a convenient pseudo-random seed value.
|
// Choose randomly assigns a convenient pseudo-random seed value.
|
||||||
// The resulting seed will be between `1-99999` for later ease of specification.
|
// The resulting seed will be between `1-99999` for later ease of specification.
|
||||||
func (rs *randomSeed) choose() {
|
func makeRandomSeed() int64 {
|
||||||
r := rand.New(rand.NewSource(time.Now().UTC().UnixNano()))
|
return rand.New(rand.NewSource(time.Now().UTC().UnixNano())).Int63n(99998) + 1
|
||||||
*rs.ref = r.Int63n(99998) + 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *randomSeed) Set(s string) error {
|
func (rs *randomSeed) Set(s string) error {
|
||||||
if s == "true" {
|
if s == "true" {
|
||||||
rs.choose()
|
*rs.ref = makeRandomSeed()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
8
run.go
8
run.go
|
@ -145,11 +145,17 @@ func RunWithOptions(suite string, contextInitializer func(suite *Suite), opt Opt
|
||||||
return exitOptionError
|
return exitOptionError
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// user may have specified -1 option to create random seed
|
||||||
|
randomize := opt.Randomize
|
||||||
|
if randomize == -1 {
|
||||||
|
randomize = makeRandomSeed()
|
||||||
|
}
|
||||||
|
|
||||||
r := runner{
|
r := runner{
|
||||||
fmt: formatter(suite, output),
|
fmt: formatter(suite, output),
|
||||||
initializer: contextInitializer,
|
initializer: contextInitializer,
|
||||||
features: features,
|
features: features,
|
||||||
randomSeed: opt.Randomize,
|
randomSeed: randomize,
|
||||||
stopOnFailure: opt.StopOnFailure,
|
stopOnFailure: opt.StopOnFailure,
|
||||||
strict: opt.Strict,
|
strict: opt.Strict,
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче