Class: TestBoosters::Boosters::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/test_boosters/boosters/base.rb

Direct Known Subclasses

Cucumber, ExUnit, GoTest, Minitest, Rspec

Instance Method Summary collapse

Constructor Details

#initialize(file_pattern, exclude_pattern, split_configuration_path, command) ⇒ Base

Returns a new instance of Base.



5
6
7
8
9
10
# File 'lib/test_boosters/boosters/base.rb', line 5

def initialize(file_pattern, exclude_pattern, split_configuration_path, command)
  @command = command
  @file_pattern = file_pattern
  @exclude_pattern = exclude_pattern
  @split_configuration_path = split_configuration_path
end

Instance Method Details

#after_jobObject



49
50
51
# File 'lib/test_boosters/boosters/base.rb', line 49

def after_job
  # Do nothing
end

#before_jobObject



45
46
47
# File 'lib/test_boosters/boosters/base.rb', line 45

def before_job
  # Do nothing
end

#display_headerObject



53
54
55
56
57
58
# File 'lib/test_boosters/boosters/base.rb', line 53

def display_header
  version = "Test Booster v#{TestBoosters::VERSION}"
  job_info = "Job #{job_index + 1} out of #{job_count}"

  TestBoosters::Shell.display_title("#{version} - #{job_info}")
end

#distributionObject



60
61
62
63
64
65
# File 'lib/test_boosters/boosters/base.rb', line 60

def distribution
  @distribution ||= TestBoosters::Files::Distributor.new(@split_configuration_path,
                                                         @file_pattern,
                                                         @exclude_pattern,
                                                         job_count)
end

#job_countObject



71
72
73
# File 'lib/test_boosters/boosters/base.rb', line 71

def job_count
  @job_count ||= cli_options[:job_count]
end

#job_indexObject



67
68
69
# File 'lib/test_boosters/boosters/base.rb', line 67

def job_index
  @job_index ||= cli_options[:job_index] - 1
end

#runObject

:reek:TooManyStatements



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/test_boosters/boosters/base.rb', line 13

def run
  display_header

  before_job # execute some activities when the before the job starts

  distribution.display_info

  known, leftover = distribution.files_for(job_index)

  if cli_options[:dry_run]
    show_files_for_dry_run("known", known)
    show_files_for_dry_run("leftover", leftover)
    return 0
  end

  exit_status = TestBoosters::Job.run(@command, known, leftover)

  after_job # execute some activities when the job finishes

  exit_status
end

#show_files_for_dry_run(label, files) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/test_boosters/boosters/base.rb', line 35

def show_files_for_dry_run(label, files)
  if files.empty?
    puts "[DRY RUN] No #{label} files."
    return
  end

  puts "\n[DRY RUN] Running tests for #{label} files:"
  puts files.map { |file| "- #{file}" }.join("\n")
end