flatware 0.4.1 → 2.0.0.rc2
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 +5 -5
- data/README.md +38 -47
- data/bin/flatware +2 -2
- data/lib/flatware.rb +32 -3
- data/lib/flatware/broadcaster.rb +20 -3
- data/lib/flatware/cli.rb +45 -21
- data/lib/flatware/configuration.rb +40 -0
- data/lib/flatware/job.rb +13 -1
- data/lib/flatware/pid.rb +41 -0
- data/lib/flatware/serialized_exception.rb +16 -4
- data/lib/flatware/sink.rb +97 -65
- data/lib/flatware/sink/client.rb +7 -5
- data/lib/flatware/version.rb +3 -1
- data/lib/flatware/worker.rb +50 -31
- metadata +20 -81
- data/lib/flatware-cucumber.rb +0 -1
- data/lib/flatware-rspec.rb +0 -1
- data/lib/flatware/cucumber.rb +0 -50
- data/lib/flatware/cucumber/cli.rb +0 -22
- data/lib/flatware/cucumber/formatter.rb +0 -66
- data/lib/flatware/cucumber/formatters/console.rb +0 -48
- data/lib/flatware/cucumber/formatters/console/summary.rb +0 -65
- data/lib/flatware/cucumber/result.rb +0 -27
- data/lib/flatware/cucumber/runtime.rb +0 -36
- data/lib/flatware/cucumber/scenario_result.rb +0 -38
- data/lib/flatware/cucumber/step_result.rb +0 -30
- data/lib/flatware/pids.rb +0 -25
- data/lib/flatware/poller.rb +0 -35
- data/lib/flatware/processor_info.rb +0 -24
- data/lib/flatware/rspec.rb +0 -28
- data/lib/flatware/rspec/checkpoint.rb +0 -29
- data/lib/flatware/rspec/cli.rb +0 -16
- data/lib/flatware/rspec/example_notification.rb +0 -21
- data/lib/flatware/rspec/examples_notification.rb +0 -24
- data/lib/flatware/rspec/formatter.rb +0 -50
- data/lib/flatware/rspec/formatters/console.rb +0 -33
- data/lib/flatware/rspec/summary.rb +0 -26
- data/lib/flatware/socket.rb +0 -176
@@ -1,24 +0,0 @@
|
|
1
|
-
module Flatware
|
2
|
-
class ProcessorInfo
|
3
|
-
def count
|
4
|
-
case operating_system
|
5
|
-
when 'Darwin'
|
6
|
-
`hostinfo`.match(/^(?<processors>\d+) processors are logically available\.$/)[:processors].to_i
|
7
|
-
when 'Linux'
|
8
|
-
`grep --count '^processor' /proc/cpuinfo`.to_i
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def operating_system
|
13
|
-
`uname`.chomp
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.count
|
17
|
-
new.count
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.operating_system
|
21
|
-
new.operating_system
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
data/lib/flatware/rspec.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'rspec/core'
|
2
|
-
require 'rspec/expectations'
|
3
|
-
require 'flatware/rspec/cli'
|
4
|
-
|
5
|
-
module Flatware
|
6
|
-
module RSpec
|
7
|
-
require 'flatware/rspec/formatters/console'
|
8
|
-
require 'flatware/rspec/formatter'
|
9
|
-
|
10
|
-
def self.extract_jobs_from_args(args, workers:)
|
11
|
-
|
12
|
-
options = ::RSpec::Core::ConfigurationOptions.new(args)
|
13
|
-
configuration = ::RSpec::Core::Configuration.new
|
14
|
-
def configuration.command() 'rspec' end
|
15
|
-
options.configure(configuration)
|
16
|
-
configuration.files_to_run.uniq.map do |file|
|
17
|
-
Job.new(file, args)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.run(job, options={})
|
22
|
-
runner = ::RSpec::Core::Runner
|
23
|
-
def runner.trap_interrupt() end
|
24
|
-
|
25
|
-
runner.run(%w[--format Flatware::RSpec::Formatter] + Array(job), $stderr, $stdout)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'flatware/rspec/examples_notification'
|
2
|
-
|
3
|
-
module Flatware
|
4
|
-
module RSpec
|
5
|
-
class Checkpoint
|
6
|
-
attr_reader :summary, :failures_notification
|
7
|
-
|
8
|
-
def initialize(summary, failures_notification)
|
9
|
-
@summary, @failures_notification = summary, ExamplesNotification.new(failures_notification.failure_notifications)
|
10
|
-
end
|
11
|
-
|
12
|
-
def +(other)
|
13
|
-
self.class.new summary + other.summary, failures_notification + other.failures_notification
|
14
|
-
end
|
15
|
-
|
16
|
-
def failures?
|
17
|
-
summary.failure_count > 0
|
18
|
-
end
|
19
|
-
|
20
|
-
def failure_notifications
|
21
|
-
failures_notification.failure_notifications
|
22
|
-
end
|
23
|
-
|
24
|
-
def fully_formatted_failed_examples(*args)
|
25
|
-
failures_notification.fully_formatted_failed_examples(*args)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
data/lib/flatware/rspec/cli.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'flatware/cli'
|
2
|
-
|
3
|
-
module Flatware
|
4
|
-
class CLI
|
5
|
-
worker_option
|
6
|
-
method_option 'dispatch-endpoint', type: :string, default: 'ipc://dispatch'
|
7
|
-
method_option 'sink-endpoint', type: :string, default: 'ipc://task'
|
8
|
-
desc "rspec [FLATWARE_OPTS]", "parallelizes rspec"
|
9
|
-
def rspec(*rspec_args)
|
10
|
-
jobs = RSpec.extract_jobs_from_args rspec_args, workers: workers
|
11
|
-
Flatware.verbose = options[:log]
|
12
|
-
Worker.spawn count: workers, runner: RSpec, dispatch: options['dispatch-endpoint'], sink: options['sink-endpoint']
|
13
|
-
start_sink jobs: jobs, workers: workers, formatter: Flatware::RSpec::Formatters::Console.new($stdout, $stderr)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'rspec/core/formatters/console_codes'
|
2
|
-
|
3
|
-
module Flatware
|
4
|
-
module RSpec
|
5
|
-
class ExampleNotification
|
6
|
-
attr_reader :formatted
|
7
|
-
def initialize(notification)
|
8
|
-
@formatted = notification.fully_formatted '!', default_colorizer
|
9
|
-
end
|
10
|
-
|
11
|
-
def fully_formatted(i, _=nil)
|
12
|
-
formatted.sub '!', i.to_s
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
def default_colorizer
|
17
|
-
::RSpec::Core::Formatters::ConsoleCodes
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'flatware/rspec/example_notification'
|
2
|
-
module Flatware
|
3
|
-
module RSpec
|
4
|
-
class ExamplesNotification
|
5
|
-
attr_reader :failure_notifications
|
6
|
-
|
7
|
-
def initialize(failure_notifications)
|
8
|
-
@failure_notifications = failure_notifications.map(&ExampleNotification.method(:new))
|
9
|
-
end
|
10
|
-
|
11
|
-
def +(other)
|
12
|
-
self.class.new failure_notifications + other.failure_notifications
|
13
|
-
end
|
14
|
-
|
15
|
-
def fully_formatted_failed_examples(*)
|
16
|
-
formatted = "\n\nFailures:\n"
|
17
|
-
failure_notifications.each_with_index do |failure, index|
|
18
|
-
formatted << failure.fully_formatted(index.next)
|
19
|
-
end
|
20
|
-
formatted
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
require 'flatware/rspec/checkpoint'
|
2
|
-
require 'flatware/rspec/summary'
|
3
|
-
require 'rspec/core/formatters/console_codes'
|
4
|
-
|
5
|
-
module Flatware
|
6
|
-
module RSpec
|
7
|
-
ProgressMessage = Struct.new(:progress)
|
8
|
-
|
9
|
-
class Formatter
|
10
|
-
attr_reader :summary, :output
|
11
|
-
|
12
|
-
def initialize(stdout)
|
13
|
-
@output = stdout
|
14
|
-
end
|
15
|
-
|
16
|
-
def example_passed(example)
|
17
|
-
send_progress :passed
|
18
|
-
end
|
19
|
-
|
20
|
-
def example_failed(example)
|
21
|
-
send_progress :failed
|
22
|
-
end
|
23
|
-
|
24
|
-
def example_pending(example)
|
25
|
-
send_progress :pending
|
26
|
-
end
|
27
|
-
|
28
|
-
def dump_summary(summary)
|
29
|
-
@summary = Summary.from_notification(summary)
|
30
|
-
end
|
31
|
-
|
32
|
-
def dump_failures(failure_notification)
|
33
|
-
@failure_notification = failure_notification
|
34
|
-
end
|
35
|
-
|
36
|
-
def close(*)
|
37
|
-
Sink::client.checkpoint Checkpoint.new(summary, @failure_notification)
|
38
|
-
@failure_notification = nil
|
39
|
-
end
|
40
|
-
|
41
|
-
private
|
42
|
-
|
43
|
-
def send_progress(status)
|
44
|
-
Sink::client.progress ProgressMessage.new status
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
::RSpec::Core::Formatters.register Formatter, :example_passed, :example_failed, :example_pending, :dump_summary, :dump_failures, :close
|
49
|
-
end
|
50
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module Flatware::RSpec::Formatters
|
2
|
-
class Console
|
3
|
-
attr_reader :formatter
|
4
|
-
|
5
|
-
def initialize(out, err)
|
6
|
-
::RSpec::configuration.tty = true
|
7
|
-
::RSpec::configuration.color = true
|
8
|
-
@formatter = ::RSpec::Core::Formatters::ProgressFormatter.new(out)
|
9
|
-
end
|
10
|
-
|
11
|
-
def progress(result)
|
12
|
-
formatter.send(message_for(result),nil)
|
13
|
-
end
|
14
|
-
|
15
|
-
def summarize(checkpoints)
|
16
|
-
result = checkpoints.reduce :+
|
17
|
-
if result
|
18
|
-
formatter.dump_failures result
|
19
|
-
formatter.dump_summary result.summary
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def message_for(result)
|
26
|
-
{
|
27
|
-
passed: :example_passed,
|
28
|
-
failed: :example_failed,
|
29
|
-
pending: :example_pending
|
30
|
-
}.fetch result.progress
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'rspec/core/notifications'
|
2
|
-
module Flatware
|
3
|
-
module RSpec
|
4
|
-
class Example
|
5
|
-
attr_reader :location_rerun_argument, :full_description
|
6
|
-
def initialize(rspec_example)
|
7
|
-
@full_description = rspec_example.full_description
|
8
|
-
@location_rerun_argument = rspec_example.location_rerun_argument
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
class Summary < ::RSpec::Core::Notifications::SummaryNotification
|
13
|
-
def +(other)
|
14
|
-
self.class.new(*zip(other).map {|a,b| a + b})
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.from_notification(summary)
|
18
|
-
serialized_examples = [summary.examples, summary.failed_examples, summary.pending_examples].map do |examples|
|
19
|
-
examples.map(&Example.method(:new))
|
20
|
-
end
|
21
|
-
|
22
|
-
new summary.duration, *serialized_examples, *summary.to_a[4..-1]
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
data/lib/flatware/socket.rb
DELETED
@@ -1,176 +0,0 @@
|
|
1
|
-
require 'ffi-rzmq'
|
2
|
-
require 'securerandom'
|
3
|
-
require 'logger'
|
4
|
-
|
5
|
-
module Flatware
|
6
|
-
Error = Class.new StandardError
|
7
|
-
|
8
|
-
extend self
|
9
|
-
|
10
|
-
def logger
|
11
|
-
@logger ||= Logger.new($stderr)
|
12
|
-
end
|
13
|
-
|
14
|
-
def logger=(logger)
|
15
|
-
@logger = logger
|
16
|
-
end
|
17
|
-
|
18
|
-
def socket(*args)
|
19
|
-
context.socket(*args)
|
20
|
-
end
|
21
|
-
|
22
|
-
def close(force: false)
|
23
|
-
@ignore_errors = true if force
|
24
|
-
context.close(force: force)
|
25
|
-
@context = nil
|
26
|
-
end
|
27
|
-
|
28
|
-
def close!
|
29
|
-
close force: true
|
30
|
-
end
|
31
|
-
|
32
|
-
def socket_error(name=nil)
|
33
|
-
raise(Error, [$0,name,ZMQ::Util.error_string].compact.join(' - '), caller) unless @ignore_errors
|
34
|
-
end
|
35
|
-
|
36
|
-
def log(*message)
|
37
|
-
if Exception === message.first
|
38
|
-
logger.error message.first
|
39
|
-
elsif verbose?
|
40
|
-
logger.info ([$0] + message).join(' ')
|
41
|
-
end
|
42
|
-
message
|
43
|
-
end
|
44
|
-
|
45
|
-
attr_writer :verbose
|
46
|
-
def verbose?
|
47
|
-
!!@verbose
|
48
|
-
end
|
49
|
-
|
50
|
-
def context
|
51
|
-
@context ||= begin
|
52
|
-
@ignore_errors = nil
|
53
|
-
Context.new
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
class Context
|
58
|
-
attr_reader :sockets, :c
|
59
|
-
|
60
|
-
def initialize
|
61
|
-
@c = ZMQ::Context.new
|
62
|
-
@sockets = []
|
63
|
-
end
|
64
|
-
|
65
|
-
def socket(zmq_type, options={})
|
66
|
-
Socket.new(c.socket(zmq_type)).tap do |socket|
|
67
|
-
sockets.push socket
|
68
|
-
if port = options[:connect]
|
69
|
-
socket.connect port
|
70
|
-
end
|
71
|
-
if port = options[:bind]
|
72
|
-
socket.bind port
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def close(force: false)
|
78
|
-
sockets.each do |socket|
|
79
|
-
socket.setsockopt ZMQ::LINGER, 0
|
80
|
-
end if force
|
81
|
-
sockets.each(&:close)
|
82
|
-
Flatware::socket_error unless LibZMQ.zmq_term(c.context) == 0
|
83
|
-
Flatware.log "terminated context"
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
class Socket
|
88
|
-
attr_reader :socket
|
89
|
-
|
90
|
-
def initialize(socket)
|
91
|
-
@socket = socket
|
92
|
-
end
|
93
|
-
|
94
|
-
def setsockopt(*args)
|
95
|
-
socket.setsockopt(*args)
|
96
|
-
end
|
97
|
-
|
98
|
-
def name
|
99
|
-
socket.name
|
100
|
-
end
|
101
|
-
|
102
|
-
def send(message)
|
103
|
-
result = socket.send_string(Marshal.dump(message))
|
104
|
-
error if result == -1
|
105
|
-
Flatware.log "#@type #@port send #{message}"
|
106
|
-
message
|
107
|
-
end
|
108
|
-
|
109
|
-
def connect(port)
|
110
|
-
@type = 'connected'
|
111
|
-
@port = port
|
112
|
-
error unless socket.connect(port) == 0
|
113
|
-
Flatware.log "connect #@port"
|
114
|
-
end
|
115
|
-
|
116
|
-
def monitor
|
117
|
-
name = "inproc://monitor#{SecureRandom.hex(10)}"
|
118
|
-
LibZMQ.zmq_socket_monitor(socket.socket, name, ZMQ::EVENT_ALL)
|
119
|
-
Monitor.new(name)
|
120
|
-
end
|
121
|
-
|
122
|
-
class Monitor
|
123
|
-
def initialize(port)
|
124
|
-
@socket = Flatware.socket ZMQ::PAIR
|
125
|
-
@socket.connect port
|
126
|
-
end
|
127
|
-
|
128
|
-
def recv
|
129
|
-
bytes = @socket.recv marshal: false
|
130
|
-
data = LibZMQ::EventData.new FFI::MemoryPointer.from_string bytes
|
131
|
-
event[data.event]
|
132
|
-
end
|
133
|
-
|
134
|
-
private
|
135
|
-
|
136
|
-
def event
|
137
|
-
ZMQ.constants.select do |c|
|
138
|
-
c.to_s =~ /^EVENT/
|
139
|
-
end.map do |s|
|
140
|
-
{s => ZMQ.const_get(s)}
|
141
|
-
end.reduce(:merge).invert
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
def bind(port)
|
146
|
-
@type = 'bound'
|
147
|
-
@port = port
|
148
|
-
error unless socket.bind(port) == 0
|
149
|
-
Flatware.log "bind #@port"
|
150
|
-
end
|
151
|
-
|
152
|
-
def close
|
153
|
-
error unless socket.close == 0
|
154
|
-
Flatware.log "close #@type #@port"
|
155
|
-
end
|
156
|
-
|
157
|
-
def error
|
158
|
-
Flatware::socket_error name
|
159
|
-
end
|
160
|
-
|
161
|
-
def recv(block: true, marshal: true)
|
162
|
-
message = ''
|
163
|
-
if block
|
164
|
-
result = socket.recv_string(message)
|
165
|
-
error if result == -1
|
166
|
-
else
|
167
|
-
socket.recv_string(message, ZMQ::NOBLOCK)
|
168
|
-
end
|
169
|
-
if message != '' and marshal
|
170
|
-
message = Marshal.load(message)
|
171
|
-
end
|
172
|
-
Flatware.log "#@type #@port recv #{message}"
|
173
|
-
message
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|