jstorimer-deep-test 0.2.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. data/.gitignore +0 -1
  2. data/README.rdoc +70 -41
  3. data/Rakefile +104 -32
  4. data/TODO +2 -2
  5. data/VERSION +1 -1
  6. data/bin/deep_test +15 -0
  7. data/jstorimer-deep-test-0.1.0.gem +0 -0
  8. data/jstorimer-deep-test.gemspec +1425 -0
  9. data/lib/deep_test.rb +40 -28
  10. data/lib/deep_test/database/mysql_setup_listener.rb +12 -12
  11. data/lib/deep_test/database/setup_listener.rb +23 -23
  12. data/lib/deep_test/distributed/dispatch_controller.rb +10 -17
  13. data/lib/deep_test/distributed/drb_client_connection_info.rb +15 -0
  14. data/lib/deep_test/distributed/master_test_server.rb +52 -0
  15. data/lib/deep_test/distributed/multi_test_server_proxy.rb +44 -0
  16. data/lib/deep_test/distributed/null_work_unit.rb +12 -0
  17. data/lib/deep_test/distributed/remote_worker_client.rb +54 -0
  18. data/lib/deep_test/distributed/remote_worker_server.rb +82 -0
  19. data/lib/deep_test/distributed/rsync.rb +12 -25
  20. data/lib/deep_test/distributed/show_status.rhtml +41 -0
  21. data/lib/deep_test/distributed/test_server.rb +78 -0
  22. data/lib/deep_test/distributed/test_server_status.rb +9 -0
  23. data/lib/deep_test/distributed/test_server_workers.rb +24 -0
  24. data/lib/deep_test/distributed/throughput_runner.rb +42 -0
  25. data/lib/deep_test/distributed/throughput_statistics.rb +26 -0
  26. data/lib/deep_test/distributed/throughput_worker_client.rb +19 -0
  27. data/lib/deep_test/extensions/drb_extension.rb +34 -0
  28. data/lib/deep_test/listener_list.rb +1 -1
  29. data/lib/deep_test/local_workers.rb +55 -0
  30. data/lib/deep_test/logger.rb +2 -17
  31. data/lib/deep_test/marshallable_exception_wrapper.rb +4 -4
  32. data/lib/deep_test/metrics/gatherer.rb +67 -0
  33. data/lib/deep_test/metrics/queue_lock_wait_time_measurement.rb +133 -0
  34. data/lib/deep_test/{null_listener.rb → null_worker_listener.rb} +14 -14
  35. data/lib/deep_test/option.rb +60 -0
  36. data/lib/deep_test/options.rb +42 -45
  37. data/lib/deep_test/process_orchestrator.rb +49 -0
  38. data/lib/deep_test/rake_tasks.rb +1 -3
  39. data/lib/deep_test/result_reader.rb +6 -10
  40. data/lib/deep_test/rspec_detector.rb +1 -1
  41. data/lib/deep_test/server.rb +75 -0
  42. data/lib/deep_test/spec.rb +1 -5
  43. data/lib/deep_test/spec/extensions/example_methods.rb +1 -7
  44. data/lib/deep_test/spec/extensions/reporter.rb +29 -0
  45. data/lib/deep_test/spec/extensions/spec_task.rb +2 -3
  46. data/lib/deep_test/spec/runner.rb +17 -32
  47. data/lib/deep_test/spec/work_result.rb +0 -2
  48. data/lib/deep_test/test/runner.rb +2 -2
  49. data/lib/deep_test/test/supervised_test_suite.rb +10 -9
  50. data/lib/deep_test/test/work_result.rb +0 -1
  51. data/lib/deep_test/test_task.rb +1 -1
  52. data/lib/deep_test/ui/console.rb +11 -9
  53. data/lib/deep_test/warlock.rb +25 -37
  54. data/lib/deep_test/worker.rb +57 -0
  55. data/sample_rails_project/deep_test.rb +0 -4
  56. data/sample_rails_project/lib/{foreign_host_agent_simulation_listener.rb → foreign_host_worker_simulation_listener.rb} +4 -6
  57. data/sample_rails_project/lib/tasks/deep_test.rake +4 -13
  58. data/script/internal/run_test_suite.rb +7 -0
  59. data/script/public/master_test_server.rb +24 -0
  60. data/script/public/test_server.rb +18 -0
  61. data/script/public/test_throughput.rb +29 -0
  62. data/spec/deep_test/option_spec.rb +33 -0
  63. data/spec/deep_test/options_spec.rb +59 -80
  64. data/spec/deep_test/spec/extensions/example_methods_spec.rb +4 -5
  65. data/spec/deep_test/spec/extensions/spec_task_spec.rb +6 -4
  66. data/spec/deep_test/spec/runner_spec.rb +32 -59
  67. data/spec/spec_helper.rb +6 -14
  68. data/spec/thread_worker.rb +25 -0
  69. data/test/deep_test/database/mysql_setup_listener_test.rb +9 -13
  70. data/test/deep_test/distributed/dispatch_controller_test.rb +177 -130
  71. data/test/deep_test/distributed/drb_client_connection_info_test.rb +42 -0
  72. data/test/deep_test/distributed/filename_resolver_test.rb +34 -38
  73. data/test/deep_test/distributed/master_test_server_test.rb +32 -0
  74. data/test/deep_test/distributed/multi_test_server_proxy_test.rb +96 -0
  75. data/test/deep_test/distributed/remote_worker_client_test.rb +180 -0
  76. data/test/deep_test/distributed/remote_worker_server_test.rb +99 -0
  77. data/test/deep_test/distributed/rsync_test.rb +62 -42
  78. data/test/deep_test/distributed/test_server_test.rb +94 -0
  79. data/test/deep_test/distributed/test_server_workers_test.rb +26 -0
  80. data/test/deep_test/distributed/throughput_runner_test.rb +68 -0
  81. data/test/deep_test/distributed/throughput_worker_client_test.rb +28 -0
  82. data/test/deep_test/listener_list_test.rb +15 -17
  83. data/test/deep_test/local_workers_test.rb +22 -0
  84. data/test/deep_test/logger_test.rb +7 -34
  85. data/test/deep_test/marshallable_exception_wrapper_test.rb +29 -31
  86. data/test/deep_test/metrics/gatherer_test.rb +66 -0
  87. data/test/deep_test/process_orchestrator_test.rb +11 -0
  88. data/test/deep_test/result_reader_test.rb +95 -95
  89. data/test/deep_test/server_test.rb +58 -0
  90. data/test/deep_test/test/extensions/error_test.rb +36 -38
  91. data/test/deep_test/test/runner_test.rb +3 -7
  92. data/test/deep_test/test/supervised_test_suite_test.rb +61 -89
  93. data/test/deep_test/test/work_result_test.rb +76 -80
  94. data/test/deep_test/test/work_unit_test.rb +51 -53
  95. data/test/deep_test/test_task_test.rb +38 -10
  96. data/test/deep_test/ui/console_test.rb +4 -8
  97. data/test/deep_test/warlock_test.rb +31 -33
  98. data/test/deep_test/worker_test.rb +94 -0
  99. data/test/failing.rake +11 -0
  100. data/{negative_acceptance_tests/failing_test.rb → test/failing.rb} +1 -3
  101. data/{infrastructure → test}/fake_deadlock_error.rb +0 -0
  102. data/test/simple_test_blackboard.rb +45 -0
  103. data/test/simple_test_blackboard_test.rb +33 -0
  104. data/{infrastructure → test}/test_factory.rb +0 -0
  105. data/test/test_helper.rb +5 -20
  106. data/test/test_task_test.rb +57 -60
  107. metadata +78 -87
  108. data/infrastructure/dynamic_teardown.rb +0 -22
  109. data/infrastructure/load.rb +0 -11
  110. data/infrastructure/test_central_command.rb +0 -15
  111. data/infrastructure/test_exception.rb +0 -7
  112. data/infrastructure/test_logger.rb +0 -11
  113. data/infrastructure/test_operator.rb +0 -15
  114. data/infrastructure/test_result.rb +0 -15
  115. data/infrastructure/thread_agent.rb +0 -21
  116. data/infrastructure/timewarp/Rakefile +0 -14
  117. data/infrastructure/timewarp/lib/timewarp.rb +0 -21
  118. data/infrastructure/timewarp/test/timewarp_test.rb +0 -45
  119. data/lib/deep_test/agent.rb +0 -108
  120. data/lib/deep_test/central_command.rb +0 -165
  121. data/lib/deep_test/cpu_info.rb +0 -22
  122. data/lib/deep_test/demon.rb +0 -25
  123. data/lib/deep_test/distributed/beachhead.rb +0 -104
  124. data/lib/deep_test/distributed/establish_beachhead.rb +0 -19
  125. data/lib/deep_test/distributed/landing_fleet.rb +0 -30
  126. data/lib/deep_test/distributed/landing_ship.rb +0 -60
  127. data/lib/deep_test/distributed/remote_deployment.rb +0 -56
  128. data/lib/deep_test/distributed/shell_environment.rb +0 -50
  129. data/lib/deep_test/distributed/ssh_client_connection_info.rb +0 -14
  130. data/lib/deep_test/failure_message.rb +0 -19
  131. data/lib/deep_test/lib_root.rb +0 -4
  132. data/lib/deep_test/local_deployment.rb +0 -46
  133. data/lib/deep_test/main.rb +0 -41
  134. data/lib/deep_test/metrics/data.rb +0 -34
  135. data/lib/deep_test/metrics/measurement.rb +0 -39
  136. data/lib/deep_test/proxy_io.rb +0 -77
  137. data/lib/deep_test/test/run_test_suite.rb +0 -5
  138. data/lib/telegraph.rb +0 -29
  139. data/lib/telegraph/ack_sequence.rb +0 -14
  140. data/lib/telegraph/logging.rb +0 -20
  141. data/lib/telegraph/message.rb +0 -39
  142. data/lib/telegraph/operator.rb +0 -47
  143. data/lib/telegraph/switchboard.rb +0 -57
  144. data/lib/telegraph/wire.rb +0 -73
  145. data/negative_acceptance_tests/dying_spec.rb +0 -13
  146. data/negative_acceptance_tests/dying_test.rb +0 -13
  147. data/negative_acceptance_tests/failing_spec.rb +0 -9
  148. data/negative_acceptance_tests/kill_agent_one_on_start_work.rb +0 -16
  149. data/negative_acceptance_tests/passing_spec.rb +0 -10
  150. data/negative_acceptance_tests/passing_test.rb +0 -12
  151. data/negative_acceptance_tests/tasks.rake +0 -87
  152. data/negative_acceptance_tests/tests.rb +0 -60
  153. data/test/deep_test/agent_test.rb +0 -175
  154. data/test/deep_test/central_command_test.rb +0 -147
  155. data/test/deep_test/cpu_info_test.rb +0 -33
  156. data/test/deep_test/demon_test.rb +0 -23
  157. data/test/deep_test/distributed/beachhead_test.rb +0 -67
  158. data/test/deep_test/distributed/landing_fleet_test.rb +0 -55
  159. data/test/deep_test/distributed/landing_ship_test.rb +0 -48
  160. data/test/deep_test/distributed/remote_deployment_test.rb +0 -134
  161. data/test/deep_test/distributed/shell_environment_fixtures/set_bar_to_foo +0 -1
  162. data/test/deep_test/distributed/shell_environment_fixtures/set_foo_to_bar +0 -1
  163. data/test/deep_test/distributed/shell_environment_fixtures/set_foo_to_baz +0 -1
  164. data/test/deep_test/distributed/shell_environment_test.rb +0 -108
  165. data/test/deep_test/distributed/ssh_client_connection_info_test.rb +0 -34
  166. data/test/deep_test/local_deployment_test.rb +0 -19
  167. data/test/deep_test/main_test.rb +0 -12
  168. data/test/deep_test/metrics/data_test.rb +0 -22
  169. data/test/deep_test/metrics/measurement_test.rb +0 -18
  170. data/test/deep_test/proxy_io_test.rb +0 -104
