Class: TestBench::Executor

Inherits:
Object
  • Object
show all
Defined in:
lib/test_bench/executor.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(binding, kernel) ⇒ Executor

Returns a new instance of Executor.



6
7
8
9
# File 'lib/test_bench/executor.rb', line 6

def initialize binding, kernel
  @binding = binding
  @kernel = kernel
end

Instance Attribute Details

#bindingObject (readonly)

Returns the value of attribute binding.



3
4
5
# File 'lib/test_bench/executor.rb', line 3

def binding
  @binding
end

#kernelObject (readonly)

Returns the value of attribute kernel.



4
5
6
# File 'lib/test_bench/executor.rb', line 4

def kernel
  @kernel
end

Class Method Details

.buildObject



11
12
13
14
15
# File 'lib/test_bench/executor.rb', line 11

def self.build
  binding = TOPLEVEL_BINDING

  new binding, Kernel
end

Instance Method Details

#call(files) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/test_bench/executor.rb', line 17

def call files
  files.each do |file|
    execute file
  end

  telemetry.passed?
end

#execute(file) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/test_bench/executor.rb', line 25

def execute file
  telemetry.file_started file

  begin
    unbound_context_method = TestBench::Structure.instance_method :context
    bound_context_method = unbound_context_method.bind binding.receiver

    bound_context_method.call :suppress_exit => true do
      kernel.load File.expand_path file
    end

  ensure
    telemetry.file_finished file
  end
end

#telemetryObject



41
42
43
# File 'lib/test_bench/executor.rb', line 41

def telemetry
  Telemetry::Registry.get binding
end