module TestBench::CLI

Public Class Methods

call(tests_directory=nil, exclude_file_pattern: nil) click to toggle source
# 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