@@ -0,0 +1,33 @@
1
+ require File.dirname(__FILE__) + "/../spec_helper"
2
+
3
+ module DeepTest
4
+ describe Option do
5
+ it "should have hash conversion" do
6
+ option = Option.new(:name, Option::Hash, {})
7
+ string = option.to_command_line({:a => "1", :b => "a"})
8
+ string.should be_instance_of(String)
9
+ option.from_command_line(string).should == {:a => "1", :b => "a"}
10
+ end
11
+
12
+ it "should support booleans in hash" do
13
+ option = Option.new(:name, Option::Hash, {})
14
+ string = option.to_command_line({:a => true})
15
+ string.should be_instance_of(String)
16
+ option.from_command_line(string).should == {:a => true}
17
+ end
18
+
19
+ it "should handle hash values with spaces" do
20
+ option = Option.new(:name, Option::Hash, {})
21
+
22
+ string = option.to_command_line(
23
+ {:a => "has a space", :b => "has more spaces"}
24
+ )
25
+
26
+ string.should be_instance_of(String)
27
+
28
+ option.from_command_line(string).should ==
29
+ {:a => "has a space", :b => "has more spaces"}
30
+ end
31
+ end
32
+ end
33
+
@@ -2,55 +2,59 @@ require File.dirname(__FILE__) + "/../spec_helper"
2
2
 
