Class: TurboTests::Runner
- Inherits:
-
Object
- Object
- TurboTests::Runner
- Defined in:
- lib/turbo_tests/runner.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(opts) ⇒ Runner
constructor
A new instance of Runner.
- #run ⇒ Object
Constructor Details
#initialize(opts) ⇒ Runner
Returns a new instance of Runner.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/turbo_tests/runner.rb', line 51 def initialize(opts) @reporter = opts[:reporter] @files = opts[:files] @verbose = opts[:verbose] @fail_fast = opts[:fail_fast] @use_runtime_info = opts[:use_runtime_info] @seed = opts[:seed] @profile = opts[:profile] @failure_count = 0 @messages = Queue.new @threads = [] @error = false end |
Class Method Details
.default_spec_folders ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/turbo_tests/runner.rb', line 43 def self.default_spec_folders # We do not want to include system specs by default, they are quite slow. Dir .entries("#{Rails.root}/spec") .reject { |entry| !File.directory?("spec/#{entry}") || %w[.. . system].include?(entry) } .map { |entry| "spec/#{entry}" } end |
.run(opts = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/turbo_tests/runner.rb', line 5 def self.run(opts = {}) files = opts[:files] formatters = opts[:formatters] seed = opts[:seed] start_time = opts.fetch(:start_time) { Time.now } verbose = opts.fetch(:verbose, false) fail_fast = opts.fetch(:fail_fast, nil) use_runtime_info = opts.fetch(:use_runtime_info, false) STDOUT.puts "VERBOSE" if verbose reporter = Reporter.from_config( formatters, start_time, max_timings_count: opts[:profile_print_slowest_examples_count], ) if ENV["GITHUB_ACTIONS"] RSpec.configure do |config| # Enable color output in GitHub Actions # This eventually will be `config.color_mode = :on` in RSpec 4? config.tty = true config.color = true end end new( reporter: reporter, files: files, verbose: verbose, fail_fast: fail_fast, use_runtime_info: use_runtime_info, seed: seed, profile: opts[:profile], ).run end |
Instance Method Details
#run ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/turbo_tests/runner.rb', line 66 def run check_for_migrations @num_processes = ParallelTests.determine_number_of_processes(nil) group_opts = {} group_opts[:runtime_log] = "tmp/turbo_rspec_runtime.log" if @use_runtime_info tests_in_groups = ParallelTests::RSpec::Runner.tests_in_groups(@files, @num_processes, **group_opts) setup_tmp_dir subprocess_opts = { record_runtime: @use_runtime_info } start_multisite_subprocess(@files, **subprocess_opts) tests_in_groups.each_with_index do |tests, process_id| start_regular_subprocess(tests, process_id + 1, **subprocess_opts) end @reporter.finish @threads.each(&:join) @reporter.failed_examples.empty? && !@error end |