1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

test: imply random test order by --seed option

This commit is contained in:
Nobuyoshi Nakada 2021-06-24 18:49:49 +09:00
parent 627aafac86
commit e1c3cb9357
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6

View file

@ -62,13 +62,16 @@ module Test
non_options(args, options)
@run_options = orig_args
order = options[:test_order]
if seed = options[:seed]
order ||= :random
srand(seed)
else
seed = options[:seed] = srand % 100_000
srand(seed)
orig_args.unshift "--seed=#{seed}"
end
MiniTest::Unit::TestCase.test_order = order if order
@help = "\n" + orig_args.map { |s|
" " + (s =~ /[\s|&<>$()]/ ? s.inspect : s)
@ -100,7 +103,7 @@ module Test
end
opts.on '--test-order=random|alpha|sorted|nosort', [:random, :alpha, :sorted, :nosort] do |a|
MiniTest::Unit::TestCase.test_order = a
options[:test_order] = a
end
end