Module: TestBench::CLI

Defined in:
lib/test_bench/cli.rb,
lib/test_bench/cli/parse_arguments.rb

Defined Under Namespace

Modules: Defaults Classes: ParseArguments

Class Method Summary collapse

Class Method Details

.call(tests_directory = nil, exclude_file_pattern: nil) ⇒ Object



3
4
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
# File 'lib/test_bench/cli.rb', line 3

def self.call(tests_directory=nil, exclude_file_pattern: nil)
  tests_directory ||= Defaults.tests_directory

  path_arguments = ParseArguments.()

  read_stdin = $stdin.stat.pipe?

  if read_stdin && $stdin.eof?
    STDERR.puts "$stdin is a pipe, but no data was written to it; no test files will be run"
  end

  Run.(exclude: exclude_file_pattern) do |run|
    if read_stdin
      until $stdin.eof?
        path = $stdin.gets.chomp

        next if path.empty?

        run.path(path)
      end
    end

    if path_arguments.empty?
      unless read_stdin
        run.path(tests_directory)
      end
    else
      path_arguments.each do |path|
        run.path(path)
      end
    end
  end
end