specjour 0.3.0.rc2 → 0.3.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
data/History.markdown CHANGED
@@ -1,7 +1,16 @@
1
1
  History
2
2
  =======
3
3
 
4
- ## 0.3.0.rc2 / thor
4
+ ## 0.3.0.rc3 / 2010-07-27
5
+
6
+ * [fixed] Cucumber prints elapsed time
7
+
8
+ * [added] Print hostname for each hostname (closes gh-8)
9
+
10
+ * [added] Rspec2 support
11
+
12
+
13
+ ## 0.3.0.rc2 / 2010-07-14
5
14
 
6
15
  * [fixed] Cucumber compatibility with 0.8.5
7
16
 
data/README.markdown CHANGED
@@ -2,17 +2,10 @@
2
2
 
3
3
  ## FUCK SETI. Run specs with your spare CPU cycles.
4
4
 
5
- _Distribute your spec suite amongst your LAN via Bonjour._
6
-
7
5
  1. Spin up a manager on each machine that can run your specs.
8
6
  2. Start a dispatcher in your project directory.
9
7
  3. Say farewell to your long coffee breaks.
10
8
 
11
- ## Requirements
12
- * Bonjour or DNSSD (the capability and the gem)
13
- * Rsync (system command used)
14
- * Rspec (officially v1.3.0)
15
-
16
9
  ## Installation
17
10
  gem install specjour
18
11
 
data/Rakefile CHANGED
@@ -11,8 +11,7 @@ begin
11
11
  gem.homepage = "http://github.com/sandro/specjour"
12
12
  gem.authors = ["Sandro Turriate"]
13
13
  gem.add_dependency "dnssd", "1.3.1"
14
- gem.add_dependency "rspec"
15
- gem.add_dependency "thor", "0.13.6"
14
+ gem.add_dependency "thor", "~>0.13.4"
16
15
  gem.add_development_dependency "rspec", "1.3.0"
17
16
  gem.add_development_dependency "rr", ">=0.10.11"
18
17
  gem.add_development_dependency "yard", ">=0.5.3"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0.rc2
1
+ 0.3.0.rc3
@@ -52,7 +52,7 @@ module Specjour
52
52
  end
53
53
  end
54
54
 
55
- def puts(arg)
55
+ def puts(arg='')
56
56
  print(arg << "\n")
57
57
  end
58
58
 
@@ -78,8 +78,10 @@ module Specjour
78
78
  def will_reconnect(&block)
79
79
  block.call
80
80
  rescue SystemCallError => error
81
- reconnect
82
- retry
81
+ unless Specjour.interrupted?
82
+ reconnect
83
+ retry
84
+ end
83
85
  end
84
86
  end
85
87
  end
@@ -1,8 +1,14 @@
1
1
  module Specjour
2
2
  module DbScrub
3
3
  require 'rake'
4
- load 'tasks/misc.rake'
5
- load 'tasks/databases.rake'
4
+ if defined?(Rails) && Rails.version =~ /^3/
5
+ task(:environment) {}
6
+ load 'rails/tasks/misc.rake'
7
+ load 'active_record/railties/databases.rake'
8
+ else
9
+ load 'tasks/misc.rake'
10
+ load 'tasks/databases.rake'
11
+ end
6
12
 
7
13
  extend self
8
14
 
@@ -4,11 +4,6 @@ module Specjour
4
4
  Thread.abort_on_exception = true
5
5
  include SocketHelper
6
6
 
7
- class << self
8
- attr_accessor :interrupted
9
- alias interrupted? interrupted
10
- end
11
-
12
7
  attr_reader :project_alias, :managers, :manager_threads, :hosts, :options, :all_tests
13
8
  attr_accessor :worker_size, :project_path
14
9
 
@@ -26,7 +21,6 @@ module Specjour
26
21
  gather_managers
27
22
  rsync_daemon.start
28
23
  dispatch_work
29
- Signal.trap('INT') { Dispatcher.interrupted = true; exit 1 }
30
24
  printer.join if dispatching_tests?
31
25
  wait_on_managers
32
26
  exit printer.exit_status
@@ -73,8 +67,10 @@ module Specjour
73
67
  end
74
68
 
75
69
  def dispatch_work
76
- puts "Managers found: #{managers.size}"
77
70
  puts "Workers found: #{worker_size}"
71
+ managers.each do |manager|
72
+ puts "#{manager.hostname} (#{manager.worker_size})"
73
+ end
78
74
  printer.worker_size = worker_size
