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
@@ -1,48 +1,43 @@
1
1
  module DeepTest
2
- Option = Struct.new :name, :default unless defined?(Option)
3
-
4
2
  class Options
5
3
  unless defined?(VALID_OPTIONS)
6
4
  VALID_OPTIONS = [
7
- Option.new(:distributed_hosts, nil),
8
- Option.new(:number_of_agents, nil),
9
- Option.new(:metrics_file, nil),
10
- Option.new(:pattern, nil),
11
- Option.new(:server_port, nil),
12
- Option.new(:sync_options, {}),
13
- Option.new(:ui, "DeepTest::UI::Console"),
14
- Option.new(:listener, "DeepTest::NullListener"),
5
+ Option.new(:distributed_server, Option::String, nil),
6
+ Option.new(:number_of_workers, Option::Integer, 2),
7
+ Option.new(:metrics_file, Option::String, nil),
8
+ Option.new(:pattern, Option::String, nil),
9
+ Option.new(:server_port, Option::Integer, 6969),
10
+ Option.new(:sync_options, Option::Hash, {}),
11
+ Option.new(:timeout_in_seconds, Option::Integer, 30),
12
+ Option.new(:ui, Option::String, "DeepTest::UI::Console"),
13
+ Option.new(:worker_listener, Option::String, "DeepTest::NullWorkerListener"),
15
14
  ]
16
15
  end
17
16
 
18
17
  attr_accessor *VALID_OPTIONS.map {|o| o.name}
19
- attr_accessor :ssh_client_connection_info, :environment_log_level
20
-
21
- def number_of_agents
22
- return CpuInfo.new.count unless @number_of_agents
23
- @number_of_agents
24
- end
25
18
 
26
19
  def ui=(value)
27
20
  @ui = value.to_s
28
21
  end
29
22
 
30
- def listener=(value)
31
- @listener = value.to_s
23
+ def worker_listener=(value)
24
+ @worker_listener = value.to_s
32
25
  end
33
26
 
34
27
  def self.from_command_line(command_line)
35
- return new({}) if command_line.nil? || command_line.empty?
36
- Marshal.load Base64.decode64(command_line)
28
+ hash = {}
29
+ VALID_OPTIONS.each do |option|
30
+ hash[option.name] = option.from_command_line(command_line)
31
+ end
32
+ new(hash)
37
33
  end
38
34
 
39
35
  def initialize(hash)
40
36
  @origin_hostname = Socket.gethostname
41
37
  check_option_keys(hash)
42
38
  VALID_OPTIONS.each do |option|
43
- send("#{option.name}=", hash[option.name] || hash[option.name.to_s] || option.default)
39
+ send("#{option.name}=", hash[option.name] || option.default)
44
40
  end
45
- self.environment_log_level = ENV['DEEP_TEST_LOG_LEVEL']
46
41
  end
47
42
 
48
43
  def gathering_metrics?
@@ -50,7 +45,7 @@ module DeepTest
50
45
  end
51
46
 
52
47
  def new_listener_list
53
- listeners = listener.split(',').map do |listener|
48
+ listeners = worker_listener.split(',').map do |listener|
54
49
  eval(listener).new
55
50
  end
56
51
  ListenerList.new(listeners)
@@ -60,15 +55,9 @@ module DeepTest
60
55
  (Socket.gethostname == @origin_hostname) ? 'localhost' : @origin_hostname
61
56
  end
62
57
 
63
- def connect_to_central_command
64
- address = ssh_client_connection_info ? ssh_client_connection_info.address : "localhost"
65
- Telegraph::Wire.connect(address, server_port) do |wire|
66
- yield wire
67
- end
68
- end
69
-
70
58
  # Don't store UI instances in the options instance, which will
71
- # need to be dumped over Telegraph since UI instances may not be dumpable.
59
+ # need to be dumped over DRb. UI instances may not be dumpable
60
+ # and we don't want to have to start yet another DRb Server
72
61
  #
73
62
  UI_INSTANCES = {} unless defined?(UI_INSTANCES)