3
3
  module DeepTest
4
4
  describe Options do
5
- it "should support number_of_agents" do
6
- Options.new(:number_of_agents => 3).number_of_agents.should == 3
7
- end
8
-
9
- it "should default to number_of_agents based on cpu info at time of call" do
10
- options = Options.new({})
11
- CpuInfo.should_receive(:new).and_return stub("cpu_info", :count => 4)
12
- options.number_of_agents.should == 4
5
+ it "should support number_of_workers" do
6
+ Options.new(:number_of_workers => 3).number_of_workers.should == 3
13
7
  end
14
8
 
15
9
  it "should have reasonable defaults" do
16
10
  options = Options.new({})
11
+ options.number_of_workers.should == 2
12
+ options.timeout_in_seconds.should == 30
13
+ options.server_port.should == 6969
17
14
  options.pattern.should == nil
18
15
  options.metrics_file.should == nil
19
16
  end
20
17
 
18
+ it "should support timeout_in_seconds" do
19
+ Options.new(:timeout_in_seconds => 2).timeout_in_seconds.should == 2
20
+ end
21
+
21
22
  it "should support pattern" do
22
23
  Options.new(:pattern => '*').pattern.should == '*'
23
24
  end
24
25
 
25
- it "should support distributed_hosts" do
26
- Options.new(:distributed_hosts => %w[host1 host2]).
27
- distributed_hosts.should == %w[host1 host2]
26
+ it "should support distributed_server" do
27
+ Options.new(:distributed_server => "uri").distributed_server.should == "uri"
28
+ end
29
+
30
+ it "should support server_port" do
31
+ Options.new(:server_port => 10).server_port.should == 10
28
32
  end
