mirror of
https://github.com/inspec/inspec
synced 2024-09-21 06:51:56 +00:00
move to test runner with multiple backends
This commit is contained in:
parent
cafa45e84e
commit
bd00ab93a4
6 changed files with 55 additions and 49 deletions
|
@ -4,7 +4,7 @@ driver:
|
|||
|
||||
provisioner:
|
||||
name: chef_solo
|
||||
data_path: ../../../.
|
||||
data_path: ../../.
|
||||
|
||||
platforms:
|
||||
- name: centos-7.1
|
|
@ -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
|
|
@ -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
28
test/runner/test.rb
Normal 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
|
25
test/runner/tests/run_command_test.rb
Normal file
25
test/runner/tests/run_command_test.rb
Normal 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
|
Loading…
Reference in a new issue