74
63
  def ui_instance
@@ -76,35 +65,43 @@ module DeepTest
76
65
  end
77
66
 
78
67
  def to_command_line
79
- Base64.encode64(Marshal.dump(self)).gsub("\n","")
68
+ command_line = []
69
+ VALID_OPTIONS.each do |option|
70
+ value = send(option.name)
71
+ command_line << option.to_command_line(value)
72
+ end
73
+ command_line.compact.join(' ')
80
74
  end
81
75
 
82
- def mirror_path
76
+ def mirror_path(base)
83
77
  raise "No source directory specified in sync_options" unless sync_options[:source]
84
- relative_mirror_path = @origin_hostname + sync_options[:source].gsub('/','_')
85
- "#{sync_options[:remote_base_dir] || '/tmp'}/#{relative_mirror_path}"
78
+ relative_mirror_path = origin_hostname + sync_options[:source].gsub('/','_')
79
+ "#{base}/#{relative_mirror_path}"
86
80
  end
87
81
 
88
- def new_deployment
89
- if distributed_hosts.nil?
90
- LocalDeployment.new self
82
+ def new_workers
83
+ if distributed_server.nil?
84
+ LocalWorkers.new self
91
85
  else
92
- Distributed::RemoteDeployment.new self, new_landing_fleet, LocalDeployment.new(self)
86
+ begin
87
+ server = Distributed::TestServer.connect(self)
88
+ Distributed::RemoteWorkerClient.new(self, server, LocalWorkers.new(self))
89
+ rescue => e
90
+ ui_instance.distributed_failover_to_local("connect", e)
91
+ LocalWorkers.new self
92
+ end
93
93
  end
94
94
  end
95
95
 
96
- def new_landing_fleet
97
- landing_ships = distributed_hosts.map do |host|
98
- Distributed::LandingShip.new :address => host
99
- end
100
- Distributed::LandingFleet.new self, landing_ships
96
+ def server
97
+ Server.remote_reference(origin_hostname, server_port)
101
98
  end
102
99
 
103
100
  protected
104
101
 
105
102
  def check_option_keys(hash)
106
103
  hash.keys.each do |key|
107
- raise InvalidOptionError.new("#{key} is not a valid option") unless VALID_OPTIONS.any? {|o| o.name == key.to_sym}
104
+ raise InvalidOptionError.new(key) unless VALID_OPTIONS.any? {|o| o.name == key.to_sym}
108
105
  end
109
106
  end
110
107
 
@@ -0,0 +1,49 @@
1
+ module DeepTest
2
+ class ProcessOrchestrator
3
+ def self.run(options, workers, runner)
4
+ new(options, workers, runner).run
5
+ end
6
+
7
+ def initialize(options, workers, runner)
8
+ @options = options
9
+ @runner = runner
10
+ @workers = workers
11
+ end
12
+
13
+ def run(exit_when_done = true)
14
+ passed = false
15
+
16
+ begin
17
+ server = Server.start(@options)
18
+ @options.new_listener_list.before_starting_workers
19
+ @workers.start_all
20
+ begin
21
+ DeepTest.logger.debug "Loader Starting (#{$$})"
22
+ passed = @runner.process_work_units
23
+ ensure
24
+ shutdown(server)
25
+ end
26
+ ensure
27
+ DeepTest.logger.debug "ProcessOrchestrator: Stopping Server"
28
+ Server.stop
29
+ end
30
+
31
+ Kernel.exit(passed ? 0 : 1) if exit_when_done
32
+ end
33
+
34
+ def shutdown(server)
35
+ DeepTest.logger.debug "ProcessOrchestrator: Shutting Down"
36
+ server.done_with_work
37
+
38
+ first_exception = $!
39
+ begin
40
+ DeepTest.logger.debug "ProcessOrchestrator: Stopping Workers"
41
+ @workers.stop_all
42
+ rescue DRb::DRbConnError
43
+ # Workers must have already stopped
44
+ rescue Exception => e
45
+ raise first_exception || e
46
+ end
47
+ end
48
+ end
49
+ end
@@ -1,8 +1,7 @@
1
1
  require "socket"