29
33
 
30
34
  it "should support sync_options" do
31
35
  Options.new(:sync_options => {:options => 1}).sync_options.should == {:options => 1}
32
36
  end
33
37
 
34
- it "should support listener" do
35
- Options.new(:listener => "AListener").
36
- listener.should == "AListener"
38
+ it "should support worker_listener" do
39
+ Options.new(:worker_listener => "AListener").
40
+ worker_listener.should == "AListener"
37
41
  end
38
42
 
39
- it "should use DeepTest::NullListener as the default listener" do
40
- Options.new({}).listener.should == "DeepTest::NullListener"
43
+ it "should use DeepTest::NullWorkerListener as the default listener" do
44
+ Options.new({}).worker_listener.should == "DeepTest::NullWorkerListener"
41
45
  end
42
46
 
43
- it "should allow listener to be set with class" do
47
+ it "should allow worker_listener to be set with class" do
44
48
  class FakeListener; end
45
- Options.new(:listener => FakeListener).
46
- listener.should == "DeepTest::FakeListener"
49
+ Options.new(:worker_listener => FakeListener).
50
+ worker_listener.should == "DeepTest::FakeListener"
47
51
  end
48
52
 
49
- it "should allow multiple listeners to be specified" do
53
+ it "should allow multiple workers to be specified" do
50
54
  class FakeListener1; end
51
55
  class FakeListener2; end