79
75
  command_managers(true) { |m| m.dispatch }
80
76
  end
@@ -109,7 +109,7 @@ module Specjour
109
109
  end
110
110
 
111
111
  def warn_if_workers_deserted
112
- if disconnections != completed_workers && !Dispatcher.interrupted?
112
+ if disconnections != completed_workers && !Specjour.interrupted?
113
113
  puts
114
114
  puts workers_deserted_message
115
115
  end
@@ -0,0 +1,15 @@
1
+ module Specjour::Rspec
2
+ class MarshalableException
3
+ attr_accessor :message, :backtrace, :class_name
4
+
5
+ def initialize(exception)
6
+ self.class_name = exception.class.name
7
+ self.message = exception.message
8
+ self.backtrace = exception.backtrace
9
+ end
10
+
11
+ def class
12
+ @class ||= OpenStruct.new :name => class_name
13
+ end
14
+ end
15
+ end
@@ -18,18 +18,4 @@ module Specjour
18
18
  end
19
19
  end
20
20
  end
21
-
22
- class MarshalableException
23
- attr_accessor :message, :backtrace, :class_name
24
-
25
- def initialize(exception)
26
- self.class_name = exception.class.name
27
- self.message = exception.message
28
- self.backtrace = exception.backtrace
29
- end
30
-
31
- def class
32
- @class ||= OpenStruct.new :name => class_name
33
- end
34
- end
35
21
  end
@@ -0,0 +1,11 @@
1
+ module Specjour::Rspec::Runner
2
+ def self.run(spec, output)
3
+ options = Spec::Runner::OptionParser.parse(
4
+ ['--format=Specjour::Rspec::DistributedFormatter', spec],
5
+ $stderr,
6
+ output
7
+ )
8
+ Spec::Runner.use options
9
+ options.run_examples
10
+ end
11
+ end
@@ -1,10 +1,32 @@
1
1
  module Specjour
2
2
  module Rspec
3
- require 'spec'
4
- require 'spec/runner/formatter/base_text_formatter'
3
+ def self.load_rspec1
4
+ require 'spec'
5
+ require 'spec/runner/formatter/base_text_formatter'
6
+
7
+ require 'specjour/rspec/distributed_formatter'
8
+ require 'specjour/rspec/final_report'
9
+ require 'specjour/rspec/marshalable_exception'
10
+ require 'specjour/rspec/preloader'
11
+ require 'specjour/rspec/runner'
12
+ end
13
+
14
+ def self.load_rspec2
15
+ require 'rspec/core'
16
+ ::Rspec::Core::Runner.disable_autorun!
17
+
18
+ require 'specjour/rspec/marshalable_exception'
19
+ require 'specjour/rspec/preloader'
20
+ require 'specjour/rspec2/distributed_formatter'
21
+ require 'specjour/rspec2/final_report'
22
+ require 'specjour/rspec2/runner'
23
+ end
24
+
25
+ begin
26
+ load_rspec2
27
+ rescue LoadError
28
+ load_rspec1
29
+ end
5
30
 
6
- require 'specjour/rspec/distributed_formatter'
7
- require 'specjour/rspec/final_report'
8
- require 'specjour/rspec/preloader'
9
31
  end
10
32
  end