2
- require "base64"
3
2
 
3
+ require File.dirname(__FILE__) + "/option"
4
4
  require File.dirname(__FILE__) + "/options"
5
- require File.dirname(__FILE__) + "/cpu_info"
6
5
  require File.dirname(__FILE__) + "/test_task"
7
6
  require File.dirname(__FILE__) + "/rspec_detector"
8
7
 
@@ -10,4 +9,3 @@ DeepTest::RSpecDetector.if_rspec_available do
10
9
  require 'spec/rake/spectask'
11
10
  require File.dirname(__FILE__) + "/spec/extensions/spec_task"
12
11
  end
13
-
@@ -1,7 +1,7 @@
1
1
  module DeepTest
2
2
  class ResultReader
3
- def initialize(central_command)
4
- @central_command = central_command
3
+ def initialize(blackboard)
4
+ @blackboard = blackboard
5
5
  end
6
6
 
7
7
  def read(original_work_units_by_id)
@@ -11,10 +11,10 @@ module DeepTest
11
11
  begin
12
12
  until errors == work_units_by_id.size
13
13
  Thread.pass
14
- result = @central_command.take_result
14
+ result = @blackboard.take_result
15
15
  next if result.nil?
16
16
 
17
- if Agent::Error === result
17
+ if Worker::Error === result
18
18
  puts result
19
19
  errors += 1
20
20
  else
@@ -26,12 +26,8 @@ module DeepTest
26
26
  yield [work_unit, result]
27
27
  end
28
28
  end
29
- rescue CentralCommand::NoAgentsRunningError
30
- FailureMessage.show "DeepTest Agents Are Not Running", <<-end_msg
31
- DeepTest's test running agents have not contacted the
32
- server to indicate they are still running.
33
- Shutting down the test run on the assumption that they have died.
34
- end_msg
29
+ rescue Server::ResultOverdueError
30
+ DeepTest.logger.error("Results are overdue from server, ending run")
35
31
  end
36
32
 
37
33
  work_units_by_id
@@ -5,7 +5,7 @@ module DeepTest
5
5
  require 'spec/version'
6
6
  if ::Spec::VERSION::MAJOR == 1 &&
7
7
  ::Spec::VERSION::MINOR == 1 &&
8
- ::Spec::VERSION::TINY >= 8
8
+ ::Spec::VERSION::TINY == 8
9
9
  yield
10
10
  else
11
11
  require 'spec/rake/spectask'
@@ -0,0 +1,75 @@
1
+ module DeepTest
2
+ class Server
3
+ def self.start(options)
4
+ server = new(options)
5
+ DRb.start_service("druby://0.0.0.0:#{options.server_port}", server)
6
+ DeepTest.logger.info "Started DeepTest service at #{DRb.uri}"
7
+ server
8
+ end
9
+
10
+ def self.stop
11
+ DRb.stop_service
12
+ end
13
+
14
+ def self.remote_reference(address, port)
15
+ DRb.start_service
16
+ blackboard = DRbObject.new_with_uri("druby://#{address}:#{port}")
17
+ DeepTest.logger.debug "Connecting to DeepTest server at #{blackboard.__drburi}"
18
+ blackboard
19
+ end
20
+
21
+ def initialize(options)
22
+ @options = options
23
+ @work_queue = Queue.new
24
+ @result_queue = Queue.new
25
+
26
+ if Metrics::Gatherer.enabled?
27
+ require File.dirname(__FILE__) + "/metrics/queue_lock_wait_time_measurement"
28
+ @work_queue.extend Metrics::QueueLockWaitTimeMeasurement
29
+ @result_queue.extend Metrics::QueueLockWaitTimeMeasurement
30
+ Metrics::Gatherer.section("server queue lock wait times") do |s|
31
+ s.measurement("work queue total pop wait time", @work_queue.total_pop_time)
32
+ s.measurement("work queue total push wait time", @work_queue.total_push_time)
33
+ s.measurement("result queue total pop wait time", @result_queue.total_pop_time)
34
+ s.measurement("result queue total push wait time", @result_queue.total_push_time)
35
+ end
36
+ end
37
+ end
38
+
39
+ def done_with_work
40
+ @done_with_work = true
41
+ end
42
+
43
+ def take_result
44
+ Timeout.timeout(@options.timeout_in_seconds, ResultOverdueError) do
45
+ @result_queue.pop
46
+ end
47
+ end
48
+
49
+ def take_work
50
+ raise NoWorkUnitsRemainingError if @done_with_work
51
+
52
+ @work_queue.pop(true)
53
+ rescue ThreadError => e
54
+ if e.message == "queue empty"
55
+ raise NoWorkUnitsAvailableError
56
+ else
57
+ raise
58
+ end
59
+ end
60
+
61
+ def write_result(result)
62
+ @result_queue.push result
63
+ nil
64
+ end
65
+
66
+ def write_work(work_unit)
67
+ @work_queue.push work_unit
68
+ nil
69
+ end
70
+
71
+ class NoWorkUnitsAvailableError < StandardError; end
72
+ class NoWorkUnitsRemainingError < StandardError; end
73
+ class ResultOverdueError < StandardError; end
74
+ end
75
+ end
@@ -1,10 +1,5 @@
1
1
  require 'rubygems'