52
56
  options = Options.new(
53
- :listener => "DeepTest::FakeListener1,DeepTest::FakeListener2"
57
+ :worker_listener => "DeepTest::FakeListener1,DeepTest::FakeListener2"
54
58
  )
55
59
  listener = options.new_listener_list
56
60
  listener.should be_instance_of(DeepTest::ListenerList)
@@ -59,7 +63,7 @@ module DeepTest
59
63
  listener.listeners.last.should be_instance_of(FakeListener2)
60
64
  end
61
65
 
62
- it "should create a list of agent listeners upon request" do
66
+ it "should create a list of worker listeners upon request" do
63
67
  Options.new({}).new_listener_list.should be_instance_of(DeepTest::ListenerList)
64
68
  end
65
69
 
@@ -88,7 +92,7 @@ module DeepTest
88
92
  end
89
93
 
90
94
  it "should support strings as well as symbols" do
91
- Options.new("server_port" => 2).server_port.should == 2
95
+ Options.new("number_of_workers" => 2).number_of_workers.should == 2
92
96
  end
93
97
 
94
98
  it "should raise error when invalid option is specifed" do
@@ -98,50 +102,42 @@ module DeepTest
98
102
  end
99
103
 
100
104
  it "should convert to command line option string" do
101
- options = Options.new(:number_of_agents => 1)
102
- options.to_command_line.should == Base64.encode64(Marshal.dump(options)).gsub("\n","")
105
+ options = Options.new(:number_of_workers => 1, :timeout_in_seconds => 3)
106
+ options.to_command_line.should ==
107
+ "--number_of_workers 1 --timeout_in_seconds 3"
103
108
  end
104
109
 
105
110
  it "should parse from command line option string" do
106
- options = Options.new(:number_of_agents => 2, :pattern => '*')
107
- parsed_options = Options.from_command_line(options.to_command_line)
108
- parsed_options.number_of_agents.should == 2
109
- parsed_options.pattern.should == '*'
111
+ options = Options.from_command_line(
112
+ "--number_of_workers 2 --timeout_in_seconds 3 --pattern *")
113
+ options.number_of_workers.should == 2
114
+ options.timeout_in_seconds.should == 3
115
+ options.pattern.should == '*'
110
116
  end
111
117
 
112
118
  it "should use default option value when no command line option is present" do
113
- ["", nil].each do |blank_value|
114
- options = Options.from_command_line(blank_value)
115
- options.ui == "DeepTest::UI::Console"
116
- end
119
+ options = Options.from_command_line("")
120
+ options.number_of_workers.should == 2
117
121
  end
118
122
 
119
- it "should create local deployment by default" do
123
+ it "should create local workers by default" do
120
124
  options = Options.new({})
121
- options.new_deployment.should be_instance_of(LocalDeployment)
125
+ options.new_workers.should be_instance_of(LocalWorkers)
122
126
  end
123
127
 
124
- it "should create remote deployment when distributed hosts are specified" do
125
- options = Options.new(:distributed_hosts => %w[hosts], :sync_options => {:source => "root"})
126
- Distributed::RemoteDeployment.should_receive(:new).with(options,
127
- be_instance_of(Distributed::LandingFleet),
128
- be_instance_of(LocalDeployment))
129
- options.new_deployment
128
+ it "should create remote worker client when distributed server is specified" do
129
+ options = Options.new(:distributed_server => "uri", :sync_options => {:source => "root"})
130
+ Distributed::TestServer.should_receive(:connect).with(options).and_return(:server_instance)
131
+ Distributed::RemoteWorkerClient.should_receive(:new).with(options, :server_instance, be_instance_of(LocalWorkers))
132
+ options.new_workers
130
133
  end
131
134
 
132
- it "should create a landing fleet with a ship for each host" do
133
- Socket.should_receive(:gethostname).and_return("myhost")
134
- options = Options.new(:ui => "DeepTest::UI::Null",
135
- :sync_options => {:source => "/my/local/dir"},
136
- :distributed_hosts => %w[host1 host2])
137
-
138
- Distributed::RSync.should_receive(:push).with("host1", options.sync_options, "/tmp/myhost_my_local_dir")
139
- Distributed::RSync.should_receive(:push).with("host2", options.sync_options, "/tmp/myhost_my_local_dir")
140
-
141
- options.new_landing_fleet.push_code(options)
135
+ it "should create local workers when connect fails" do
136
+ options = Options.new(:distributed_server => "uri", :sync_options => {:source => "root"}, :ui => "DeepTest::UI::Null")
137
+ Distributed::TestServer.should_receive(:connect).and_raise("An error")
138
+ options.new_workers.should be_instance_of(LocalWorkers)
142
139
  end
