jcukeforker 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 32563d887a984beb002a2661539769d5908beeb3
4
- data.tar.gz: 602298483da878759729ab39644dfae2058012d9
3
+ metadata.gz: 16336863494d6a228e277b0a66de9bcca02a1527
4
+ data.tar.gz: dba852dd02f74272edd6f4c645e21ff1906ec2b3
5
5
  SHA512:
6
- metadata.gz: f956f1cc6927646155a24209b2b796a058818a39ca038df79e7f4de673ea15803840a8bba9f638d6dd658c2a6c8c0f34b5a76bcd474321e50404561249d2345e
7
- data.tar.gz: 4245453e0c2a25cc5cfe430932cf499fbd4fbeb2ff6fa312c2724b380543b6981ab8eeb7f8cbd86c6c5771fb01a044a1b816ffd73efdbfc79d19c941fbc0d0f1
6
+ metadata.gz: 65c45703a692fd01c9b0a64985bb3ffd821f94a730dea820075fed343df2afa0e649e91d9fffb3df9f2674914be1d6f7b81b8d0dc0f401f0fc165b330f9a6ae1
7
+ data.tar.gz: 7fd90ad2eaa840999db8557bf50d890429dfe151c4b8fadfc05c8802d7e4389e73a7ad5911f73d9ef1d2e539504ff89dc82aef9f6b2b844d3a6de881fb512490
data/README.mdown CHANGED
@@ -24,7 +24,7 @@ to avoid this.
24
24
 
25
25
  # parallelize per scenario, with one JUnit XML file per scenario.
26
26
  JCukeForker::Runner.run JCukeForker::Scenarios.tagged(%W[@edition ~@wip])
