Skip to content
Browse files

print random seed and allow forcing it to a particular value

  • Loading branch information...
1 parent 8c7936b commit 1d03ffcaf663187d2fe8202ce52959d1ad5253c4 Dave Copeland committed Feb 27, 2012
Showing with 10 additions and 0 deletions.
  1. +10 −0 lib/clean_test/any.rb
View
10 lib/clean_test/any.rb
@@ -46,6 +46,16 @@ module Test #:nodoc:
# }
# }
module Any
+ def self.included(k)
+ seed = if ENV['RANDOM_SEED']
+ ENV['RANDOM_SEED'].to_i
+ else
+ srand() # generate random seed
+ seed = srand() # save it (but we've now generated another one)
+ end
+ srand(seed) # set it explicitly
+ puts "Random seed was #{seed}; re-use it via environment variable RANDOM_SEED"
+ end
MAX_RAND = 50000 #:nodoc:
# Public: Get any number; one that doesn't matter

0 comments on commit 1d03ffc

Please sign in to comment.
Something went wrong with that request. Please try again.