143
140
 
144
-
145
141
  it "should return localhost as origin_hostname current hostname is same as when created" do
146
142
  options = Options.new({})
147
143
  options.origin_hostname.should == 'localhost'
@@ -154,41 +150,24 @@ module DeepTest
154
150
  options.origin_hostname.should == local_hostname
155
151
  end
156
152
 
157
- it "should connect_to_central_command on localhost when there is no SSH info" do
158
- Telegraph::Wire.should_receive(:connect).with("localhost", 9999).and_yield(:wire)
159
- yielded_wire = nil
160
- Options.new(:server_port => 9999).connect_to_central_command { |yielded_wire| }
161
- yielded_wire.should == :wire
162
- end
163
-
164
- it "should connect_to_central_command on remote address where there is SSH info" do
165
- Telegraph::Wire.should_receive(:connect).with("remote_address", 9999).and_yield(:wire)
166
- yielded_wire = nil
167
-
168
- options = Options.new(:server_port => 9999)
169
- options.ssh_client_connection_info = mock("connection_info", :address => "remote_address")
170
- options.connect_to_central_command { |yielded_wire| }
171
-
172
- yielded_wire.should == :wire
173
- end
174
-
175
- it "should be able to calculate mirror_path based on sync_options" do
176
- Socket.should_receive(:gethostname).and_return("hostname")
177
- options = Options.new(:sync_options => {:source => "/my/source/path", :remote_base_dir => "/mirror/base/path"})
178
- options.mirror_path.should == "/mirror/base/path/hostname_my_source_path"
153
+ it "should be able to calculate mirror_path based on base an sync_options" do
154
+ Socket.should_receive(:gethostname).and_return("hostname", "server_hostname")
155
+ options = Options.new(:sync_options => {:source => "/my/source/path"})
156
+ options.mirror_path("/mirror/base/path").should ==
157
+ "/mirror/base/path/hostname_my_source_path"
179
158
  end
180
159
 
181
160
  it "should raise a useful error if no source is specified" do
182
- options = DeepTest::Options.new(:sync_options => {:remote_base_dir => "/mirror/base/path/"})
161
+ options = DeepTest::Options.new(:sync_options => {})
183
162
  lambda {
184
- options.mirror_path
163
+ options.mirror_path("base")
185
164
  }.should raise_error("No source directory specified in sync_options")
186
165
  end
187
166
 
188
- it "should default to /tmp if no remote_base_dir is specified in sync_options" do
189
- Socket.should_receive(:gethostname).and_return("hostname")
190
- options = DeepTest::Options.new(:sync_options => {:source => "/my/source/path"})
191
- options.mirror_path.should == "/tmp/hostname_my_source_path"
167
+ it "should create drb object to connect to server" do
168
+ options = DeepTest::Options.new({})
169
+ server = options.server
170
+ server.__drburi.should == "druby://#{options.origin_hostname}:#{options.server_port}"
192
171
  end
193
172
 
194
173
  it "should be gathering metrics if metrics file is set" do
@@ -14,9 +14,8 @@ module Spec
14
14
  example_1 = group.examples.first
15
15
  example_2 = group.examples.last
16
16
 
17
-
18
- (example_1.identifier.locate([group]) == example_1).should == true # as of rspec 1.1.12 should is redefined on examples to behave differently
19
- (example_2.identifier.locate([group]) == example_2).should == true
17
+ example_1.identifier.locate([group]).should == example_1
18
+ example_2.identifier.locate([group]).should == example_2
20
19
  end
21
20
 
22
21
  it "should have identifier that can locate the example by name" do
@@ -29,8 +28,8 @@ module Spec
29
28
  example_1 = group.examples.first
30
29
  example_2 = group.examples.last
31
30
 
