deep_test 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,11 @@
1
+ * 1.1.4 (March 11, 2008)
2
+
3
+ * Fixed 2 RSpec pending example bugs
4
+ * Fixed setting spec_opts with DeepTest bug
5
+ * Raise an error if before or after all is defined
6
+ * Added server_port to configuration options
7
+ * Wait for signal from server indicating it is ready on startup
8
+
1
9
  * 1.1.3 (March 10, 2008)
2
10
 
3
11
  * Added Support for RSpec
data/README CHANGED
@@ -14,15 +14,17 @@ In your Rakefile:
14
14
  DeepTest::TestTask.new "task_name" do |t|
15
15
  t.number_of_workers = 2 # optional, defaults to 2
16
16
  t.timeout_in_seconds = 30 # optional, defaults to 30
17
+ t.server_port = 6969 # optional, defaults to 6969
17
18
  t.pattern = "test/**/*_test.rb"
18
19
  end
19
20
 
20
- # Sample SpecTask using DeepTest
21
+ # sample SpecTask using DeepTest
21
22
 
22
23
  Spec::Rake::SpecTask.new(:deep_spec) do |t|
23
24
  t.spec_files = FileList['spec/**/*_spec.rb']
24
25
  t.deep_test :number_of_workers => 2, # optional, defaults to 2
25
26
  :timeout_in_seconds => 30, # optional, defaults to 30
27
+ :server_port => 6969 # optional, defaults to 6969
26
28
  end
27
29
 
28
30
 
@@ -54,11 +56,11 @@ loaded, so it is available to be instantiated.
54
56
 
55
57
  == Contributors
56
58
 
