Class: Flatware::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/flatware/cli.rb,
lib/flatware/rspec/cli.rb,
lib/flatware/cucumber/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.processorsObject



6
7
8
# File 'lib/flatware/cli.rb', line 6

def self.processors
  @processors ||= ProcessorInfo.count
end

.worker_optionObject



10
11
12
# File 'lib/flatware/cli.rb', line 10

def self.worker_option
  method_option :workers, aliases: "-w", type: :numeric, default: processors, desc: "Number of concurent processes to run"
end

Instance Method Details

#clearObject



33
34
35
36
37
# File 'lib/flatware/cli.rb', line 33

def clear
  (Flatware.pids - [$$]).each do |pid|
    Process.kill 6, pid
  end
end

#cucumber(*args) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/flatware/cucumber/cli.rb', line 9

def cucumber(*args)
  config = Cucumber.configure args

  unless config.jobs.any?
    puts "Please create some feature files in the #{config.feature_dir} directory."
    exit 1
  end

  Flatware.verbose = options[:log]
  Worker.spawn count: workers, runner: Cucumber, dispatch: options['dispatch-endpoint'], sink: options['sink-endpoint']
  start_sink jobs: config.jobs, workers: workers, formatter: Flatware::Cucumber::Formatters::Console.new($stdout, $stderr)
end

#fan(*command) ⇒ Object



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

def fan(*command)
  Flatware.verbose = options[:log]

  command = command.join(" ")
  puts "Running '#{command}' on #{workers} workers"

  workers.times do |i|
    fork do
      exec({"TEST_ENV_NUMBER" => i.to_s}, command)
    end
  end
  Process.waitall
end

#rspec(*rspec_args) ⇒ Object



9
10
11
12
13
14
# File 'lib/flatware/rspec/cli.rb', line 9

def rspec(*rspec_args)
  jobs = RSpec.extract_jobs_from_args rspec_args, workers: workers
  Flatware.verbose = options[:log]
  Worker.spawn count: workers, runner: RSpec, dispatch: options['dispatch-endpoint'], sink: options['sink-endpoint']
  start_sink jobs: jobs, workers: workers, formatter: Flatware::RSpec::Formatters::Console.new($stdout, $stderr)
end