class RSpec::MultiprocessRunner::RakeTask
Rake task to invoke `multispec`. Lots of it is copied from RSpec::Core::RakeTask.
@see Rakefile
Constants
- DEFAULT_MULTIRSPEC_PATH
Default path to the multirspec executable.
Attributes
File search will be limited to these directories or specific files. Defaults to nil.
The maximum number of seconds to allow a single example to run before killing it. Defaults to 15.
Whether or not to fail Rake when an error occurs (typically when examples fail). Defaults to `true`.
A message to print to stderr when there are failures.
The maximum number of seconds to allow a single spec file to run before killing it. Defaults to disabled.
File search will be limited to these directories or specific files. Defaults to nil.
File search will be limited to these directories or specific files. Defaults to nil.
If true, set TEST_ENV_NUMBER=“1” for the first worker (instead of “”)
Hostname of head node. Defaults to `localhost`
Filename to which to append a list of the files containing specs that failed.
Max number of connections to head_node. Defaults to `5`
Path to the multispec executable. Defaults to the absolute path to the rspec binary from the loaded rspec-core gem.
Name of task. Defaults to `:multispec`.
Be a node to a head node at hostname. Defaults to `false`
Files matching this pattern will be loaded. Defaults to `'*/_spec.rb'`.
Port to use for TCP communication. Defaults to `2222`.
Command line options to pass to the RSpec
workers. Defaults to `nil`.
Unique string used by nodes to confirm identity
Use order of files as given on the command line
Use verbose output. If this is set to true, the task will print the executed spec command to stdout. Defaults to `true`.
The number of workers to run. Defaults to 3.
Public Class Methods
# File lib/rspec/multiprocess_runner/rake_task.rb, line 83 def initialize(*args, &task_block) @name = args.shift || :multispec @verbose = true @fail_on_error = true @multirspec_path = DEFAULT_MULTIRSPEC_PATH define(args, &task_block) end
Public Instance Methods
@private
# File lib/rspec/multiprocess_runner/rake_task.rb, line 93 def run_task(verbose) command = spec_command puts Shellwords.shelljoin(command) if verbose return if system(*command) puts failure_message if failure_message return unless fail_on_error $stderr.puts "#{command} failed" if verbose exit $?.exitstatus end
Private Instance Methods
@private
# File lib/rspec/multiprocess_runner/rake_task.rb, line 108 def define(args, &task_block) desc "Run RSpec code examples" unless ::Rake.application.last_description task name, *args do |_, task_args| RakeFileUtils.__send__(:verbose, verbose) do task_block.call(*[self, task_args].slice(0, task_block.arity)) if task_block run_task verbose end end end
# File lib/rspec/multiprocess_runner/rake_task.rb, line 119 def spec_command cmd_parts = [] cmd_parts << RUBY cmd_parts << multirspec_path if worker_count cmd_parts << '--worker-count' << worker_count.to_s end if example_timeout_seconds cmd_parts << '--example-timeout' << example_timeout_seconds.to_s end if file_timeout_seconds cmd_parts << '--file-timeout' << file_timeout_seconds.to_s end if first_is_1 cmd_parts << '--first-is-1' end if pattern cmd_parts << '--pattern' << pattern end if log_failing_files cmd_parts << '--log-failing-files' << log_failing_files end if use_given_order cmd_parts << '--use-given-order' end if port cmd_parts << '--port' << port.to_s end if node cmd_parts << '--node' end if hostname cmd_parts << '--hostname' << hostname end if max_nodes cmd_parts << '--max-nodes' << max_nodes.to_s end if run_identifier cmd_parts << '--run-identifier' << run_identifier.to_s end if files_or_directories cmd_parts.concat(files_or_directories) end if rspec_opts cmd_parts << '--' cmd_parts.concat(Shellwords.shellsplit rspec_opts) end cmd_parts end