Class: RSpec::MultiprocessRunner::RakeTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- RSpec::MultiprocessRunner::RakeTask
- Includes:
- Rake::DSL
- Defined in:
- lib/rspec/multiprocess_runner/rake_task.rb
Overview
Rake task to invoke ‘multispec`. Lots of it is copied from RSpec::Core::RakeTask.
Constant Summary collapse
- DEFAULT_MULTIRSPEC_PATH =
Default path to the multirspec executable.
File.('../../../../exe/multirspec', __FILE__)
Instance Attribute Summary collapse
-
#example_timeout_seconds ⇒ Object
The maximum number of seconds to allow a single example to run before killing it.
-
#fail_on_error ⇒ Object
Whether or not to fail Rake when an error occurs (typically when examples fail).
-
#failure_message ⇒ Object
A message to print to stderr when there are failures.
-
#file_timeout_seconds ⇒ Object
The maximum number of seconds to allow a single spec file to run before killing it.
-
#files_or_directories ⇒ Object
File search will be limited to these directories or specific files.
-
#first_is_1 ⇒ Object
If true, set TEST_ENV_NUMBER=“1” for the first worker (instead of “”).
-
#hostname ⇒ Object
Hostname of head node.
-
#log_failing_files ⇒ Object
Filename to which to append a list of the files containing specs that failed.
-
#max_nodes ⇒ Object
Max number of connections to head_node.
-
#multirspec_path ⇒ Object
Path to the multispec executable.
-
#name ⇒ Object
Name of task.
-
#node ⇒ Object
Be a node to a head node at hostname.
-
#pattern ⇒ Object
Files matching this pattern will be loaded.
-
#port ⇒ Object
Port to use for TCP communication.
-
#rspec_opts ⇒ Object
Command line options to pass to the RSpec workers.
-
#run_identifier ⇒ Object
Unique string used by nodes to confirm identity.
-
#use_given_order ⇒ Object
Use order of files as given on the command line.
-
#verbose ⇒ Object
Use verbose output.
-
#worker_count ⇒ Object
The number of workers to run.
Instance Method Summary collapse
-
#initialize(*args, &task_block) ⇒ RakeTask
constructor
A new instance of RakeTask.
- #run_task(verbose) ⇒ Object
Constructor Details
#initialize(*args, &task_block) ⇒ RakeTask
Returns a new instance of RakeTask.
83 84 85 86 87 88 89 90 |
# 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 |
Instance Attribute Details
#example_timeout_seconds ⇒ Object
The maximum number of seconds to allow a single example to run before killing it. Defaults to 15.
38 39 40 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 38 def example_timeout_seconds @example_timeout_seconds end |
#fail_on_error ⇒ Object
Whether or not to fail Rake when an error occurs (typically when examples fail). Defaults to ‘true`.
45 46 47 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 45 def fail_on_error @fail_on_error end |
#failure_message ⇒ Object
A message to print to stderr when there are failures.
48 49 50 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 48 def @failure_message end |
#file_timeout_seconds ⇒ Object
The maximum number of seconds to allow a single spec file to run before killing it. Defaults to disabled.
34 35 36 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 34 def file_timeout_seconds @file_timeout_seconds end |
#files_or_directories ⇒ Object
File search will be limited to these directories or specific files. Defaults to nil.
25 26 27 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 25 def files_or_directories @files_or_directories end |
#first_is_1 ⇒ Object
If true, set TEST_ENV_NUMBER=“1” for the first worker (instead of “”)
41 42 43 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 41 def first_is_1 @first_is_1 end |
#hostname ⇒ Object
Hostname of head node. Defaults to ‘localhost`
75 76 77 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 75 def hostname @hostname end |
#log_failing_files ⇒ Object
Filename to which to append a list of the files containing specs that failed.
60 61 62 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 60 def log_failing_files @log_failing_files end |
#max_nodes ⇒ Object
Max number of connections to head_node. Defaults to ‘5`
78 79 80 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 78 def max_nodes @max_nodes end |
#multirspec_path ⇒ Object
Path to the multispec executable. Defaults to the absolute path to the rspec binary from the loaded rspec-core gem.
56 57 58 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 56 def multirspec_path @multirspec_path end |
#name ⇒ Object
Name of task. Defaults to ‘:multispec`.
17 18 19 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 17 def name @name end |
#node ⇒ Object
Be a node to a head node at hostname. Defaults to ‘false`
72 73 74 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 72 def node @node end |
#pattern ⇒ Object
Files matching this pattern will be loaded. Defaults to ‘’*/_spec.rb’‘.
21 22 23 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 21 def pattern @pattern end |
#port ⇒ Object
Port to use for TCP communication. Defaults to ‘2222`.
69 70 71 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 69 def port @port end |
#rspec_opts ⇒ Object
Command line options to pass to the RSpec workers. Defaults to ‘nil`.
66 67 68 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 66 def rspec_opts @rspec_opts end |
#run_identifier ⇒ Object
Unique string used by nodes to confirm identity
81 82 83 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 81 def run_identifier @run_identifier end |
#use_given_order ⇒ Object
Use order of files as given on the command line
63 64 65 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 63 def use_given_order @use_given_order end |
#verbose ⇒ Object
Use verbose output. If this is set to true, the task will print the executed spec command to stdout. Defaults to ‘true`.
52 53 54 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 52 def verbose @verbose end |
#worker_count ⇒ Object
The number of workers to run. Defaults to 3.
30 31 32 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 30 def worker_count @worker_count end |
Instance Method Details
#run_task(verbose) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 |
# 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 if return unless fail_on_error $stderr.puts "#{command} failed" if verbose exit $?.exitstatus end |