Этот коммит содержится в:
gedi 2018-11-26 09:48:18 +02:00
родитель 65e5acf2eb
коммит cb8e8cae52
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 56604CDCCC201556
2 изменённых файлов: 10 добавлений и 5 удалений

Просмотреть файл

@ -196,14 +196,13 @@ type randomSeed struct {
// Choose randomly assigns a convenient pseudo-random seed value.
// The resulting seed will be between `1-99999` for later ease of specification.
func (rs *randomSeed) choose() {
r := rand.New(rand.NewSource(time.Now().UTC().UnixNano()))
*rs.ref = r.Int63n(99998) + 1
func makeRandomSeed() int64 {
return rand.New(rand.NewSource(time.Now().UTC().UnixNano())).Int63n(99998) + 1
}
func (rs *randomSeed) Set(s string) error {
if s == "true" {
rs.choose()
*rs.ref = makeRandomSeed()
return nil
}

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

@ -145,11 +145,17 @@ func RunWithOptions(suite string, contextInitializer func(suite *Suite), opt Opt
return exitOptionError
}
// user may have specified -1 option to create random seed
randomize := opt.Randomize
if randomize == -1 {
randomize = makeRandomSeed()
}
r := runner{
fmt: formatter(suite, output),
initializer: contextInitializer,
features: features,
randomSeed: opt.Randomize,
randomSeed: randomize,
stopOnFailure: opt.StopOnFailure,
strict: opt.Strict,
}