@@ -0,0 +1,38 @@
1
+ module Specjour::Rspec
2
+ class DistributedFormatter < ::RSpec::Core::Formatters::ProgressFormatter
3
+
4
+ def metadata_for_examples
5
+ examples.map do |example|
6
+ metadata = example.metadata
7
+ {
8
+ :execution_result => marshalable_execution_result(example.execution_result),
9
+ :description => metadata[:description],
10
+ :file_path => metadata[:file_path],
11
+ :full_description => metadata[:full_description],
12
+ :line_number => metadata[:line_number],
13
+ :location => metadata[:location]
14
+ }
15
+ end
16
+ end
17
+
18
+ def noop
19
+ end
20
+ alias dump_pending noop
21
+ alias dump_failures noop
22
+ alias start_dump noop
23
+
24
+ def dump_summary(*args)
25
+ output.send_message :rspec_summary=, metadata_for_examples
26
+ end
27
+
28
+ protected
29
+
30
+ def marshalable_execution_result(execution_result)
31
+ if exception = execution_result[:exception_encountered]
32
+ execution_result[:exception_encountered] = MarshalableException.new(exception)
33
+ end
34
+ execution_result
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,60 @@
1
+ module Specjour::Rspec
2
+ class FinalReport
3
+ attr_reader :examples
4
+ attr_reader :duration
5
+
6
+ def initialize
7
+ @examples = []
8
+ @duration = 0.0
9
+ end
10
+
11
+ def add(data)
12
+ if data.respond_to?(:has_key?) && data.has_key?(:duration)
13
+ self.duration = data[:duration]
14
+ else
15
+ metadata_for_examples(data)
16
+ end
17
+ end
18
+
19
+ def duration=(value)
20
+ @duration = value.to_f if duration < value.to_f
21
+ end
22
+
23
+ def exit_status
24
+ formatter.failed_examples.empty?
25
+ end
26
+
27
+ def metadata_for_examples(metadata_collection)
28
+ examples.concat(
29
+ metadata_collection.map do |partial_metadata|
30
+ example = ::Rspec::Core::Example.allocate
31
+ metadata = ::Rspec::Core::Metadata.new
32
+ metadata.merge! partial_metadata
33
+ example.instance_variable_set(:@metadata, metadata)
34
+ example
35
+ end
36
+ )
37
+ end
38
+
39
+ def formatter
40
+ @formatter ||= new_progress_formatter
41
+ end
42
+
43
+ def summarize
44
+ if examples.size > 0
45
+ formatter.dump_summary(duration, formatter.example_count, formatter.failure_count, formatter.pending_count)
46
+ formatter.dump_pending
47
+ formatter.dump_failures
48
+ end
49
+ end
50
+
51
+ protected
52
+ def new_progress_formatter
53
+ new_formatter = ::Rspec::Core::Formatters::ProgressFormatter.new($stdout)
54
+ new_formatter.instance_variable_set(:@examples, examples)
55
+ new_formatter.instance_variable_set(:@example_count, examples.size)
56
+ Rspec.configuration.color_enabled = true
57
+ new_formatter
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,12 @@
1
+ module Specjour::Rspec::Runner
2
+ def self.run(spec, output)
3
+ reset
4
+ options = ['--format=Specjour::Rspec::DistributedFormatter', spec]
5
+ ::Rspec::Core::Runner.run options, $stderr, output
6
+ end
7
+
8
+ def self.reset
9
+ ::Rspec.instance_variable_set(:@world, nil)
10
+ ::Rspec.configuration.instance_variable_set(:@formatter, nil)
11
+ end
12
+ end
@@ -34,15 +34,16 @@ module Specjour
34
34
  def run_tests
35
35
  load_app
36
36
  Configuration.after_fork.call
37
- run_time = 0
37
+ run_times = Hash.new(0)
38
38
 
39
39
  while test = connection.next_test
40
40
  time = Benchmark.realtime do
41
41
  run_test test
42
42
  end
43
- run_time += time if test =~ /_spec\.rb$/
43
+ run_times[test_type(test)] += time
44
44
  end
45
- connection.send_message(:rspec_summary=, {:duration => sprintf("%6f", run_time)})
45
+
46
+ send_run_times(run_times)
46
47
  connection.send_message(:done)
47
48
  connection.disconnect
48
49
  end
@@ -60,6 +61,8 @@ module Specjour
60
61
  def load_app
61
62
  Rspec::Preloader.load(preload_spec) if preload_spec
62
63
  Cucumber::Preloader.load(preload_feature) if preload_feature
64
+ rescue StandardError => exception
65
+ $stderr.puts "Caught exception: #{exception.class} #{exception.message}\nProceeding..."
63
66
  end
64
67
 
65
68
  def printer_connection
@@ -74,7 +77,7 @@ module Specjour
74
77
 
75
78
  def run_test(test)
76
79
  print_status(test)
77
- if test =~ /\.feature$/
80
+ if test_type(test) == :cucumber
78
81
  run_feature test
79
82
  else
80
83
  run_spec test
@@ -87,18 +90,22 @@ module Specjour
87
90
  end
88
91
 
89
92
  def run_spec(spec)
90
- options = Spec::Runner::OptionParser.parse(
91
- ['--format=Specjour::Rspec::DistributedFormatter', spec],
92
- $stderr,
93
- connection
94
- )
95
- Spec::Runner.use options
96
- options.run_examples
93
+ Specjour::Rspec::Runner.run(spec, connection)
94
+ end
95
+
96
+ def send_run_times(run_times)
97
+ [:rspec, :cucumber].each do |type|
98
+ connection.send_message(:"#{type}_summary=", {:duration => sprintf("%6f", run_times[type])})
99
+ end
100
+ end
101
+
102
+ def test_type(test)
103
+ test =~ /\.feature$/ ? :cucumber : :rspec
97
104
  end