27
- :extra_args => %W[-f CukeForker::Formatters::JunitScenarioFormatter --out results/junit]
27
+ :extra_args => %W[-f JCukeForker::Formatters::JunitScenarioFormatter --out results/junit]
28
28
  ```
29
29
 
30
30
  Note on Patches/Pull Requests
@@ -39,8 +39,8 @@ module JCukeForker
39
39
 
40
40
  private
41
41
 
42
- def status_string(failed)
43
- failed == 'false' ? 'failed' : 'passed'
42
+ def status_string(status)
43
+ status ? 'passed' : 'failed'
44
44
  end
45
45
 
46
46
  def worker_id(worker_path)
@@ -5,7 +5,7 @@ module JCukeForker
5
5
  attr_reader :output
6
6
 
7
7
  def initialize(worker, opts = {})
8
- @ext = opts[:codec] || "webm"
8
+ @ext = opts['ext'] || "webm"
9
9
  @options = opts
10
10
  @worker = worker
11
11
 
@@ -23,7 +23,7 @@ module JCukeForker
23
23
  raise 'ffmpeg failed'
24
24
  end
25
25
 
26
- unless worker.failed?
26
+ if status
27
27
  FileUtils.rm_rf output
28
28
  end
29
29
 
@@ -46,10 +46,10 @@ module JCukeForker
46
46
  '-an',
47
47
  '-y',
48
48
  '-f', 'x11grab',
49
- '-r', @options[:frame_rate] || '5',
50
- '-s', @options[:frame_size] || '1024x768',
49
+ '-r', @options['frame_rate'] || '5',
50
+ '-s', @options['frame_size'] || '1024x768',
51
51
  '-i', ENV['DISPLAY'],
52
- '-vcodec', @options[:codec] || 'vp8',
52
+ '-vcodec', @options['codec'] || 'vp8',
53
53
  @output
54
54
  )
55
55
  process.io.stdout = process.io.stderr = File.open('/dev/null', 'w')
@@ -19,7 +19,8 @@ module JCukeForker
19
19
  # :format => Symbol format passed to `cucumber --format` (default: html)
20
20
  # :extra_args => Array extra arguments passed to cucumber
21
21
  # :delay => Numeric seconds to sleep between each worker is started (default: 0)
22
- #
22
+ # :port => String port that the event server runs on
23
+ # (default: 6333)
23
24
 
24
25
  class Runner
25
26
  include Observable
@@ -32,7 +33,8 @@ module JCukeForker
32
33
  :out => Dir.pwd,
33
34
  :log => true,
34
35
  :format => :html,
35
- :delay => 0
36
+ :delay => 0,
37
+ :port => '6333'
36
38
  }
37
39
 
38
40
  def self.run(features, opts = {})
@@ -48,6 +50,7 @@ module JCukeForker
48
50
  listeners = Array(opts[:notify])
49
51
  extra_args = Array(opts[:extra_args])
50
52
  delay = opts[:delay]
53
+ port = opts[:port]
51
54
 
52
55
  if opts[:log]
53
56
  listeners << LoggingListener.new
@@ -59,7 +62,7 @@ module JCukeForker
59
62
  end
60
63
 
61
64
  listeners << task_manager
62
- status_server = StatusServer.new '6333'
65
+ status_server = StatusServer.new port
63
66
  worker_dir = "/tmp/jcukeforker-#{SecureRandom.hex 4}"
64
67
  FileUtils.mkdir_p worker_dir
65
68
 
@@ -74,7 +77,7 @@ module JCukeForker
74
77
  end
75
78
  end
76
79
 
77
- processes = create_processes(max, '6333', worker_dir, vnc_pool, opts[:record])
80
+ processes = create_processes(max, port, worker_dir, vnc_pool, opts[:record])
78
81
 
79
82
  runner = Runner.new status_server, processes, worker_dir, vnc_pool, delay
80
83
 
@@ -101,7 +104,8 @@ module JCukeForker
101
104
  rescue Interrupt
102
105
  fire :on_run_interrupted
103
106
  stop
104
- rescue StandardError
107
+ rescue StandardError => e
108
+ $stderr.puts e.backtrace
105
109
  fire :on_run_interrupted
106
110
  stop
107
111
  raise
@@ -115,8 +119,11 @@ module JCukeForker
115
119
  (1..max).inject([]) do |l, i|
116
120
  process_args = %W[ruby #{worker_file} #{status_path} #{worker_dir}/worker-#{i}]
117
121
  if vnc_pool && record
118
- record = {} unless record.kind_of? Hash
119
- process_args << record.to_json
122
+ if record.kind_of? Hash
123
+ process_args << record.to_json
124
+ else
125
+ process_args << {}.to_json
126
+ end
120
127
  end
121
128
  process = ChildProcess.build(*process_args)
122
129
  process.environment['DISPLAY'] = vnc_pool.get.display if vnc_pool
@@ -1,3 +1,3 @@
1
1
  module JCukeForker
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -7,18 +7,20 @@ require 'observer'
7
7
  require 'childprocess'
8
8
  require_relative './abstract_listener'
9
9
  require_relative './recording_vnc_listener'
10
+ require_relative './formatters/scenario_line_logger'
11
+ require_relative './formatters/junit_scenario_formatter'
10
12
 
11
13
  module JCukeForker
12
14
  class Worker
13
15
  include Observable
14
16
 
15
- attr_reader :feature, :format, :out
17
+ attr_reader :feature, :format, :out, :basename
16
18
 
17
19
  def initialize(status_path, task_path, recorder = nil)
18
20
  @status_path = status_path
19
21
  @task_path = task_path
20
22
  if ENV['DISPLAY'] && recorder
21
- config = recorder ? {} : JSON.parse(recorder)
23
+ config = JSON.parse(recorder)
22
24
  add_observer JCukeForker::RecordingVncListener.new(self, config)
23
25
  end
24
26
  @status_socket = TCPSocket.new 'localhost', status_path
@@ -64,7 +66,7 @@ module JCukeForker
64
66
  end
65
67
 
66
68
  def failed?
67
- @status.nil? || @status
69
+ @status.nil? || !@status
68
70
  end
69
71
 
70
72
  def output
@@ -79,10 +81,6 @@ module JCukeForker
79
81
  File.join out, "#{basename}.stderr"
80
82
  end
81
83
 
82
- def basename
83
- @basename ||= feature.gsub(/\W/, '_')
84
- end
85
-
86
84
  def args
87
85
  args = %W[--format #{format} --out #{output}]
88
86
  args += @extra_args
@@ -94,11 +92,13 @@ module JCukeForker
94
92
  private
95
93
 
96
94
  def set_state(raw_message)
95
+ @status = nil
97
96
  json_obj = JSON.parse raw_message
98
97
  @format = json_obj['format']
99
98
  @feature = json_obj['feature']
100
99
  @extra_args = json_obj['extra_args']
101
100
  @out = json_obj['out']
101
+ @basename = feature.gsub(/\W/, '_')
102
102
  end
103
103
 
104
104
  def execute_cucumber
data/lib/jcukeforker.rb CHANGED
@@ -14,6 +14,10 @@ require "securerandom"
14
14
  require "celluloid/io"
15
15
  require "celluloid/autostart"
16
16
 
17
+ unless ENV['DEBUG']
18
+ Celluloid.logger = Logger.new('/dev/null')
19
+ end
20
+
17
21
  module JCukeForker
18
22
  end
19
23
 
@@ -25,19 +25,22 @@ module JCukeForker
25
25
 
26
26
  timestamp = Time.now.strftime("%Y-%m-%d %H:%M:%S##{Process.pid}")
27
27
 
28
- stdout.string.should == <<-OUTPUT
28
+ str = <<-OUTPUT
29
29
  I, [#{timestamp}] INFO -- : [ run ] starting
30
30
  I, [#{timestamp}] INFO -- : [ worker 1 ] register: /tmp/12sd3-1
31
31
  I, [#{timestamp}] INFO -- : [ worker 1 ] starting: foo/bar
32
32
  I, [#{timestamp}] INFO -- : [ worker 15 ] register: /tmp/12sd3-15
33
33
  I, [#{timestamp}] INFO -- : [ worker 15 ] starting: foo/baz
34
- I, [#{timestamp}] INFO -- : [ worker 1 ] passed : foo/bar
35
- I, [#{timestamp}] INFO -- : [ worker 15 ] failed : foo/baz
34
+ I, [#{timestamp}] INFO -- : [ worker 1 ] failed : foo/bar
35
+ I, [#{timestamp}] INFO -- : [ worker 15 ] passed : foo/baz
36
36
  I, [#{timestamp}] INFO -- : [ worker 1 ] dead : /tmp/12sd3-1
37
37
  I, [#{timestamp}] INFO -- : [ worker 15 ] dead : /tmp/12sd3-15
38
38
  I, [#{timestamp}] INFO -- : [ run ] interrupted - please wait
39
- I, [#{timestamp}] INFO -- : [ run ] finished, passed
40
- OUTPUT
39
+ I, [#{timestamp}] INFO -- : [ run ] finished, failed
40
+ OUTPUT
41
+
42
+ puts str
43
+ stdout.string.should == str
41
44
  end
42
45
  end # Worker
43
46
  end # CukeForker
@@ -50,15 +50,14 @@ module JCukeForker
50
50
  recorder.stub(:stop)
51
51
  listener.instance_variable_set(:@recorder, recorder)
52
52
 
53
- worker.should_receive(:failed?).and_return(false)
54
53
  listener.should_receive(:output).and_return("./foo.mp4")
55
54
  FileUtils.should_receive(:rm_rf).with("./foo.mp4")
56
55
 
57
- listener.on_task_finished worker, nil, nil
56
+ listener.on_task_finished worker, nil, true
58
57
  end
59
58
 
60
59
  it "passes along options to recorder" do
61
- listener = RecordingVncListener.new worker, :codec => "flv"
60
+ listener = RecordingVncListener.new worker, 'codec' => "flv", 'ext' => 'flv'
62
61
  env = ENV['DISPLAY']
63
62
  ENV['DISPLAY']= ':1'
64
63
  ChildProcess.should_receive(:build).with(
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jcukeforker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Gowan
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-08-08 00:00:00.000000000 Z
12
+ date: 2014-08-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cucumber