Skip to content

Commit

Permalink
--randomize now auto-generates seeds; match behavior of minitest's --…
Browse files Browse the repository at this point in the history
…seed
  • Loading branch information
quix committed May 21, 2011
1 parent 2834fd5 commit 2c7520f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
10 changes: 5 additions & 5 deletions doc/command_line_usage.rdoc
Expand Up @@ -65,11 +65,11 @@ Options are:
[<tt>--rakelibdir</tt> _rakelibdir_ (-R)]
Auto-import any .rake files in RAKELIBDIR. (default is 'rakelib')

[<tt>--randomize</tt>[=_seed_]]
Randomize the order of sibling prerequisites for each task. When
_seed_ is given, <tt>srand(seed.hash)</tt> will be called so that
the same permutations will be produced for subsequent runs with
the same _seed_.
[<tt>--randomize</tt> [_seed_]]
Randomize the order of sibling prerequisites for each task. Runs
with the same _seed_ will produce the same sibling permutations.
If no _seed_ is given then one will be generated. _seed_ is
reported when Rake exits.

[<tt>--require</tt> _name_ (-r)]
Require _name_ before executing the Rakefile.
Expand Down
10 changes: 5 additions & 5 deletions doc/parallel.rdoc
Expand Up @@ -71,7 +71,7 @@ The problem of underspecified dependencies plagues Makefiles as well

Suppose +-j+ produces errors from insufficient dependencies in your
Rakefile. Do you want to bother fixing them? If you are satisfied with
your build time, then there is really no reason to use +-j+.
your build time then there is really no reason to use +-j+.

If on the other hand your build takes twenty minutes to complete, you
may be interested in getting the full dependency graph correct in
Expand All @@ -83,10 +83,10 @@ saying what you mean:

% rake --randomize[=SEED]

This will randomize the order of sibling prerequisites for each task.
When SEED is given, <tt>srand(SEED.hash)</tt> will be called so that
the same permutations will be produced for subsequent runs with the
same SEED.
where the optional SEED is an integer. This will randomize the order
of sibling prerequisites for each task. Runs with the same SEED will
produce the same sibling permutations. If no SEED is given then one
will be generated. SEED is reported when Rake exits.

Though this option may cause an error due to underspecified
dependencies, with SEED at least it will be an error which is exactly
Expand Down
9 changes: 6 additions & 3 deletions lib/rake/application.rb
Expand Up @@ -351,11 +351,14 @@ def standard_rake_options
"Auto-import any .rake files in RAKELIBDIR. (default is 'rakelib')",
lambda { |value| options.rakelib = value.split(':') }
],
['--randomize[=SEED]', "Randomize the order of sibling prerequisites.",
['--randomize[=SEED]', Integer, "Randomize the order of sibling prerequisites.",
lambda { |value|
options.randomize = true
MultiTask.class_eval { remove_method(:invoke_prerequisites) }
srand(value.hash) if value
options.randomize = value || (srand ; srand % 10_000)
srand options.randomize
at_exit do
$stderr.puts "Run options: --randomize=#{options.randomize}"
end
}
],
['--require', '-r MODULE', "Require MODULE before executing rakefile.",
Expand Down

0 comments on commit 2c7520f

Please sign in to comment.