98
105
 
99
106
  def set_env_variables
100
- ENV['RSPEC_COLOR'] = 'true'
101
- ENV['TEST_ENV_NUMBER'] = number.to_s
107
+ ENV['RSPEC_COLOR'] ||= 'true'
108
+ ENV['TEST_ENV_NUMBER'] ||= number.to_s
102
109
  end
103
110
  end
104
111
  end
data/lib/specjour.rb CHANGED
@@ -28,9 +28,14 @@ module Specjour
28
28
  autoload :Cucumber, 'specjour/cucumber'
29
29
  autoload :Rspec, 'specjour/rspec'
30
30
 
31
- VERSION = "0.3.0.rc2".freeze
31
+ VERSION = "0.3.0.rc3".freeze
32
32
  HOOKS_PATH = ".specjour/hooks.rb"
33
33
 
34
+ class << self
35
+ attr_accessor :interrupted
36
+ alias interrupted? interrupted
37
+ end
38
+
34
39
  def self.logger
35
40
  @logger ||= new_logger
36
41
  end
@@ -53,4 +58,6 @@ module Specjour
53
58
  PROGRAM_NAME = $PROGRAM_NAME # keep a reference of the original program name
54
59
 
55
60
  GC.copy_on_write_friendly = true if GC.respond_to?(:copy_on_write_friendly=)
61
+
62
+ Signal.trap('INT') { Specjour.interrupted = true; exit 1 }
56
63
  end
data/specjour.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{specjour}
8
- s.version = "0.3.0.rc2"
8
+ s.version = "0.3.0.rc3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Sandro Turriate"]
12
- s.date = %q{2010-07-14}
12
+ s.date = %q{2010-07-27}
13
13
  s.default_executable = %q{specjour}
14
14
  s.description = %q{Distribute your spec suite amongst your LAN via Bonjour.}
15
15
  s.email = %q{sandro.turriate@gmail.com}
@@ -45,8 +45,13 @@ Gem::Specification.new do |s|
45
45
  "lib/specjour/rspec.rb",
46
46
  "lib/specjour/rspec/distributed_formatter.rb",
47
47
  "lib/specjour/rspec/final_report.rb",
48
+ "lib/specjour/rspec/marshalable_exception.rb",
48
49
  "lib/specjour/rspec/marshalable_rspec_failure.rb",
49
50
  "lib/specjour/rspec/preloader.rb",
51
+ "lib/specjour/rspec/runner.rb",
52
+ "lib/specjour/rspec2/distributed_formatter.rb",
53
+ "lib/specjour/rspec2/final_report.rb",
54
+ "lib/specjour/rspec2/runner.rb",
50
55
  "lib/specjour/rsync_daemon.rb",
51
56
  "lib/specjour/socket_helper.rb",
52
57
  "lib/specjour/worker.rb",
@@ -83,23 +88,20 @@ Gem::Specification.new do |s|
83
88
 
84
89
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
85
90
  s.add_runtime_dependency(%q<dnssd>, ["= 1.3.1"])
86
- s.add_runtime_dependency(%q<rspec>, [">= 0"])
87
- s.add_runtime_dependency(%q<thor>, ["= 0.13.6"])
91
+ s.add_runtime_dependency(%q<thor>, ["~> 0.13.4"])
88
92
  s.add_development_dependency(%q<rspec>, ["= 1.3.0"])
89
93
  s.add_development_dependency(%q<rr>, [">= 0.10.11"])
90
94
  s.add_development_dependency(%q<yard>, [">= 0.5.3"])
91
95
  else
92
96
  s.add_dependency(%q<dnssd>, ["= 1.3.1"])
93
- s.add_dependency(%q<rspec>, [">= 0"])
94
- s.add_dependency(%q<thor>, ["= 0.13.6"])
97
+ s.add_dependency(%q<thor>, ["~> 0.13.4"])
95
98
  s.add_dependency(%q<rspec>, ["= 1.3.0"])
96
99
  s.add_dependency(%q<rr>, [">= 0.10.11"])
97
100
  s.add_dependency(%q<yard>, [">= 0.5.3"])
98
101
  end
99
102
  else
100
103
  s.add_dependency(%q<dnssd>, ["= 1.3.1"])
