move to test runner with multiple backends

This commit is contained in:
Dominik Richter 2015-09-14 16:34:58 +02:00
parent cafa45e84e
commit bd00ab93a4
6 changed files with 55 additions and 49 deletions

View file

@ -4,7 +4,7 @@ driver:
provisioner:
name: chef_solo
data_path: ../../../.
data_path: ../../.
platforms:
- name: centos-7.1

View file

@ -5,6 +5,6 @@ execute 'bundle install' do
end
execute 'run tests' do
command '/opt/chef/embedded/bin/ruby -I lib test/runner/local_test.d/test.rb'
command '/opt/chef/embedded/bin/ruby -I lib test/runner/test.rb'
cwd '/tmp/kitchen/data'
end

View file

@ -1,47 +0,0 @@
require 'minitest/autorun'
require 'minitest/spec'
require 'vulcano/backend'
backends = {
:local => proc {
backend_conf = Vulcano::Backend.target_config({})
backend_class = Vulcano::Backend.registry['local']
backend_class.new(backend_conf)
},
:specinfra_local => proc {
backend_conf = Vulcano::Backend.target_config({
'backend' => 'exec',
})
backend_class = Vulcano::Backend.registry['specinfra']
backend_class.new(backend_conf)
},
}
backends.each do |type, get_backend|
puts "run on backend #{type.to_s}"
describe 'run_command' do
let(:backend) { get_backend.call() }
it 'can echo commands' do
res = backend.run_command('echo hello world')
res.stdout.must_equal("hello world\n")
res.stderr.must_equal('')
res.exit_status.must_equal(0)
end
it 'can echo commands to stderr' do
res = backend.run_command('>&2 echo hello world')
res.stdout.must_equal('')
res.stderr.must_equal("hello world\n")
res.exit_status.must_equal(0)
end
it 'prints a correct exit status' do
res = backend.run_command('exit 123')
res.stdout.must_equal('')
res.stderr.must_equal('')
res.exit_status.must_equal(123)
end
end
end

28
test/runner/test.rb Normal file
View file

@ -0,0 +1,28 @@
require 'minitest/autorun'
require 'minitest/spec'
require 'vulcano/backend'
backends = {}
backends[:local] = proc {
backend_conf = Vulcano::Backend.target_config({})
backend_class = Vulcano::Backend.registry['local']
backend_class.new(backend_conf)
}
backends[:specinfra_local] = proc {
backend_conf = Vulcano::Backend.target_config({
'backend' => 'exec',
})
backend_class = Vulcano::Backend.registry['specinfra']
backend_class.new(backend_conf)
}
tests = ARGV
backends.each do |type, get_backend|
puts "run on backend #{type.to_s}"
tests.each do |test|
instance_eval(File.read(test))
end
end

View file

@ -0,0 +1,25 @@
describe 'run_command' do
let(:backend) { get_backend.call() }
it 'can echo commands' do
res = backend.run_command('echo hello world')
res.stdout.must_equal("hello world\n")
res.stderr.must_equal('')
res.exit_status.must_equal(0)
end
it 'can echo commands to stderr' do
res = backend.run_command('>&2 echo hello world')
res.stdout.must_equal('')
res.stderr.must_equal("hello world\n")
res.exit_status.must_equal(0)
end
it 'prints a correct exit status' do
res = backend.run_command('exit 123')
res.stdout.must_equal('')
res.stderr.must_equal('')
res.exit_status.must_equal(123)
end
end