32
- (example_1.identifier.locate([group]) == example_1).should == true
33
- (example_2.identifier.locate([group]) == example_2).should == true
31
+ example_1.identifier.locate([group]).should == example_1
32
+ example_2.identifier.locate([group]).should == example_2
34
33
  end
35
34
 
36
35
  describe ExampleMethods::Identifier do
@@ -3,11 +3,12 @@ require File.dirname(__FILE__) + "/../../../spec_helper"
3
3
  describe Spec::Rake::SpecTask do
4
4
  it "should allow deep_test configuration" do
5
5
  t = Spec::Rake::SpecTask.new do |t|
6
- t.deep_test :number_of_agents => 2
6
+ t.deep_test :number_of_workers => 2
7
7
  end
8
8
 
9
- deep_test_path = File.expand_path(DeepTest::LIB_ROOT + "/deep_test")
10
- options = DeepTest::Options.new(:number_of_agents => 2)
9
+ deep_test_path = File.expand_path(File.dirname(__FILE__) +
10
+ '/../../../../lib/deep_test')
11
+ options = DeepTest::Options.new(:number_of_workers => 2)
11
12
  t.spec_opts.should == ["--require #{deep_test_path}",
12
13
  "--runner 'DeepTest::Spec::Runner:#{options.to_command_line}'"]
13
14
  end
@@ -18,7 +19,8 @@ describe Spec::Rake::SpecTask do
18
19
  t.spec_opts = ["anoption"]
19
20
  end
20
21
 
21
- deep_test_path = File.expand_path(DeepTest::LIB_ROOT + "/deep_test")
22
+ deep_test_path = File.expand_path(File.dirname(__FILE__) +
23
+ '/../../../../lib/deep_test')
22
24
  options = DeepTest::Options.new({})