101
- s.add_dependency(%q<rspec>, [">= 0"])
102
- s.add_dependency(%q<thor>, ["= 0.13.6"])
104
+ s.add_dependency(%q<thor>, ["~> 0.13.4"])
103
105
  s.add_dependency(%q<rspec>, ["= 1.3.0"])
104
106
  s.add_dependency(%q<rr>, [">= 0.10.11"])
105
107
  s.add_dependency(%q<yard>, [">= 0.5.3"])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: specjour
3
3
  version: !ruby/object:Gem::Version
4
- hash: 977940567
4
+ hash: 977940564
5
5
  prerelease: true
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
9
  - 0
10
- - rc2
11
- version: 0.3.0.rc2
10
+ - rc3
11
+ version: 0.3.0.rc3
12
12
  platform: ruby
13
13
  authors:
14
14
  - Sandro Turriate
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-07-14 00:00:00 -04:00
19
+ date: 2010-07-27 00:00:00 -04:00
20
20
  default_executable: specjour
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -36,39 +36,25 @@ dependencies:
36
36
  type: :runtime
37
37
  version_requirements: *id001
38
38
  - !ruby/object:Gem::Dependency
39
- name: rspec
39
+ name: thor
40
40
  prerelease: false
41
41
  requirement: &id002 !ruby/object:Gem::Requirement
42
42
  none: false
43
43
  requirements:
44
- - - ">="
44
+ - - ~>
45
45
  - !ruby/object:Gem::Version
46
- hash: 3
47
- segments:
48
- - 0
49
- version: "0"
50
- type: :runtime
51
- version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
53
- name: thor
54
- prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
56
- none: false
57
- requirements:
58
- - - "="
59
- - !ruby/object:Gem::Version
60
- hash: 39
46
+ hash: 35
61
47
  segments:
62
48
  - 0
63
49
  - 13
64
- - 6
65
- version: 0.13.6
50
+ - 4
51
+ version: 0.13.4
66
52
  type: :runtime
67
- version_requirements: *id003
53
+ version_requirements: *id002
68
54
  - !ruby/object:Gem::Dependency
69
55
  name: rspec
70
56
  prerelease: false
71
- requirement: &id004 !ruby/object:Gem::Requirement
57
+ requirement: &id003 !ruby/object:Gem::Requirement
72
58
  none: false
73
59
  requirements:
74
60
  - - "="
@@ -80,11 +66,11 @@ dependencies:
80
66
  - 0
81
67
  version: 1.3.0
82
68
  type: :development
83
- version_requirements: *id004
69
+ version_requirements: *id003
84
70
  - !ruby/object:Gem::Dependency
85
71
  name: rr
86
72
  prerelease: false
87
- requirement: &id005 !ruby/object:Gem::Requirement
73
+ requirement: &id004 !ruby/object:Gem::Requirement
88
74
  none: false
89
75
  requirements:
90
76
  - - ">="
@@ -96,11 +82,11 @@ dependencies:
96
82
  - 11
97
83
  version: 0.10.11
98
84
  type: :development
99
- version_requirements: *id005
85
+ version_requirements: *id004
100
86
  - !ruby/object:Gem::Dependency
101
87
  name: yard
102
88
  prerelease: false
103
- requirement: &id006 !ruby/object:Gem::Requirement
89
+ requirement: &id005 !ruby/object:Gem::Requirement
104
90
  none: false
105
91
  requirements:
106
92
  - - ">="
@@ -112,7 +98,7 @@ dependencies:
112
98
  - 3
113
99
  version: 0.5.3
114
100
  type: :development
115
- version_requirements: *id006
101
+ version_requirements: *id005
116
102
  description: Distribute your spec suite amongst your LAN via Bonjour.
117
103
  email: sandro.turriate@gmail.com
118
104
  executables:
@@ -149,8 +135,13 @@ files:
149
135
  - lib/specjour/rspec.rb
150
136
  - lib/specjour/rspec/distributed_formatter.rb
151
137
  - lib/specjour/rspec/final_report.rb
138
+ - lib/specjour/rspec/marshalable_exception.rb
152
139
  - lib/specjour/rspec/marshalable_rspec_failure.rb
153
140
  - lib/specjour/rspec/preloader.rb
141
+ - lib/specjour/rspec/runner.rb
142
+ - lib/specjour/rspec2/distributed_formatter.rb
143
+ - lib/specjour/rspec2/final_report.rb
144
+ - lib/specjour/rspec2/runner.rb
154
145
  - lib/specjour/rsync_daemon.rb
155
146
  - lib/specjour/socket_helper.rb
156
147
  - lib/specjour/worker.rb