57
- +* anonymous z
58
- +* Alex Chaffee
59
- +* Dan[http://www.dcmanges.com/blog] Manges[http://www.dcmanges.com/blog]
60
- +* David Vollbracht[http://davidvollbracht.com/]
61
- +* Scott Taylor
59
+ * anonymous z
60
+ * Alex Chaffee
61
+ * Dan[http://www.dcmanges.com/blog] Manges[http://www.dcmanges.com/blog]
62
+ * David[http://davidvollbracht.com/] Vollbracht[http://davidvollbracht.com/]
63
+ * Scott Taylor
62
64
 
63
65
  == License
64
66
  Released under Ruby's[http://www.ruby-lang.org/en/LICENSE.txt] license[http://www.ruby-lang.org/en/LICENSE.txt]
data/Rakefile CHANGED
@@ -58,7 +58,7 @@ specification = Gem::Specification.new do |s|
58
58
  s.platform = Gem::Platform::RUBY
59
59
  s.name = "deep_test"
60
60
  s.summary = "DeepTest runs tests in multiple processes."
61
- s.version = "1.1.3"
61
+ s.version = "1.1.4"
62
62
  s.author = "anonymous z, Dan Manges, David Vollbracht"
63
63
  s.description = s.summary
64
64
  s.email = "daniel.manges@gmail.com"
@@ -22,6 +22,7 @@ module DeepTest
22
22
  Option.new(:number_of_workers, :to_i, 2),
23
23
  Option.new(:pattern, :to_s, nil),
24
24
  Option.new(:timeout_in_seconds, :to_i, 30),
25
+ Option.new(:server_port, :to_i, 6969),
25
26
  Option.new(:worker_listener, :to_s, "DeepTest::NullWorkerListener"),
26
27
  ]
27
28
  end
@@ -56,8 +56,19 @@ module DeepTest
56
56
  end
57
57
 
58
58
  def start_warlock_server
59
- @warlock.start("server") { DeepTest::Server.start }
60
- sleep 0.5 # TODO: change from sleep to something better... Process.wait?
59
+ server_ready = false
60
+ previous_trap = Signal.trap('USR2') {server_ready = true}
61
+
62
+ pid = Process.pid
63
+ @warlock.start("server") do
64
+ DeepTest::Server.start(@options) do
65
+ Process.kill('USR2', pid)
66
+ end
67
+ end
68
+
69
+ Thread.pass until server_ready
70
+ ensure
71
+ Signal.trap('USR2', previous_trap)
61
72
  end
62
73
 
63
74
  def stop_all_warlocks
@@ -1,6 +1,6 @@
1
1
  module DeepTest
2
2
  class RindaBlackboard
3
- def initialize(options, tuple_space = TupleSpaceFactory.tuple_space)
3
+ def initialize(options, tuple_space = TupleSpaceFactory.tuple_space(options))
4
4
  @options = options
5
5
  @tuple_space = tuple_space
6
6
  end
@@ -1,11 +1,10 @@
1
1
  module DeepTest
2
2
  class Server
3
- PORT = 6969 unless defined?(PORT)
4
-
5
- def self.start
3
+ def self.start(options)
6
4
  DRb.start_service
7
- Rinda::RingServer.new(Rinda::TupleSpace.new, PORT)
5
+ Rinda::RingServer.new(Rinda::TupleSpace.new, options.server_port)
8
6
  DeepTest.logger.info "Started DeepTest service at #{DRb.uri}"
7
+ yield if block_given?
9
8
  DRb.thread.join
10
9
  end
11
10
  end
@@ -1,6 +1,8 @@
1
1
  require 'spec/runner/example_group_runner'
2
+ require 'spec/example/example_group_methods'
2
3
  require 'spec/rake/spectask'
3
4
 
5
+ require File.dirname(__FILE__) + "/spec/extensions/example_group_methods"
4
6
  require File.dirname(__FILE__) + "/spec/extensions/spec_task"
5
7
  require File.dirname(__FILE__) + "/spec/extensions/options"
6
8
  require File.dirname(__FILE__) + "/spec/extensions/reporter"
@@ -0,0 +1,38 @@
1
+ module Spec
2
+ module Example
3
+ module ExampleGroupMethods
4
+ PREPEND_BEFORE = instance_method(:prepend_before) unless defined?(PREPEND_BEFORE)
5
+ APPEND_BEFORE = instance_method(:append_before) unless defined?(APPEND_BEFORE)
6
+ PREPEND_AFTER = instance_method(:prepend_after) unless defined?(PREPEND_AFTER)
7
+ APPEND_AFTER = instance_method(:append_after) unless defined?(APPEND_AFTER)
8
+
9
+ def prepend_before(*args, &block)
10
+ check_filter_args(args)
11
+ PREPEND_BEFORE.bind(self).call(*args, &block)
12
+ end
13
+
14
+ def append_before(*args, &block)
15
+ check_filter_args(args)
16
+ APPEND_BEFORE.bind(self).call(*args, &block)
17
+ end
18
+ alias_method :before, :append_before
19
+
20
+ def prepend_after(*args, &block)
21
+ check_filter_args(args)
22
+ PREPEND_AFTER.bind(self).call(*args, &block)
23
+ end
24
+
25
+ def append_after(*args, &block)
26
+ check_filter_args(args)
27
+ APPEND_AFTER.bind(self).call(*args, &block)
28
+ end
29
+ alias_method :after, :append_after
30
+
31
+ def check_filter_args(args)
32
+ raise BeforeAfterAllNotSupportedByDeepTestError if args.first == :all
33
+ end
34
+
35
+ class BeforeAfterAllNotSupportedByDeepTestError < StandardError; end
36
+ end
37
+ end
38
+ end
@@ -2,6 +2,18 @@ require 'spec/runner/reporter'
2
2
  module Spec
3
3
  module Runner
4
4
  class Reporter
5
+ def example_finished(example, error=nil)
6
+ @examples << example
7
+
8
+ if error.nil?
9
+ example_passed(example)
10
+ elsif Spec::Example::ExamplePendingError === error
11
+ example_pending(example.class, example, error.message)
12
+ else
13
+ example_failed(example, error)
14
+ end
15
+ end
16
+
5
17
  def failure(example, error)
6
18
  backtrace_tweaker.tweak_backtrace(error)
7
19
  example_name = "#{example.class.description} #{example.description}"
@@ -5,8 +5,15 @@ module Spec
5
5
  deep_test_options = DeepTest::Options.new(options)
6
6
  deep_test_path = File.expand_path(File.dirname(__FILE__) +
7
7
  "/../../../deep_test")
8
- spec_opts << "--require #{deep_test_path}"
9
- spec_opts << "--runner 'DeepTest::Spec::Runner:#{deep_test_options.to_command_line}'"
8
+ @deep_test_spec_opts = [
9
+ "--require #{deep_test_path}",
10
+ "--runner 'DeepTest::Spec::Runner:#{deep_test_options.to_command_line}'"
11
+ ]
12
+ spec_opts.concat @deep_test_spec_opts
13
+ end
14
+
15
+ def spec_opts=(options)
16
+ @spec_opts = (@deep_test_spec_opts || []) + options
10
17
  end
11
18
  end
12
19
  end
@@ -36,7 +36,7 @@ module DeepTest
36
36
  print result.output if result.output
37
37
  example = examples_by_location.delete("#{result.file}:#{result.line}")
38
38
  @options.reporter.example_finished(example, result.error)
39
- success &= result.error.nil?
39
+ success &= result.success?
40
40
  end
41
41
 
42
42
  success
@@ -18,6 +18,10 @@ module DeepTest
18
18
  DeadlockDetector.due_to_deadlock?(@error)
19
19
  end
20
20
 
21
+ def success?
22
+ error.nil? || ::Spec::Example::ExamplePendingError === error
23
+ end
24
+
21
25
  def deadlock_result
22
26
  WorkResult.new(file, line, example_description, nil, '-deadlock-')
23
27
  end
@@ -31,6 +31,14 @@ module DeepTest
31
31
  @options.pattern = Dir.pwd + "/" + pattern
32
32
  end
33
33
 
34
+ def server_port=(port)
35
+ @options.server_port = port
36
+ end
37
+
38
+ def server_port
39
+ @options.server_port
40
+ end
41
+
34
42
  def timeout_in_seconds=(seconds)
35
43
  @options.timeout_in_seconds = seconds
36
44
  end
@@ -1,10 +1,10 @@
1
1
  module DeepTest
2
2
  class TupleSpaceFactory
3
- def self.tuple_space
3
+ def self.tuple_space(options)
4
4
  require "rinda/ring"
5
5
  require "socket"
6
6
  DRb.start_service
7
- ts = Rinda::RingFinger.new([Socket.gethostname],DeepTest::Server::PORT).lookup_ring_any
7
+ ts = Rinda::RingFinger.new([Socket.gethostname],options.server_port).lookup_ring_any
8
8
  DeepTest.logger.debug "Connected to DeepTest server at #{ts.__drburi}"
9
9
  Rinda::TupleSpaceProxy.new ts
10
10
  end
@@ -20,4 +20,14 @@ unit_tests do
20
20
  assert_equal "A", t.instance_variable_get(:@options).worker_listener
21
21
  assert_equal "A", t.worker_listener
22
22
  end
23
+
24
+ test "should support server_port" do
25
+ t = DeepTest::TestTask.new :deep_test do |t|
26
+ t.stubs(:desc)
27
+ t.stubs(:task)
28
+ t.server_port = 10
29
+ end
30
+ assert_equal 10, t.instance_variable_get(:@options).server_port
31
+ assert_equal 10, t.server_port
32
+ end
23
33
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: deep_test
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.1.3
7
- date: 2008-03-10 00:00:00 -04:00
6
+ version: 1.1.4
7
+ date: 2008-03-11 00:00:00 -04:00
8
8
  summary: DeepTest runs tests in multiple processes.
9
9
  require_paths:
10
10
  - lib
@@ -49,6 +49,7 @@ files:
49
49
  - lib/deep_test/spec/runner.rb
50
50
  - lib/deep_test/spec/work_result.rb
51
51
  - lib/deep_test/spec/work_unit.rb
52
+ - lib/deep_test/spec/extensions/example_group_methods.rb
52
53
  - lib/deep_test/spec/extensions/options.rb
53
54
  - lib/deep_test/spec/extensions/reporter.rb
54
55
  - lib/deep_test/spec/extensions/spec_task.rb