specify the random order seed with --seed
This commit is contained in:
parent
f8db052281
commit
3fe66c66c5
@ -32,3 +32,4 @@ module Jasmine::Headless
|
|||||||
end
|
end
|
||||||
|
|
||||||
require 'jasmine/headless/errors'
|
require 'jasmine/headless/errors'
|
||||||
|
|
||||||
|
@ -62,6 +62,8 @@ module Jasmine::Headless
|
|||||||
def initialize(options = {})
|
def initialize(options = {})
|
||||||
@options = options
|
@options = options
|
||||||
|
|
||||||
|
srand(@options[:seed]) if @options[:seed]
|
||||||
|
|
||||||
@required_files = UniqueAssetList.new
|
@required_files = UniqueAssetList.new
|
||||||
@potential_files_to_filter = []
|
@potential_files_to_filter = []
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ module Jasmine
|
|||||||
:do_list => false,
|
:do_list => false,
|
||||||
:full_run => true,
|
:full_run => true,
|
||||||
:enable_cache => true,
|
:enable_cache => true,
|
||||||
|
:seed => rand(10000),
|
||||||
:files => []
|
:files => []
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,6 +61,8 @@ module Jasmine
|
|||||||
@options[:full_run] = false
|
@options[:full_run] = false
|
||||||
when '--list', '-l'
|
when '--list', '-l'
|
||||||
@options[:do_list] = true
|
@options[:do_list] = true
|
||||||
|
when '--seed'
|
||||||
|
@options[:seed] = arg.to_i
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -82,7 +85,8 @@ module Jasmine
|
|||||||
[ '--report', GetoptLong::REQUIRED_ARGUMENT ],
|
[ '--report', GetoptLong::REQUIRED_ARGUMENT ],
|
||||||
[ '--jasmine-config', '-j', GetoptLong::REQUIRED_ARGUMENT ],
|
[ '--jasmine-config', '-j', GetoptLong::REQUIRED_ARGUMENT ],
|
||||||
[ '--no-full-run', GetoptLong::NO_ARGUMENT ],
|
[ '--no-full-run', GetoptLong::NO_ARGUMENT ],
|
||||||
[ '--list', '-l', GetoptLong::NO_ARGUMENT ]
|
[ '--list', '-l', GetoptLong::NO_ARGUMENT ],
|
||||||
|
[ '--seed', GetoptLong::REQUIRED_ARGUMENT ]
|
||||||
)
|
)
|
||||||
|
|
||||||
command_line_args.each { |*args| process_option(*args) }
|
command_line_args.each { |*args| process_option(*args) }
|
||||||
|
@ -73,7 +73,8 @@ module Jasmine
|
|||||||
|
|
||||||
files_list = Jasmine::Headless::FilesList.new(
|
files_list = Jasmine::Headless::FilesList.new(
|
||||||
:config => jasmine_config,
|
:config => jasmine_config,
|
||||||
:only => @options[:files]
|
:only => @options[:files],
|
||||||
|
:seed => @options[:seed]
|
||||||
)
|
)
|
||||||
|
|
||||||
@_targets = template_writer.write!(files_list)
|
@_targets = template_writer.write!(files_list)
|
||||||
@ -81,6 +82,9 @@ module Jasmine
|
|||||||
run_targets.pop if (!@options[:full_run] && files_list.filtered?) || files_list.has_spec_outside_scope?
|
run_targets.pop if (!@options[:full_run] && files_list.filtered?) || files_list.has_spec_outside_scope?
|
||||||
|
|
||||||
system jasmine_command(run_targets)
|
system jasmine_command(run_targets)
|
||||||
|
|
||||||
|
puts "\nTest ordering seed: --seed #{@options[:seed]}"
|
||||||
|
|
||||||
@_status = $?.exitstatus
|
@_status = $?.exitstatus
|
||||||
ensure
|
ensure
|
||||||
if @_targets && !runner_filename && (@options[:remove_html_file] || (@_status == 0))
|
if @_targets && !runner_filename && (@options[:remove_html_file] || (@_status == 0))
|
||||||
|
13
spec/integration/randomization_spec.rb
Normal file
13
spec/integration/randomization_spec.rb
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe 'sprockets' do
|
||||||
|
let(:seed) { 100 }
|
||||||
|
|
||||||
|
it 'should randomize the run order' do
|
||||||
|
output = %x{bin/jasmine-headless-webkit -j spec/jasmine/success/success.yml --seed #{seed}}
|
||||||
|
$?.exitstatus.should == 0
|
||||||
|
|
||||||
|
output.should include("--seed #{seed}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -177,13 +177,13 @@ describe Jasmine::Headless::FilesList do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '#add_files' do
|
describe '#add_files' do
|
||||||
|
let(:files_list) { described_class.new(:seed => 100) }
|
||||||
|
|
||||||
no_default_files!
|
no_default_files!
|
||||||
|
|
||||||
let(:dir) { 'tmp' }
|
let(:dir) { 'tmp' }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
srand(100)
|
|
||||||
|
|
||||||
FileUtils.mkdir_p dir
|
FileUtils.mkdir_p dir
|
||||||
|
|
||||||
10.times do |index|
|
10.times do |index|
|
||||||
|
@ -92,6 +92,24 @@ describe Jasmine::Headless::Options do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'specify no seed' do
|
||||||
|
it 'should have a seed' do
|
||||||
|
options[:seed].should_not be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'specify random order seed' do
|
||||||
|
let(:seed) { 12345 }
|
||||||
|
|
||||||
|
before do
|
||||||
|
ARGV.replace([ "--seed", seed ])
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should specify the seed' do
|
||||||
|
options[:seed].should == seed
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
ARGV.replace(@argv)
|
ARGV.replace(@argv)
|
||||||
end
|
end
|
||||||
|
2
spec/lib/jasmine/headless_spec.rb
Normal file
2
spec/lib/jasmine/headless_spec.rb
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user