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 “”).
-
#log_failing_files ⇒ Object
Filename to which to append a list of the files containing specs that failed.
-
#multirspec_path ⇒ Object
Path to the multispec executable.
-
#name ⇒ Object
Name of task.
-
#pattern ⇒ Object
Files matching this pattern will be loaded.
-
#rspec_opts ⇒ Object
Command line options to pass to the RSpec workers.
-
#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.
65 66 67 68 69 70 71 72 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 65 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 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 |
#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 |
#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 |
#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 |
#rspec_opts ⇒ Object
Command line options to pass to the RSpec workers. Defaults to ‘nil`.
63 64 65 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 63 def rspec_opts @rspec_opts 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
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/rspec/multiprocess_runner/rake_task.rb', line 75 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 |