Class: UIAuto::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/uiauto/runner.rb

Class Method Summary collapse

Class Method Details

.run(file_or_dir, options = {}) ⇒ Object



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
36
37
38
39
40
# File 'lib/uiauto/runner.rb', line 9

def self.run(file_or_dir, options = {})
  if options[:require]
    require File.expand_path(options[:require])
  end

  @reporter = Reporter.new
  @exit_status_listener = Listeners::ExitStatusListener.new
  @reporter.add_listener(@exit_status_listener)

  listeners = options[:listeners] || []
  listeners.each do |listener|
    @reporter.add_listener(listener)
  end

  formatter = eval("Formatters::#{options[:format]}.new")
  @reporter.formatter = formatter

  @reporter.run_start

  exit_status = 0
  if file_or_dir.nil?
    self.run_one options
  elsif File.directory?(file_or_dir)
    self.run_all(file_or_dir, options)
  else
    self.run_one(file_or_dir, options)
  end

  @reporter.run_finish

  exit @exit_status_listener.result
end