flatware 1.0.0 → 2.0.0.rc3

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.
Files changed (38) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +38 -49
  3. data/bin/flatware +2 -2
  4. data/lib/flatware.rb +32 -3
  5. data/lib/flatware/broadcaster.rb +20 -3
  6. data/lib/flatware/cli.rb +45 -21
  7. data/lib/flatware/configuration.rb +40 -0
  8. data/lib/flatware/job.rb +13 -1
  9. data/lib/flatware/pid.rb +41 -0
  10. data/lib/flatware/serialized_exception.rb +16 -4
  11. data/lib/flatware/sink.rb +97 -65
  12. data/lib/flatware/sink/client.rb +7 -5
  13. data/lib/flatware/version.rb +3 -1
  14. data/lib/flatware/worker.rb +50 -31
  15. metadata +20 -81
  16. data/lib/flatware-cucumber.rb +0 -1
  17. data/lib/flatware-rspec.rb +0 -1
  18. data/lib/flatware/cucumber.rb +0 -50
  19. data/lib/flatware/cucumber/cli.rb +0 -22
  20. data/lib/flatware/cucumber/formatter.rb +0 -66
  21. data/lib/flatware/cucumber/formatters/console.rb +0 -48
  22. data/lib/flatware/cucumber/formatters/console/summary.rb +0 -65
  23. data/lib/flatware/cucumber/result.rb +0 -27
  24. data/lib/flatware/cucumber/runtime.rb +0 -36
  25. data/lib/flatware/cucumber/scenario_result.rb +0 -38
  26. data/lib/flatware/cucumber/step_result.rb +0 -30
  27. data/lib/flatware/pids.rb +0 -25
  28. data/lib/flatware/poller.rb +0 -35
  29. data/lib/flatware/processor_info.rb +0 -24
  30. data/lib/flatware/rspec.rb +0 -28
  31. data/lib/flatware/rspec/checkpoint.rb +0 -29
  32. data/lib/flatware/rspec/cli.rb +0 -16
  33. data/lib/flatware/rspec/example_notification.rb +0 -21
  34. data/lib/flatware/rspec/examples_notification.rb +0 -24
  35. data/lib/flatware/rspec/formatter.rb +0 -50
  36. data/lib/flatware/rspec/formatters/console.rb +0 -33
  37. data/lib/flatware/rspec/summary.rb +0 -26
  38. data/lib/flatware/socket.rb +0 -176
