Skip to content

Commit

Permalink
simplify interface of CommandLine class, bevaes just like its ancestor
Browse files Browse the repository at this point in the history
  • Loading branch information
grosser committed Feb 4, 2012
1 parent 142eed4 commit 8ce3fc3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
11 changes: 10 additions & 1 deletion lib/parallel_split_test/command_line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
module ParallelSplitTest
class CommandLine < RSpec::Core::CommandLine
def run(err, out)
Parallel.in_processes(ParallelSplitTest.processes) do |process_number|
results = Parallel.in_processes(ParallelSplitTest.processes) do |process_number|
ENV['TEST_ENV_NUMBER'] = (process_number == 0 ? '' : (process_number + 1).to_s)
out = OutputRecorder.new(out)
setup_copied_from_rspec(err, out)
Expand All @@ -17,10 +17,19 @@ def run(err, out)

[run_group_of_tests, out.recorded]
end

reprint_result_lines(out, results.map(&:last))
results.map(&:first).max # combine exit status
end

private

def reprint_result_lines(out, printed_outputs)
out.puts
out.puts "Summary:"
out.puts printed_outputs.map{|o| o[/.*\d+ failure.*/] }.join("\n")
end

def run_group_of_tests
example_count = @world.example_count / ParallelSplitTest.processes

Expand Down
10 changes: 1 addition & 9 deletions lib/parallel_split_test/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ def self.run(args, err=$stderr, out=$stdout)
out.puts "Running examples in #{ParallelSplitTest.processes} processes"

report_execution_time(out) do
results = ParallelSplitTest::CommandLine.new(options).run(err, out)
reprint_result_lines(out, results.map(&:last))
results.map(&:first).max
ParallelSplitTest::CommandLine.new(options).run(err, out)
end
ensure
RSpec.reset
Expand All @@ -27,11 +25,5 @@ def self.report_execution_time(out)
out.puts "Took %.2f seconds with #{ParallelSplitTest.processes} processes" % runtime
result
end

def self.reprint_result_lines(out, printed_outputs)
out.puts
out.puts "Summary:"
out.puts printed_outputs.map{|o| o[/.*\d+ failure.*/] }.join("\n")
end
end
end

0 comments on commit 8ce3fc3

Please sign in to comment.