Class: Oncall::Core::Runner

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reporter = Oncall::Core.reporter, config = Oncall::Core.config, world = Oncall::Core.world) ⇒ Runner

Returns a new instance of Runner.



4
5
6
7
8
# File 'lib/oncall/core/runner.rb', line 4

def initialize(reporter=Oncall::Core.reporter, config=Oncall::Core.config, world=Oncall::Core.world)
  @config = config
  @world = world
  @reporter = reporter
end

Class Method Details

.invoke(args) ⇒ Object



10
11
12
13
# File 'lib/oncall/core/runner.rb', line 10

def self.invoke(args)
  status = run(args, $stderr, $stdout).to_i
  exit(status) if status != 0
end

.run(args, err = $stderr, out = $stdout) ⇒ Object



15
16
17
18
# File 'lib/oncall/core/runner.rb', line 15

def self.run(args, err=$stderr, out=$stdout)
  # TODO: init options class
  new.run(err, out)
end

Instance Method Details

#run(err, out) ⇒ Object



20
21
22
23
# File 'lib/oncall/core/runner.rb', line 20

def run(err, out)
  setup(err, out)
  run_tests(@world.suite)
end

#run_tests(suite) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/oncall/core/runner.rb', line 30

def run_tests(suite)
  @reporter.report(suite) do |reporter|
    suite.map { |g| g.run(reporter) }
  end

  @reporter.success? ? 0 : @config.failure_exit_code
end

#setup(err, out) ⇒ Object



25
26
27
28
# File 'lib/oncall/core/runner.rb', line 25

def setup(err, out)
  files = @config.test_files
  @world.register_suite(files)
end