Class: Qspec::CommandLine
- Inherits:
-
Object
- Object
- Qspec::CommandLine
- Defined in:
- lib/qspec/command_line.rb
Constant Summary collapse
- TIME_LOG_NAME =
'elapsed_time'
- DEFAULT_ELAPSED_TIME =
3.0
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#ipc ⇒ Object
readonly
Returns the value of attribute ipc.
Instance Method Summary collapse
-
#initialize(args) ⇒ CommandLine
constructor
A new instance of CommandLine.
- #process ⇒ Object
- #run(err, out) ⇒ Object
Constructor Details
#initialize(args) ⇒ CommandLine
Returns a new instance of CommandLine.
8 9 10 11 12 13 14 15 16 |
# File 'lib/qspec/command_line.rb', line 8 def initialize(args) @config = Config.new() @ipc = IPC.from_config(@config) @id = rand(10000) @stats = [] @rspec_options = RSpec::Core::ConfigurationOptions.new(args) @rspec_configuration = RSpec.configuration @rspec_options.configure(@rspec_configuration) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/qspec/command_line.rb', line 6 def config @config end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/qspec/command_line.rb', line 6 def id @id end |
#ipc ⇒ Object (readonly)
Returns the value of attribute ipc.
6 7 8 |
# File 'lib/qspec/command_line.rb', line 6 def ipc @ipc end |
Instance Method Details
#process ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/qspec/command_line.rb', line 52 def process ipc = IPC.from_config(@config) success = true while f = ipc.lpop("to_run_#{id}") @rspec_configuration.add_formatter(Qspec::Formatters::RedisFormatterFactory.build(id, f)) require File.(f) world = RSpec.world example_groups = world.ordered_example_groups begin @rspec_configuration.reporter.report(world.example_count(example_groups)) do |reporter| begin hook_context = RSpec::Core::SuiteHookContext.new @rspec_configuration.hooks.run(:before, :suite, hook_context) success = example_groups.map { |g| g.run(reporter) }.all? && success ensure @rspec_configuration.hooks.run(:after, :suite, hook_context) end end ensure world.example_groups.clear @rspec_configuration.reset # formatter, reporter end end success end |
#run(err, out) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/qspec/command_line.rb', line 18 def run(err, out) @rspec_configuration.error_stream = err @rspec_configuration.output_stream = out if @rspec_configuration.output_stream == $stdout out.puts "ID: #{id}" register_files(id) puts "Forking #{@config['workers']} workers" thread = start_progress_thread(id) results = Parallel.map(1..@config['workers'], in_processes: @config['workers']) do |no| ENV['TEST_ENV_NUMBER'] = no == 1 ? '' : no.to_s process end thread.exit pop_stat(id) @rspec_configuration.output_stream.puts "Failures: " if ipc.llen("failure_#{id}") > 0 each_object("failure_#{id}") do |failure| dump_failure(failure) end log_elapsed_times dump_summary exit(results.all? ? 0 : 1) ensure if ipc ipc.del("to_run_#{id}") ipc.del("stat_#{id}") ipc.del("failure_#{id}") end end |