Class: TestRunner::TestEvaluator
- Inherits:
-
Object
- Object
- TestRunner::TestEvaluator
- Defined in:
- lib/test-runner/test_evaluator.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
protected
Returns the value of attribute config.
-
#machines ⇒ Object
readonly
Returns the value of attribute machines.
-
#opts ⇒ Object
readonly
protected
Returns the value of attribute opts.
-
#test ⇒ Object
readonly
protected
Returns the value of attribute test.
Instance Method Summary collapse
-
#breakpoint ⇒ Object
Invoke interactive shell from within a test.
- #do_run ⇒ Object protected
-
#initialize(test, **opts) ⇒ TestEvaluator
constructor
A new instance of TestEvaluator.
-
#interactive ⇒ Object
Run interactive shell.
-
#run ⇒ Object
Run the test script.
-
#start_all ⇒ Object
Start all machines.
- #test_script ⇒ Object protected
Constructor Details
#initialize(test, **opts) ⇒ TestEvaluator
Returns a new instance of TestEvaluator.
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 |
# File 'lib/test-runner/test_evaluator.rb', line 14 def initialize(test, **opts) @test = test @config = TestConfig.build(test) @opts = opts @machines = {} config[:machines].each do |name, cfg| var = :"@#{name}" m = OsVm::Machine.new( name, OsVm::MachineConfig.new(cfg), opts[:state_dir], opts[:sock_dir], default_timeout: opts[:default_timeout], hash_base: test.path ) instance_variable_set(var, m) define_singleton_method(name) do instance_variable_get(var) end machines[name] = m end end |
Instance Attribute Details
#config ⇒ Object (readonly, protected)
Returns the value of attribute config.
66 67 68 |
# File 'lib/test-runner/test_evaluator.rb', line 66 def config @config end |
#machines ⇒ Object (readonly)
Returns the value of attribute machines.
6 7 8 |
# File 'lib/test-runner/test_evaluator.rb', line 6 def machines @machines end |
#opts ⇒ Object (readonly, protected)
Returns the value of attribute opts.
66 67 68 |
# File 'lib/test-runner/test_evaluator.rb', line 66 def opts @opts end |
#test ⇒ Object (readonly, protected)
Returns the value of attribute test.
66 67 68 |
# File 'lib/test-runner/test_evaluator.rb', line 66 def test @test end |
Instance Method Details
#breakpoint ⇒ Object
Invoke interactive shell from within a test
60 61 62 |
# File 'lib/test-runner/test_evaluator.rb', line 60 def breakpoint binding.pry # rubocop:disable Lint/Debugger end |
#do_run ⇒ Object (protected)
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/test-runner/test_evaluator.rb', line 72 def do_run yield ensure machines.each_value do |m| m.kill m.destroy if opts[:destructive] m.finalize m.cleanup end end |
#interactive ⇒ Object
Run interactive shell
48 49 50 51 52 |
# File 'lib/test-runner/test_evaluator.rb', line 48 def interactive do_run do binding.pry # rubocop:disable Lint/Debugger end end |
#run ⇒ Object
Run the test script
41 42 43 44 45 |
# File 'lib/test-runner/test_evaluator.rb', line 41 def run do_run do test_script end end |
#start_all ⇒ Object
Start all machines
55 56 57 |
# File 'lib/test-runner/test_evaluator.rb', line 55 def start_all machines.each(&:start) end |
#test_script ⇒ Object (protected)
68 69 70 |
# File 'lib/test-runner/test_evaluator.rb', line 68 def test_script binding.eval(config[:testScript]) # rubocop:disable Security/Eval end |