@@ -1 +0,0 @@
1
- require 'flatware/cucumber'
@@ -1 +0,0 @@
1
- require 'flatware/rspec'
@@ -1,50 +0,0 @@
1
- require 'cucumber'
2
- require 'flatware/cucumber/formatter'
3
- require 'flatware/cucumber/result'
4
- require 'flatware/cucumber/scenario_result'
5
- require 'flatware/cucumber/step_result'
6
- require 'flatware/cucumber/formatters/console'
7
- require 'flatware/cucumber/cli'
8
-
9
- module Flatware
10
- module Cucumber
11
- class Config
12
- attr_reader :config, :args
13
- def initialize(cucumber_config, args)
14
- @config, @args = cucumber_config, args
15
- end
16
-
17
- def feature_dir
18
- @config.feature_dirs.first
19
- end
20
-
21
- def jobs
22
- feature_files.map { |file| Job.new file, args }.to_a
23
- end
24
-
25
- private
26
-
27
- def feature_files
28
- config.feature_files - config.feature_dirs
29
- end
30
- end
31
-
32
- extend self
33
-
34
- def configure(args, out_stream=$stdout, error_stream=$stderr)
35
- raw_args = args.dup
36
- cli_config = ::Cucumber::Cli::Configuration.new(out_stream, error_stream)
37
- cli_config.parse! args + %w[--format Flatware::Cucumber::Formatter]
38
- cucumber_config = ::Cucumber::Configuration.new cli_config
39
- Config.new cucumber_config, raw_args
40
- end
41
-
42
- def run(feature_files, options)
43
- runtime(Array(feature_files) + options).run!
44
- end
45
-
46
- def runtime(args)
47
- ::Cucumber::Runtime.new(configure(args).config)
48
- end
49
- end
50
- end
@@ -1,22 +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 "cucumber [FLATWARE_OPTS] [CUCUMBER_ARGS]", "parallelizes cucumber with custom arguments"
9
- def cucumber(*args)
10
- config = Cucumber.configure args
11
-
12
- unless config.jobs.any?
13
- puts "Please create some feature files in the #{config.feature_dir} directory."
14
- exit 1
15
- end
16
-
17
- Flatware.verbose = options[:log]
18
- Worker.spawn count: workers, runner: Cucumber, dispatch: options['dispatch-endpoint'], sink: options['sink-endpoint']
19
- start_sink jobs: config.jobs, workers: workers, formatter: Flatware::Cucumber::Formatters::Console.new($stdout, $stderr)
20
- end
21
- end
22
- end
@@ -1,66 +0,0 @@
1
- require 'cucumber'
2
- require 'flatware/sink'
3
- require 'ostruct'
4
- module Flatware
5
- module Cucumber
6
- class Formatter
7
- Checkpoint = Struct.new :steps, :scenarios do
8
- def failures?
9
- scenarios.any? &:failed?
10
- end
11
- end
12
-
13
- Scenario = Struct.new :name, :file_colon_line, :status do
14
- def failed?
15
- status == :failed
16
- end
17
-
18
- def failed_outside_step?
19
- false
20
- end
21
- end
22
-
23
- def initialize(config)
24
- config.on_event :test_case_finished, &method(:on_test_case_finished)
25
- config.on_event :test_step_finished, &method(:on_test_step_finished)
26
- config.on_event :test_run_finished, &method(:on_test_run_finished)
27
- config.on_event :step_activated, &method(:on_step_activated)
28
- reset
29
- end
30
-
31
- private
32
-
33
- def reset
34
- @steps = []
35
- @scenarios = []
36
- @matched_steps = Set.new
37
- end
38
-
39
- attr_reader :steps, :scenarios, :matched_steps
40
-
41
- def on_test_case_finished(event)
42
- scenarios << Scenario.new(event.test_case.name, event.test_case.location.to_s, event.result.to_sym)
43
- end
44
-
45
- def on_step_activated(event)
46
- @matched_steps << event.step_match.location.to_s
47
- end
48
-
49
- def on_test_step_finished(event)
50
- if really_a_step?(event.test_step) or event.result.undefined?
51
- steps << StepResult.new(event.result.to_sym, event.result.failed? && event.result.exception)
52
- Sink::client.progress Result.new event.result.to_sym
53
- end
54
- end
55
-
56
- def on_test_run_finished(*)
57
- Sink::client.checkpoint Checkpoint.new steps, scenarios
58
- reset
59
- end
60
-
61
- def really_a_step?(step)
62
- matched_steps.include?(step.action_location.to_s)
63
- end
64
- end
65
- end
66
- end
@@ -1,48 +0,0 @@
1
- require 'flatware/cucumber/formatters/console/summary'
2
- require 'cucumber/formatter/console'
3
-
4
- module Flatware::Cucumber::Formatters
5
- class Console
6
- #for format_string
7
- include ::Cucumber::Formatter::Console
8
-
9
- FORMATS = {
10
- passed: '.',
11
- failed: 'F',
12
- undefined: 'U',
13
- pending: 'P',
14
- skipped: '-'
15
- }
16
-
17
- STATUSES = FORMATS.keys
18
-
19
- attr_reader :out, :err
20
-
21
- def initialize(stdout, stderr)
22
- @out, @err = stdout, stderr
23
- end
24
-
25
- def progress(result)
26
- out.print format result.progress
27
- end
28
-
29
- def summarize(checkpoints)
30
- steps = checkpoints.flat_map(&:steps)
31
- scenarios = checkpoints.flat_map(&:scenarios)
32
- Summary.new(steps, scenarios, out).summarize
33
- end
34
-
35
- def summarize_remaining(remaining_jobs)
36
- out.puts
37
- out.puts "The following features have not been run:"
38
- for job in remaining_jobs
39
- out.puts job.id
40
- end
41
- end
42
-
43
- private
44
- def format(status)
45
- format_string FORMATS[status], status
46
- end
47
- end
48
- end
@@ -1,65 +0,0 @@
1
- require 'cucumber/formatter/console'
2
- require 'flatware/cucumber/formatters/console'
3
-
4
- module Flatware::Cucumber::Formatters
5
- class Console
6
- class Summary
7
- include ::Cucumber::Formatter::Console
8
- attr_reader :io, :steps, :scenarios
9
-
10
- def initialize(steps, scenarios=[], io=StringIO.new)
11
- @io = io
12
- @steps = steps
13
- @scenarios = scenarios
14
- end
15
-
16
- def summarize
17
- 2.times { io.puts }
18
- print_failures(steps, 'step')
19
- print_failures(scenarios.select(&:failed_outside_step?), 'scenario')
20
- print_failed_scenarios scenarios
21
- print_counts 'scenario', scenarios
22
- print_counts 'step', steps
23
- end
24
-
25
- private
26
-
27
- def print_failed_scenarios(scenarios)
28
- return unless scenarios.any? &with_status(:failed)
29
-
30
- io.puts format_string "Failing Scenarios:", :failed
31
- scenarios.select(&with_status(:failed)).sort_by(&:file_colon_line).each do |scenario|
32
- io.puts format_string(scenario.file_colon_line, :failed) + format_string(" # Scenario: " + scenario.name, :comment)
33
- end
34
- io.puts
35
- end
36
-
37
- def print_failures(collection, label)
38
- failures = collection.select(&with_status(:failed))
39
- print_elements failures, :failed, pluralize(label, failures.size)
40
- end
41
-
42
- def print_counts(label, collection)
43
- io.puts pluralize(label, collection.size) + count_summary(collection)
44
- end
45
-
46
- def pluralize(word, number)
47
- "#{number} #{number == 1 ? word : word + 's'}"
48
- end
49
-
50
- def with_status(status)
51
- proc {|r| r.status == status}
52
- end
53
-
54
- def count_summary(results)
55
- return "" unless results.any?
56
- status_counts = STATUSES.map do |status|
57
- count = results.select(&with_status(status)).size
58
- format_string "#{count} #{status}", status if count > 0
59
- end.compact.join ", "
60
-
61
- " (#{status_counts})"
62
- end
63
- end
64
- end
65
- end
@@ -1,27 +0,0 @@
1
- module Flatware
2
- module Cucumber
3
- class Result
4
- attr_reader :progress, :worker
5
-
6
- def initialize(progress)
7
- @progress = progress
8
- @worker = ENV['TEST_ENV_NUMBER'].to_i
9
- end
10
-
11
- class << self
12
- def step(*args)
13
- step = StepResult.new *args
14
- new step.progress, [step]
15
- end
16
-
17
- def status(status)
18
- new status
19
- end
20
-
21
- def background(status, exception)
22
- new '', [StepResult.new(status, exception)]
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,36 +0,0 @@
1
- require 'cucumber'
2
-
3
- module Flatware
4
- module Cucumber
5
- class Runtime < ::Cucumber::Runtime
6
-
7
- attr_accessor :configuration, :loader
8
- attr_reader :out, :err
9
- attr_reader :visitor
10
-
11
- def initialize(out=StringIO.new, err=out)
12
- @out, @err = out, err
13
- super(default_configuration)
14
- load_step_definitions
15
- @results = Results.new(configuration)
16
- end
17
-
18
- def default_configuration
19
- config = ::Cucumber::Cli::Configuration.new
20
- config.parse! []
21
- config
22
- end
23
-
24
- def run(feature_files=[], options=[])
25
- @loader = nil
26
- options = Array(feature_files) + %w[--format Flatware::Cucumber::Formatter] + options
27
-
28
- configure(::Cucumber::Cli::Main.new(options, out, err).configuration)
29
-
30
- self.visitor = configuration.build_tree_walker(self)
31
- visitor.visit_features(features)
32
- results
33
- end
34
- end
35
- end
36
- end
@@ -1,38 +0,0 @@
1
- require 'flatware/serialized_exception'
2
- module Flatware
3
- module Cucumber
4
- class ScenarioResult
5
- attr_reader :status, :file_colon_line, :name
6
- def initialize(status, file_colon_line, name, e)
7
- @status = status
8
- @file_colon_line = file_colon_line
9
- @name = name
10
- @exception = SerializedException.new(e.class, e.message, e.backtrace) if e
11
- @failed_outside_step = false
12
- end
13
-
14
- def passed?
15
- status == :passed
16
- end
17
-
18
- def failed?
19
- status == :failed
20
- end
21
-
22
- def failed_outside_step!(file_colon_line)
23
- @failed_outside_step = file_colon_line
24
- end
25
-
26
- def failed_outside_step?
27
- !!@failed_outside_step
28
- end
29
-
30
- def exception
31
- @exception.tap do |e|
32
- e.backtrace = e.backtrace.grep(Regexp.new(Dir.pwd)).map { |line| line[Dir.pwd.size..-1] }
33
- e.backtrace = e.backtrace + [@failed_outside_step] if failed_outside_step?
34
- end
35
- end
36
- end
37
- end
38
- end
@@ -1,30 +0,0 @@
1
- require 'flatware/serialized_exception'
2
- module Flatware
3
- module Cucumber
4
- class StepResult
5
- attr_reader :status, :exception
6
-
7
- def initialize(status, exception)
8
- @status, @exception = status, (serialized(exception) if exception)
9
- end
10
-
11
- def passed?
12
- status == :passed
13
- end
14
-
15
- def failed?
16
- status == :failed
17
- end
18
-
19
- def progress
20
- Cucumber::ProgressString.format(status)
21
- end
22
-
23
- private
24
- def serialized(e)
25
- e.backtrace and e.backtrace.unshift e.backtrace.shift.sub(Dir.pwd, '.')
26
- SerializedException.new(e.class, e.message, e.backtrace)
27
- end
28
- end
29
- end
30
- end
data/lib/flatware/pids.rb DELETED
@@ -1,25 +0,0 @@
1
- require 'flatware/processor_info'
2
- module Flatware
3
- extend self
4
- # All the pids of all the processes called flatware on this machine
5
- def pids
6
- pids_command.map do |row|
7
- row =~ /(\d+).*flatware/ and $1.to_i
8
- end.compact
9
- end
10
-
11
- def pids_command
12
- case ProcessorInfo.operating_system
13
- when 'Darwin'
14
- `ps -c -opid,pgid,command`
15
- when 'Linux'
16
- `ps -opid,pgid,command`
17
- end.split("\n")[1..-1]
18
- end
19
-
20
- def pids_of_group(group_pid)
21
- pids_command.map(&:split).map do |pid, pgid, _|
22
- pid.to_i if pgid.to_i == group_pid
23
- end.compact
24
- end
25
- end
@@ -1,35 +0,0 @@
1
- module Flatware
2
- class Poller
3
- attr_reader :sockets, :zmq_poller
4
- def initialize(*sockets)
5
- @sockets = sockets
6
- @zmq_poller = ZMQ::Poller.new
7
- register_sockets
8
- end
9
-
10
- def each(&block)
11
- while (result = zmq_poller.poll) != 0
12
- raise Error, ZMQ::Util.error_string, caller if result == -1
13
- for socket in zmq_poller.readables.map &find_wrapped_socket
14
- yield socket
15
- end
16
- end
17
- end
18
-
19
- private
20
-
21
- def find_wrapped_socket
22
- ->(s) do
23
- sockets.find do |socket|
24
- socket.socket == s
25
- end
26
- end
27
- end
28
-
29
- def register_sockets
30
- sockets.each do |socket|
31
- zmq_poller.register_readable socket.socket
32
- end
33
- end
34
- end
35
- end