From 4a0e7cdceaf88f0e594286d3acb2329162442462 Mon Sep 17 00:00:00 2001 From: "Florian R. Hanke" Date: Mon, 20 Jan 2014 17:30:41 +0100 Subject: [PATCH 1/3] Add option to shuffle test files. This adds a -u/--shuffle option (default is "do not shuffle", as it is currently). --- bin/bacon | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/bacon b/bin/bacon index bff060a..1f0fb6a 100755 --- a/bin/bacon +++ b/bin/bacon @@ -6,6 +6,7 @@ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '../lib/') module Bacon; end automatic = false +shuffling = :to_a output = 'SpecDoxOutput' options = OptionParser.new("", 24, ' ') { |opts| @@ -65,6 +66,10 @@ options = OptionParser.new("", 24, ' ') { |opts| $LOAD_PATH.unshift "lib" if File.directory? "lib" automatic = true } + + opts.on("-u", "--shuffle", "shuffle test file order") { + shuffling = :shuffle + } opts.on('-n', '--name NAME', String, "runs tests matching regexp NAME") { |n| @@ -112,7 +117,7 @@ require 'bacon' Bacon.extend Bacon.const_get(output) rescue abort "No such formatter: #{output}" Bacon.summary_on_exit -files.each { |file| +files.send(shuffling).each { |file| load file } From 069f2b3789981b929724d1085296732012159e5b Mon Sep 17 00:00:00 2001 From: "Florian R. Hanke" Date: Wed, 9 Jul 2014 11:01:42 +0200 Subject: [PATCH 2/3] Add optional seed parameter to shuffling option. --- bin/bacon | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/bacon b/bin/bacon index 1f0fb6a..90b27ed 100755 --- a/bin/bacon +++ b/bin/bacon @@ -6,7 +6,7 @@ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '../lib/') module Bacon; end automatic = false -shuffling = :to_a +shuffling = [:to_a] output = 'SpecDoxOutput' options = OptionParser.new("", 24, ' ') { |opts| @@ -67,8 +67,8 @@ options = OptionParser.new("", 24, ' ') { |opts| automatic = true } - opts.on("-u", "--shuffle", "shuffle test file order") { - shuffling = :shuffle + opts.on("-u", "--shuffle [SEED]", Integer, "shuffle test file order using optional SEED") { |n| + shuffling = [:shuffle, n ? { random: Random.new(n) } : {}] } opts.on('-n', '--name NAME', String, @@ -117,7 +117,7 @@ require 'bacon' Bacon.extend Bacon.const_get(output) rescue abort "No such formatter: #{output}" Bacon.summary_on_exit -files.send(shuffling).each { |file| +files.send(*shuffling).each { |file| load file } From d1236430db696acf5e44e84842e10bd339d67d4b Mon Sep 17 00:00:00 2001 From: "Florian R. Hanke" Date: Wed, 9 Jul 2014 16:59:39 +0200 Subject: [PATCH 3/3] Rewrite to always use randomized test file order (use -u SEED, --shuffle SEED to use specific SEED). --- bin/bacon | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/bacon b/bin/bacon index 90b27ed..eb5a8de 100755 --- a/bin/bacon +++ b/bin/bacon @@ -6,7 +6,7 @@ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '../lib/') module Bacon; end automatic = false -shuffling = [:to_a] +random = Random.new output = 'SpecDoxOutput' options = OptionParser.new("", 24, ' ') { |opts| @@ -67,8 +67,8 @@ options = OptionParser.new("", 24, ' ') { |opts| automatic = true } - opts.on("-u", "--shuffle [SEED]", Integer, "shuffle test file order using optional SEED") { |n| - shuffling = [:shuffle, n ? { random: Random.new(n) } : {}] + opts.on("-u", "--shuffle SEED", Integer, "use SEED for randomizing test file order") { |seed| + random = Random.new seed } opts.on('-n', '--name NAME', String, @@ -117,7 +117,7 @@ require 'bacon' Bacon.extend Bacon.const_get(output) rescue abort "No such formatter: #{output}" Bacon.summary_on_exit -files.send(*shuffling).each { |file| +files.shuffle(random: random).each { |file| load file }