23
25
  t.spec_opts.should == ["--require #{deep_test_path}",
24
26
  "--runner 'DeepTest::Spec::Runner:#{options.to_command_line}'",
@@ -5,127 +5,100 @@ module DeepTest
5
5
  describe Runner do
6
6
  it_should_behave_like 'sandboxed rspec_options'
7
7
 
8
- it "should run each test using central_command" do
9
- deep_test_options = Options.new({})
10
- central_command = TestCentralCommand.start deep_test_options
11
- runner = Runner.new(options, deep_test_options.to_command_line)
8
+ it "should run each test using blackboard" do
9
+ blackboard = SimpleTestBlackboard.new
10
+ runner = Runner.new(options, Options.new({}), blackboard)
12
11
 
13
12
  describe("test") do
14
13
  it("passes1") {}
15
14
  it("passes2") {}
16
15
  end
17
16
 
18
- agent = ThreadAgent.new deep_test_options
17
+ worker = ThreadWorker.new(blackboard, 2)
19
18
  Timeout.timeout(5) do
20
- runner.process_work_units(central_command).should == true
19
+ runner.process_work_units.should == true
21
20
  end
22
- central_command.done_with_work
23
- agent.wait_until_done
21
+ worker.wait_until_done
24
22
 
25
- agent.work_done.should == 2
23
+ worker.work_done.should == 2
26
24
  options.reporter.number_of_examples.should == 2
27
- central_command.remaining_result_count.should == 0
25
+ blackboard.take_result.should be_nil
28
26
  options.reporter.examples_finished.should == ['passes1','passes2']
29
27
  options.reporter.should be_ended
30
28
  end
31
29
 
32
30
  it "should return failure when a spec fails" do
33
- deep_test_options = Options.new({})
34
- central_command = TestCentralCommand.start deep_test_options
35
- runner = Runner.new(options, deep_test_options.to_command_line)
31
+ blackboard = SimpleTestBlackboard.new
32
+ runner = Runner.new(options, Options.new({}), blackboard)
36
33
 
37
34
  describe("test") do
38
35
  it("passes") {};
39
36
  it("fails") {1.should == 2};
40
37
  end
41
38
 
42
- agent = ThreadAgent.new(deep_test_options)
39
+ worker = ThreadWorker.new(blackboard, 2)
43
40
  Timeout.timeout(5) do
44
- runner.process_work_units(central_command).should == false
41
+ runner.process_work_units.should == false
45
42
  end
46
- central_command.done_with_work
47
- agent.wait_until_done
43
+ worker.wait_until_done
48
44
  end
49
45
 
50
46
  it "should return success when there are pending examples" do
51
- deep_test_options = Options.new({})
52
- central_command = TestCentralCommand.start deep_test_options
53
- runner = Runner.new(options, deep_test_options.to_command_line)
47
+ blackboard = SimpleTestBlackboard.new
48
+ runner = Runner.new(options, Options.new({}), blackboard)
54
49
 
55
50
  describe("test") do
56
51
  it("pending") {pending {1.should == 2}};
57
52
  end
58
53
 
59
- agent = ThreadAgent.new deep_test_options
54
+ worker = ThreadWorker.new(blackboard, 1)
60
55
  Timeout.timeout(5) do
61
- runner.process_work_units(central_command).should == true
56
+ runner.process_work_units.should == true
62
57
  end
63
- central_command.done_with_work
64
- agent.wait_until_done
58
+ worker.wait_until_done
65
59
  end
66
60
 
67
61
  it "should return failure when a pending example passes" do
68
- deep_test_options = Options.new({})
69
- central_command = TestCentralCommand.start deep_test_options
70
- runner = Runner.new(options, deep_test_options.to_command_line)
62
+ blackboard = SimpleTestBlackboard.new
63
+ runner = Runner.new(options, Options.new({}), blackboard)
71
64
 
72
65
  describe("test") do
73
66
  it("pending") {pending {1.should == 1}};
74
67
  end
75
68
 
76
- agent = ThreadAgent.new deep_test_options
69
+ worker = ThreadWorker.new(blackboard, 1)
77
70
  Timeout.timeout(5) do
78
- runner.process_work_units(central_command).should == false
71
+ runner.process_work_units.should == false
79
72
  end
80
- central_command.done_with_work
81
- agent.wait_until_done
73
+ worker.wait_until_done
82
74
  end
83
75
 
84
- it "should return failure when a agent error occurs" do
85
- deep_test_options = Options.new({})
86
- central_command = TestCentralCommand.start deep_test_options
87
- runner = Runner.new(options, deep_test_options.to_command_line)
88
-
89
- describe("test") { it("does") {} }
90
-
91
- central_command.write_result Agent::Error.new("example", RuntimeError.new)
92
- capture_stdout do
93
- runner.process_work_units(central_command).should == false
94
- end
95
-
96
- options.reporter.number_of_errors.should == 1
97
- end
98
-
99
- it "should return a singl efailure when multiple agent error occurs" do
100
- deep_test_options = Options.new({})
101
- central_command = TestCentralCommand.start deep_test_options
102
- runner = Runner.new(options, deep_test_options.to_command_line)
76
+ it "should return failure when a worker error occurs" do
77
+ blackboard = SimpleTestBlackboard.new
78
+ runner = Runner.new(options, Options.new({}), blackboard)
103
79
 
104
80
  describe("test") do
105
- it("does a") {}
106
- it("does b") {}
81
+ it("pending") {pending {1.should == 1}};
107
82
  end
108
83
 
109
- central_command.write_result Agent::Error.new("example 1", RuntimeError.new)
110
- central_command.write_result Agent::Error.new("example 2", RuntimeError.new)
84
+ blackboard.write_result Worker::Error.new("example", RuntimeError.new)
111
85
  capture_stdout do
112
- runner.process_work_units(central_command).should == false
86
+ runner.process_work_units.should == false
113
87
  end
114
88
 
115
89
  options.reporter.number_of_errors.should == 1
116
90
  end
117
91
 
118
92
  it "should raise error if duplicate spec is found" do
119
- deep_test_options = Options.new({})
120
- central_command = TestCentralCommand.start deep_test_options
121
- runner = Runner.new(options, deep_test_options.to_command_line)
93
+ blackboard = SimpleTestBlackboard.new
94
+ runner = Runner.new(options, Options.new({}), blackboard)
122
95
 
123
96
  describe("test") do
124
97
  2.times {it("example") {}};
125
98
  end
126
99
 
127
100
  lambda {
128
- runner.process_work_units(central_command)
101
+ runner.process_work_units
129
102
  }.should raise_error
130
103
  end
131
104
  end