Skip to content

Commit

Permalink
Support for autotest with parallel option
Browse files Browse the repository at this point in the history
  • Loading branch information
snelson committed Mar 28, 2011
1 parent 8f74614 commit de074af
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/autotest/rspec2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@ def consolidate_failures(failed)
end

def make_test_cmd(files_to_test)
files_to_test.empty? ? '' :
if files_to_test.empty?
''
elsif options[:parallel] and files_to_test.size > 1
"#{prefix}parallel_spec #{normalize(files_to_test).keys.flatten.join(' ')}"
else
"#{prefix}#{ruby}#{suffix} -S #{SPEC_PROGRAM} --tty #{normalize(files_to_test).keys.flatten.map { |f| "'#{f}'"}.join(' ')}"
end
end

def normalize(files_to_test)
Expand Down
21 changes: 21 additions & 0 deletions spec/autotest/rspec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,27 @@
cmd.should match(' --tty ')
cmd.should_not match(' --autotest ')
end

context "when parallel option is set to true" do
before do
rspec_autotest.options[:parallel] = true
end

after do
rspec_autotest.options[:parallel] = false
end

it "makes the appropriate test command" do
actual_command = rspec_autotest.make_test_cmd(@files_to_test)
expected_command = /parallel_spec (.*)/

actual_command.should match(expected_command)

actual_command =~ expected_command
$1.should =~ /#{File.expand_path('file_one')}/
$1.should =~ /#{File.expand_path('file_two')}/
end
end
end

describe "mappings" do
Expand Down

0 comments on commit de074af

Please sign in to comment.