Class: RSpec::MultiprocessRunner::CommandLineOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/multiprocess_runner/command_line_options.rb

Constant Summary collapse

DEFAULT_WORKER_COUNT =
3

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCommandLineOptions

Returns a new instance of CommandLineOptions.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rspec/multiprocess_runner/command_line_options.rb', line 14

def initialize
  self.worker_count = default_worker_count
  self.file_timeout_seconds = nil
  self.example_timeout_seconds = 15
  self.pattern = "**/*_spec.rb"
  self.log_failing_files = nil
  self.rspec_options = []
  self.first_is_1 = default_first_is_1
  self.use_given_order = false
  self.port = 2222
  self.hostname = "localhost"
  self.head_node = true
  self.max_nodes = 5
  self.summary_filename = ENV['SUMMARY_FILE']
end

Instance Attribute Details

#example_timeout_secondsObject

Returns the value of attribute example_timeout_seconds.



7
8
9
# File 'lib/rspec/multiprocess_runner/command_line_options.rb', line 7

def example_timeout_seconds
  @example_timeout_seconds
end

#explicit_files_or_directoriesObject

Returns the value of attribute explicit_files_or_directories.



7
8
9
# File 'lib/rspec/multiprocess_runner/command_line_options.rb', line 7

def explicit_files_or_directories
  @explicit_files_or_directories
end

#file_timeout_secondsObject

Returns the value of attribute file_timeout_seconds.



7
8
9
# File 'lib/rspec/multiprocess_runner/command_line_options.rb', line 7

def file_timeout_seconds
  @file_timeout_seconds
end

#first_is_1Object

Returns the value of attribute first_is_1.



7
8
9
# File 'lib/rspec/multiprocess_runner/command_line_options.rb', line 7

def first_is_1
  @first_is_1
end

#head_nodeObject

Returns the value of attribute head_node.



7
8
9
# File 'lib/rspec/multiprocess_runner/command_line_options.rb', line 7

def head_node
  @head_node
end

#hostnameObject

Returns the value of attribute hostname.



7
8
9
# File 'lib/rspec/multiprocess_runner/command_line_options.rb', line 7

def hostname
  @hostname
end

#log_failing_filesObject

Returns the value of attribute log_failing_files.



7
8
9
# File 'lib/rspec/multiprocess_runner/command_line_options.rb', line 7

def log_failing_files
  @log_failing_files
end

#max_nodesObject

Returns the value of attribute max_nodes.



7
8
9
# File 'lib/rspec/multiprocess_runner/command_line_options.rb', line 7

def max_nodes
  @max_nodes
end

#patternObject

Returns the value of attribute pattern.



7
8
9
# File 'lib/rspec/multiprocess_runner/command_line_options.rb', line 7

def pattern
  @pattern
end

#portObject

Returns the value of attribute port.



7
8
9
# File 'lib/rspec/multiprocess_runner/command_line_options.rb', line 7

def port
  @port
end

#rspec_optionsObject

Returns the value of attribute rspec_options.



7
8
9
# File 'lib/rspec/multiprocess_runner/command_line_options.rb', line 7

def rspec_options
  @rspec_options
end

#run_identifierObject

Returns the value of attribute run_identifier.



7
8
9
# File 'lib/rspec/multiprocess_runner/command_line_options.rb', line 7

def run_identifier
  @run_identifier
end

#summary_filenameObject

Returns the value of attribute summary_filename.



7
8
9
# File 'lib/rspec/multiprocess_runner/command_line_options.rb', line 7

def summary_filename
  @summary_filename
end

#use_given_orderObject

Returns the value of attribute use_given_order.



7
8
9
# File 'lib/rspec/multiprocess_runner/command_line_options.rb', line 7

def use_given_order
  @use_given_order
end

#worker_countObject

Returns the value of attribute worker_count.



7
8
9
# File 'lib/rspec/multiprocess_runner/command_line_options.rb', line 7

def worker_count
  @worker_count
end

Instance Method Details

#files_to_runObject



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/rspec/multiprocess_runner/command_line_options.rb', line 51

def files_to_run
  self.explicit_files_or_directories = %w(.) unless explicit_files_or_directories
  relative_root = Pathname.new('.')
  explicit_files_or_directories.map { |path| Pathname.new(path) }.flat_map do |path|
    if path.file?
      path.to_s
    else
      Dir[path.join(pattern).relative_path_from(relative_root)]
    end
  end
end

#parse(command_line_args, error_stream = $stderr) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/rspec/multiprocess_runner/command_line_options.rb', line 30

def parse(command_line_args, error_stream=$stderr)
  args = command_line_args.dup
  parser = build_parser

  begin
    parser.parse!(args)
  rescue OptionParser::ParseError => e
    error_stream.puts e.to_s
    error_stream.puts parser
    return nil
  end

  if help_requested?
    error_stream.puts parser
    return nil
  end

  extract_files_and_rspec_options(args)
  self
end