2
2
  require 'spec/runner/example_group_runner'
3
- if ::Spec::VERSION::MAJOR == 1 &&
4
- ::Spec::VERSION::MINOR == 1 &&
5
- ::Spec::VERSION::TINY >= 12
6
- require 'spec/example/before_and_after_hooks'
7
- end
8
3
  require 'spec/example/example_group_methods'
9
4
  require 'spec/rake/spectask'
10
5
 
@@ -12,6 +7,7 @@ require File.dirname(__FILE__) + "/spec/extensions/example_group_methods"
12
7
  require File.dirname(__FILE__) + "/spec/extensions/example_methods"
13
8
  require File.dirname(__FILE__) + "/spec/extensions/spec_task"
14
9
  require File.dirname(__FILE__) + "/spec/extensions/options"
10
+ require File.dirname(__FILE__) + "/spec/extensions/reporter"
15
11
  require File.dirname(__FILE__) + "/spec/runner"
16
12
  require File.dirname(__FILE__) + "/spec/work_unit"
17
13
  require File.dirname(__FILE__) + "/spec/work_result"
@@ -2,13 +2,7 @@ module Spec
2
2
  module Example
3
3
  module ExampleMethods
4
4
  def identifier
5
- if ::Spec::VERSION::MAJOR == 1 &&
6
- ::Spec::VERSION::MINOR == 1 &&
7
- ::Spec::VERSION::TINY >= 12
8
- file, line = eval("caller", @_implementation).first.split(/:/)
9
- else
10
- file, line = implementation_backtrace.first.split(/:/)
11
- end
5
+ file, line = implementation_backtrace.first.split(/:/)
12
6
  Identifier.new(file, line.to_i, self.class.description, description)
13
7
  end
14
8
 
@@ -0,0 +1,29 @@
1
+ require 'spec/runner/reporter'
2
+ module Spec
3
+ module Runner
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, error.message)
12
+ else
13
+ example_failed(example, error)
14
+ end
15
+ end
16
+
17
+ def failure(example, error)
18
+ backtrace_tweaker.tweak_backtrace(error)
19
+ example_name = "#{example.class.description} #{example.description}"
20
+ failure = Failure.new(example, error)
21
+ @failures << failure
22
+ formatters.each do |f|
23
+ f.example_failed(example, @failures.length, failure)
24
+ end
25
+ end
26
+ alias_method :example_failed, :failure
27
+ end
28
+ end
29
+ end
@@ -1,11 +1,10 @@
1
- require File.dirname(__FILE__) + "/../../lib_root"
2
-
3
1
  module Spec
4
2
  module Rake
5
3
  class SpecTask
6
4
  def deep_test(options)
