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 ⇒ Hash<String, OsVm::Machine> readonly
-
#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.
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 |
# File 'lib/test-runner/test_evaluator.rb', line 15 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.to_s, 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.
67 68 69 |
# File 'lib/test-runner/test_evaluator.rb', line 67 def config @config end |
#machines ⇒ Hash<String, OsVm::Machine> (readonly)
7 8 9 |
# File 'lib/test-runner/test_evaluator.rb', line 7 def machines @machines end |
#opts ⇒ Object (readonly, protected)
Returns the value of attribute opts.
67 68 69 |
# File 'lib/test-runner/test_evaluator.rb', line 67 def opts @opts end |
#test ⇒ Object (readonly, protected)
Returns the value of attribute test.
67 68 69 |
# File 'lib/test-runner/test_evaluator.rb', line 67 def test @test end |
Instance Method Details
#breakpoint ⇒ Object
Invoke interactive shell from within a test
61 62 63 |
# File 'lib/test-runner/test_evaluator.rb', line 61 def breakpoint binding.pry # rubocop:disable Lint/Debugger end |
#do_run ⇒ Object (protected)
73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/test-runner/test_evaluator.rb', line 73 def do_run yield machines.each_value do |m| m.stop if m.running? end ensure machines.each_value do |m| m.kill m.destroy if opts[:destructive] m.finalize m.cleanup end end |
#interactive ⇒ Object
Run interactive shell
49 50 51 52 53 |
# File 'lib/test-runner/test_evaluator.rb', line 49 def interactive do_run do binding.pry # rubocop:disable Lint/Debugger end end |
#run ⇒ Object
Run the test script
42 43 44 45 46 |
# File 'lib/test-runner/test_evaluator.rb', line 42 def run do_run do test_script end end |
#start_all ⇒ Object
Start all machines
56 57 58 |
# File 'lib/test-runner/test_evaluator.rb', line 56 def start_all machines.each(&:start) end |
#test_script ⇒ Object (protected)
69 70 71 |
# File 'lib/test-runner/test_evaluator.rb', line 69 def test_script binding.eval(config[:testScript]) # rubocop:disable Security/Eval end |