Permalink
Browse files

Fix duplicate tests dispatched by printer

A slow worker would call tests= after some tests had already been run.
  • Loading branch information...
1 parent bb4a2e4 commit 334cb9a1ad8b2dafc92c28e2c03c64131a3f6d22 @sandro committed Feb 22, 2012
Showing with 11 additions and 25 deletions.
  1. +7 −16 lib/specjour/loader.rb
  2. +4 −2 lib/specjour/printer.rb
  3. +0 −7 spec/specjour/printer_spec.rb
View
@@ -81,20 +81,14 @@ def file_collector(paths, &globber)
end
def load_app
- share_examples if spec_files.any?
- share_features if feature_files.any?
+ RSpec::Preloader.load spec_files if spec_files.any?
+ Cucumber::Preloader.load if feature_files.any?
+ register_tests_with_printer
end
- def share_examples
- RSpec::Preloader.load spec_files
- connection.send_message :tests=, filtered_examples
- ensure
- ::RSpec.reset
- end
-
- def share_features
- Cucumber::Preloader.load
- connection.send_message :tests=, feature_files
+ def register_tests_with_printer
+ tests = filtered_examples | feature_files
+ connection.send_message :tests=, tests
end
def filtered_examples
@@ -118,12 +112,9 @@ def kill_worker_processes
def connection
@connection ||= begin
at_exit { connection.disconnect }
- printer_connection
+ Connection.new URI.parse(printer_uri)
end
end
- def printer_connection
- Connection.new URI.parse(printer_uri)
- end
end
end
View
@@ -71,8 +71,10 @@ def done(client)
end
def tests=(client, tests)
- self.tests_to_run = run_order(tests_to_run | tests)
- self.example_size = tests_to_run.size
+ if tests_to_run.empty?
+ self.tests_to_run = run_order(tests)
+ self.example_size = tests_to_run.size
+ end
end
def rspec_summary=(client, summary)
@@ -21,17 +21,10 @@
subject.tests_to_run.should =~ ["one_spec.rb", "two_spec.rb"]
end
- it "accumulates both features and specs" do
- subject.send(:tests=, nil, ["one.feature", "two.feature"])
- subject.send(:tests=, nil, ["one_spec.rb", "two_spec.rb"])
- subject.tests_to_run.should =~ ["one.feature", "two.feature", "one_spec.rb", "two_spec.rb"]
- end
-
it "disregards duplicates" do
subject.send(:tests=, nil, ["one_spec.rb", "two_spec.rb"])
subject.send(:tests=, nil, ["one_spec.rb", "two_spec.rb"])
subject.tests_to_run.should =~ ["one_spec.rb", "two_spec.rb"]
- p subject.tests_to_run
end
it "doesn't increment example_size with duplicates" do

0 comments on commit 334cb9a

Please sign in to comment.