7
5
  deep_test_options = DeepTest::Options.new(options)
8
- deep_test_path = File.expand_path(DeepTest::LIB_ROOT + "/deep_test")
6
+ deep_test_path = File.expand_path(File.dirname(__FILE__) +
7
+ "/../../../deep_test")
9
8
  @deep_test_spec_opts = [
10
9
  "--require #{deep_test_path}",
11
10
  "--runner 'DeepTest::Spec::Runner:#{deep_test_options.to_command_line}'"
@@ -1,66 +1,51 @@
1
1
  module DeepTest
2
2
  module Spec
3
3
  class Runner < ::Spec::Runner::ExampleGroupRunner
4
- def initialize(options, deep_test_options)
4
+ def initialize(options, deep_test_options, blackboard = nil)
5
5
  super(options)
6
- if ::Spec::VERSION::MAJOR == 1 &&
7
- ::Spec::VERSION::MINOR == 1 &&
8
- ::Spec::VERSION::TINY >= 12
9
- @runner_options = options # added to make work with 1.1.12
10
- end
11
6
  @deep_test_options = DeepTest::Options.from_command_line(deep_test_options)
7
+ DeepTest.init(@deep_test_options)
8
+ @blackboard = blackboard
9
+ @workers = @deep_test_options.new_workers
12
10
  end
13
11
 
14
- def main
15
- @main ||= Main.new @deep_test_options, @deep_test_options.new_deployment, self
16
- end
17
-
18
- def central_command
19
- # Can't create central_command as default argument to initialize
20
- # because Main hasn't been invoked at
12
+ def blackboard
13
+ # Can't create blackboard as default argument to initialize
14
+ # because ProcessOrchestrator hasn't been invoked at
21
15
  # instantiation time
22
- @central_command ||= main.central_command
16
+ @blackboard ||= @deep_test_options.server
23
17
  end
24
18
 
25
19
  def load_files(files)
26
- main.load_files files
20
+ @workers.load_files files
27
21
  end
28
22
 
29
23
  def run
30
- main.run
24
+ ProcessOrchestrator.run(@deep_test_options, @workers, self)
31
25
  end
32
26
 
33
- def process_work_units(central_command)
27
+ def process_work_units
34
28
  prepare
35
29
 
36
- examples = (example_groups.map do |g|
37
- if ::Spec::VERSION::MAJOR == 1 &&
38
- ::Spec::VERSION::MINOR == 1 &&
39
- ::Spec::VERSION::TINY >= 12
40
- g.send(:examples_to_run, @runner_options) # added @runner_options to make wiork with 1.1.12
41
- else
42
- g.send(:examples_to_run)
43
- end
44
- end).flatten
30
+ examples = example_groups.map {|g| g.send(:examples_to_run)}.flatten
45
31
  examples_by_location = {}
46
32
  examples.each do |example|
47
33
  raise "duplicate example: #{example.identifier}" if examples_by_location[example.identifier]
48
34
  examples_by_location[example.identifier] = example
49
- central_command.write_work Spec::WorkUnit.new(example.identifier)
35
+ blackboard.write_work Spec::WorkUnit.new(example.identifier)
50
36
  end
51
37
 
52
38
  success = true
53
39
 
54
- missing_examples = ResultReader.new(central_command).read(examples_by_location) do |example, result|
40
+ missing_exmaples = ResultReader.new(blackboard).read(examples_by_location) do |example, result|
55
41
  @options.reporter.example_finished(example, result.error)
56
42
  success &= result.success?
57
43
  end
58
44
 
59
- success &= missing_examples.empty?
45
+ success &= missing_exmaples.empty?
60
46
 
61
- if missing_examples.any?
62
- @options.reporter.example_finished(examples_by_location[missing_examples.keys.first],
63
- IncompleteTestRunError.new(missing_examples.size))
47
+ missing_exmaples.each do |identifier, example|
48
+ @options.reporter.example_finished(example, WorkUnitNeverReceivedError.new)
64
49
  end
65
50
 
66
51
  success