flatware 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -7,7 +7,7 @@ Flatware is a distributed cucumber runner.
7
7
 
8
8
  == Requirements
9
9
 
10
- * ZeroMQ ~> 2.1
10
+ * ZeroMQ > 2.1
11
11
 
12
12
  == Installation
13
13
 
data/lib/flatware.rb CHANGED
@@ -2,18 +2,19 @@ require 'forwardable'
2
2
  require 'ffi-rzmq'
3
3
 
4
4
  module Flatware
5
- autoload :CLI, 'flatware/cli'
6
- autoload :Cucumber, 'flatware/cucumber'
7
- autoload :Dispatcher, 'flatware/dispatcher'
8
- autoload :Fireable, 'flatware/fireable'
9
- autoload :ProcessorInfo, 'flatware/processor_info'
10
- autoload :Result, 'flatware/result'
11
- autoload :ScenarioResult, 'flatware/scenario_result'
12
- autoload :Sink, 'flatware/sink'
13
- autoload :StepResult, 'flatware/step_result'
14
- autoload :Summary, 'flatware/summary'
15
- autoload :Worker, 'flatware/worker'
16
- autoload :ScenarioDecorator, 'flatware/scenario_decorator'
5
+ require 'flatware/checkpoint_handler'
6
+ require 'flatware/processor_info'
7
+ require 'flatware/cli'
8
+ require 'flatware/cucumber'
9
+ require 'flatware/dispatcher'
10
+ require 'flatware/fireable'
11
+ require 'flatware/result'
12
+ require 'flatware/scenario_result'
13
+ require 'flatware/sink'
14
+ require 'flatware/step_result'
15
+ require 'flatware/summary'
16
+ require 'flatware/worker'
17
+ require 'flatware/scenario_decorator'
17
18
 
18
19
  Error = Class.new StandardError
19
20
 
@@ -66,7 +67,7 @@ module Flatware
66
67
  def_delegators :s, :bind, :connect, :setsockopt
67
68
  def send(message)
68
69
  result = s.send_string(Marshal.dump(message))
69
- raise Error, ZMQ::Util.error_string, caller unless result == 0
70
+ raise Error, ZMQ::Util.error_string, caller if result == -1
70
71
  message
71
72
  end
72
73
 
@@ -78,7 +79,7 @@ module Flatware
78
79
  def recv
79
80
  message = ''
80
81
  result = s.recv_string(message)
81
- raise Error, ZMQ::Util.error_string, caller unless result == 0
82
+ raise Error, ZMQ::Util.error_string, caller if result == -1
82
83
  Marshal.load message
83
84
  end
84
85
  end
@@ -1,3 +1,4 @@
1
+ require 'flatware/scenario_result'
1
2
  module Flatware
2
3
  class Checkpoint
3
4
  attr_reader :steps, :scenarios
@@ -5,6 +6,10 @@ module Flatware
5
6
  @steps, @scenarios = serialize_steps(steps), serialize_scenarios(scenarios)
6
7
  end
7
8
 
9
+ def failures?
10
+ scenarios.any? &:failed?
11
+ end
12
+
8
13
  private
9
14
 
10
15
  def serialize_steps(steps)
@@ -0,0 +1,27 @@
1
+ module Flatware
2
+ class CheckpointHandler
3
+ def initialize(out, fails_fast)
4
+ @fail_fast = fails_fast
5
+ @out = out
6
+ @checkpoints = []
7
+ end
8
+
9
+ def handle!(checkpoint)
10
+ @checkpoints << checkpoint
11
+ if checkpoint.failures? && @fail_fast
12
+ Fireable::kill # Killing everybody
13
+ @done = true
14
+ end
15
+ end
16
+
17
+ def done?
18
+ @done
19
+ end
20
+
21
+ def summarize
22
+ steps = @checkpoints.map(&:steps).flatten
23
+ scenarios = @checkpoints.map(&:scenarios).flatten
24
+ Summary.new(steps, scenarios, @out).summarize
25
+ end
26
+ end
27
+ end
data/lib/flatware/cli.rb CHANGED
@@ -15,11 +15,12 @@ module Flatware
15
15
  default_task :default
16
16
  worker_option
17
17
  desc "default [FLATWARE_OPTS]", "parallelizes cucumber with default arguments"
18
- def default
18
+ def default(*)
19
19
  invoke :cucumber
20
20
  end
21
21
 
22
22
  worker_option
23
+ method_option 'fail-fast', type: :boolean, default: false, desc: "Abort the run on first failure"
23
24
  desc "[FLATWARE_OPTS] cucumber [CUCUMBER_ARGS]", "parallelizes cucumber with custom arguments"
24
25
  def cucumber(*)
25
26
  Flatware.verbose = options[:log]
@@ -34,7 +35,7 @@ module Flatware
34
35
  end
