Class: TestSuiteSplitter::Cli

Inherits:
Object
  • Object
show all
Defined in:
lib/test_suite_splitter/cli.rb

Constant Summary collapse

DEFAULT_LOG_FILE_PATH =
"log/test_suite_splitter.log".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv:, stderr: $stderr, stdout: $stdout) ⇒ Cli

Returns a new instance of Cli.



6
7
8
9
10
# File 'lib/test_suite_splitter/cli.rb', line 6

def initialize(argv:, stderr: $stderr, stdout: $stdout)
  @argv = argv
  @stderr = stderr
  @stdout = stdout
end

Instance Attribute Details

#argvObject (readonly)

Returns the value of attribute argv.



4
5
6
# File 'lib/test_suite_splitter/cli.rb', line 4

def argv
  @argv
end

#stderrObject (readonly)

Returns the value of attribute stderr.



4
5
6
# File 'lib/test_suite_splitter/cli.rb', line 4

def stderr
  @stderr
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



4
5
6
# File 'lib/test_suite_splitter/cli.rb', line 4

def stdout
  @stdout
end

Instance Method Details

#execute_rspec_commandObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/test_suite_splitter/cli.rb', line 19

def execute_rspec_command
  files = group_file_paths

  if files.empty?
    print_output("No files from test_suite_splitter - skipping shard")
    return 0
  end

  require "rspec/core"

  RSpec::Core::Runner.run(rspec_arguments + files, stderr, stdout)
rescue StandardError => e
  handle_error(e)
end

#execute_splitter_commandObject



12
13
14
15
16
17
# File 'lib/test_suite_splitter/cli.rb', line 12

def execute_splitter_command
  print_output(group_file_paths.join(" "))
  0
rescue StandardError => e
  handle_error(e)
end

#group_file_pathsObject



34
35
36
# File 'lib/test_suite_splitter/cli.rb', line 34

def group_file_paths
  rspec_helper.group_files.map { |group_file| group_file.fetch(:path) }
end