ruby-changes:60206
From: Koichi <ko1@a...>
Date: Thu, 27 Feb 2020 02:32:55 +0900 (JST)
Subject: [ruby-changes:60206] 116c632095 (master): don't ignore `--seed` option
https://git.ruby-lang.org/ruby.git/commit/?id=116c632095 From 116c6320956ce80efcb1db849a190ebd7f8c8ad3 Mon Sep 17 00:00:00 2001 From: Koichi Sasada <ko1@a...> Date: Thu, 27 Feb 2020 02:26:14 +0900 Subject: don't ignore `--seed` option `--seed N` option is just ignored so respect this option. [Feature #16655] Also making "Run options" display pretty. diff --git a/tool/lib/test/unit.rb b/tool/lib/test/unit.rb index 42d1d83..ad053cf 100644 --- a/tool/lib/test/unit.rb +++ b/tool/lib/test/unit.rb @@ -64,7 +64,18 @@ module Test https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit.rb#L64 args = @init_hook.call(args, options) if @init_hook non_options(args, options) @run_options = orig_args - @help = orig_args.map { |s| s =~ /[\s|&<>$()]/ ? s.inspect : s }.join " " + + if seed = options[:seed] + srand(seed) + else + seed = options[:seed] = srand % 100_000 + srand(seed) + orig_args << "--seed=#{seed}" + end + + @help = "\n" + orig_args.map { |s| + " " + (s =~ /[\s|&<>$()]/ ? s.inspect : s) + }.join("\n") @options = options end @@ -79,7 +90,7 @@ module Test https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit.rb#L90 end opts.on '-s', '--seed SEED', Integer, "Sets random seed" do |m| - options[:seed] = m + options[:seed] = m.to_i end opts.on '-v', '--verbose', "Verbose. Show progress processing files." do -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/