35
36
  log "bossman"
36
37
  $0 = 'flatware sink'
37
- Sink.start_server jobs
38
+ Sink.start_server jobs, $stdout, $stderr, options['fail-fast']
38
39
  Process.waitall
39
40
  end
40
41
 
data/lib/flatware/sink.rb CHANGED
@@ -12,8 +12,8 @@ module Flatware
12
12
  push job
13
13
  end
14
14
 
15
- def start_server(jobs=Cucumber.jobs, out_stream=$stdout, error_stream=$stderr)
16
- Server.new(jobs, out_stream, error_stream).start
15
+ def start_server(*args)
16
+ Server.new(*args).start
17
17
  end
18
18
 
19
19
  def client
@@ -22,13 +22,13 @@ module Flatware
22
22
  end
23
23
 
24
24
  class Server
25
- def initialize(jobs, out, error)
26
- @jobs, @out, @error = jobs, out, error
25
+ def initialize(jobs, out=$stdout, error=$stderr, fail_fast=false)
26
+ @jobs, @out, @error, @fail_fast = jobs, out, error, fail_fast
27
27
  end
28
28
 
29
29
  def start
30
30
  trap 'INT' do
31
- summarize
31
+ checkpoint_handler.summarize
32
32
  summarize_remaining
33
33
  exit 1
34
34
  end
@@ -37,28 +37,36 @@ module Flatware
37
37
  Flatware.close
38
38
  end
39
39
 
40
+ def checkpoint_handler
41
+ @checkpoint_handler ||= CheckpointHandler.new(out, fail_fast?)
42
+ end
43
+
40
44
  def listen
41
45
  until done?
42
- message = socket.recv
43
- case (result = message)
46
+ result = socket.recv
47
+ case result
44
48
  when Result
45
49
  print result.progress
46
50
  when Checkpoint
47
- checkpoints << result
51
+ checkpoint_handler.handle! result
48
52
  when Job
49
53
  completed_jobs << result
50
54
  log "COMPLETED SCENARIO"
51
55
  else
52
- log "i don't know that message, bro.", message
56
+ log "i don't know that message, bro.", result
53
57
  end
54
58
  end
55
- summarize
59
+ checkpoint_handler.summarize
56
60
  rescue Error => e
57
61
  raise unless e.message == "Interrupted system call"
58
62
  end
59
63
 
60
64
  private
61
65
 
66
+ def fail_fast?
67
+ @fail_fast
68
+ end
69
+
62
70
  attr_reader :out, :jobs
63
71
 
64
72
  def print(*args)
@@ -69,12 +77,6 @@ module Flatware
69
77
  out.puts *args
70
78
  end
71
79
 
72
- def summarize
73
- steps = checkpoints.map(&:steps).flatten
74
- scenarios = checkpoints.map(&:scenarios).flatten
75
- Summary.new(steps, scenarios, out).summarize
76
- end
77
-
78
80
  def summarize_remaining
79
81
  return if remaining_work.empty?
80
82
  puts
@@ -94,17 +96,13 @@ module Flatware
94
96
  Flatware::Fireable::kill
95
97
  end
96
98
 
97
- def checkpoints
98
- @checkpoints ||= []
99
- end
100
-
101
99
  def completed_jobs
102
100
  @completed_jobs ||= []
103
101
  end
104
102
 
105
103
  def done?
106
104
  log remaining_work
107
- remaining_work.empty?
105
+ remaining_work.empty? || checkpoint_handler.done?
108
106
  end
109
107
 
110
108
  def remaining_work
@@ -1,3 +1,3 @@
1
1
  module Flatware
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flatware
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-22 00:00:00.000000000 Z
12
+ date: 2013-07-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi-rzmq
@@ -48,17 +48,17 @@ dependencies:
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
51
- - - ~>
51
+ - - ! '>='
52
52
  - !ruby/object:Gem::Version
53
- version: 1.2.0
53
+ version: 1.3.0
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
- - - ~>
59
+ - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
- version: 1.2.0
61
+ version: 1.3.0
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: aruba
64
64
  requirement: !ruby/object:Gem::Requirement
@@ -118,6 +118,7 @@ extra_rdoc_files:
118
118
  files:
119
119
  - lib/flatware.rb
120
120
  - lib/flatware/checkpoint.rb
121
+ - lib/flatware/checkpoint_handler.rb
121
122
  - lib/flatware/cli.rb
122
123
  - lib/flatware/cucumber.rb
123
124
  - lib/flatware/cucumber/formatter.rb
@@ -157,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
158
  version: '0'
158
159
  requirements: []
159
160
  rubyforge_project:
160
- rubygems_version: 1.8.25
161
+ rubygems_version: 1.8.23
161
162
  signing_key:
162
163
  specification_version: 3
163
164
  summary: A distributed cucumber runner