Class: TurboTests::CLI
- Inherits:
-
Object
- Object
- TurboTests::CLI
- Defined in:
- lib/turbo_tests/cli.rb
Instance Method Summary collapse
-
#initialize(argv) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
Constructor Details
#initialize(argv) ⇒ CLI
Returns a new instance of CLI.
7 8 9 |
# File 'lib/turbo_tests/cli.rb', line 7 def initialize(argv) @argv = argv end |
Instance Method Details
#run ⇒ Object
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 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 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/turbo_tests/cli.rb', line 11 def run requires = [] formatters = [] = [] count = nil runtime_log = nil verbose = false fail_fast = nil seed = nil OptionParser.new { |opts| opts. = <<~BANNER Run all tests in parallel, giving each process ENV['TEST_ENV_NUMBER'] ('1', '2', '3', ...). Reports test results incrementally. Uses methods from `parallel_tests` gem to split files to groups. Source code of `turbo_tests` gem is based on Discourse and RubyGems work in this area (see README file of the source repository). Usage: turbo_tests [options] [optional] Only selected files & folders: turbo_tests spec/bar spec/baz/xxx_spec.rb Options: BANNER opts.on("-n [PROCESSES]", Integer, "How many processes to use, default: available CPUs") { |n| count = n } opts.on("-r", "--require PATH", "Require a file.") do |filename| requires << filename end opts.on("-f", "--format FORMATTER", "Choose a formatter. Available formatters: progress (p), documentation (d). Default: progress") do |name| formatters << { name: name, outputs: [] } end opts.on("-t", "--tag TAG", "Run examples with the specified tag.") do |tag| << tag end opts.on("-o", "--out FILE", "Write output to a file instead of $stdout") do |filename| if formatters.empty? formatters << { name: "progress", outputs: [] } end formatters.last[:outputs] << filename end opts.on("--runtime-log FILE", "Location of previously recorded test runtimes") do |filename| runtime_log = filename end opts.on("-v", "--verbose", "More output") do verbose = true end opts.on("--fail-fast=[N]") do |n| n = begin Integer(n) rescue nil end fail_fast = n.nil? || n < 1 ? 1 : n end opts.on("--seed SEED", "Seed for rspec") do |s| seed = s end }.parse!(@argv) requires.each { |f| require(f) } if formatters.empty? formatters << { name: "progress", outputs: [] } end formatters.each do |formatter| if formatter[:outputs].empty? formatter[:outputs] << "-" end end exitstatus = TurboTests::Runner.run( formatters: formatters, tags: , files: @argv.empty? ? ["spec"] : @argv, runtime_log: runtime_log, verbose: verbose, fail_fast: fail_fast, count: count, seed: seed ) # From https://github.com/serpapi/turbo_tests/pull/20/ exit exitstatus end |