78 lines
2.5 KiB
Ruby
78 lines
2.5 KiB
Ruby
require 'puppetlabs_spec_helper/rake_tasks'
|
|
require 'puppet-lint/tasks/puppet-lint'
|
|
require 'puppet-syntax/tasks/puppet-syntax'
|
|
require 'metadata-json-lint/rake_task'
|
|
|
|
PuppetLint.configuration.fail_on_warnings = true
|
|
PuppetLint.configuration.send('disable_80chars')
|
|
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
|
|
PuppetLint.configuration.send('disable_class_parameter_defaults')
|
|
|
|
exclude_paths = [
|
|
"pkg/**/*",
|
|
"vendor/**/*",
|
|
"spec/**/*",
|
|
]
|
|
PuppetLint.configuration.ignore_paths = exclude_paths
|
|
PuppetSyntax.exclude_paths = exclude_paths
|
|
|
|
desc "Run metadata_lint, lint, syntax, and spec tests."
|
|
task :test => [
|
|
:metadata_lint,
|
|
:lint,
|
|
:syntax,
|
|
:spec,
|
|
]
|
|
|
|
LUA_TESTS = Rake::FileList.new("tests/**/test_*.lua")
|
|
desc "Run Lua unit tests."
|
|
task :lua_tests => [:lua_5_1, :lua_libraries, :lib_cbuf] do |t|
|
|
LUA_TESTS.each do |f|
|
|
sh "lua5.1 #{f}"
|
|
end
|
|
end
|
|
|
|
task :lua_5_1 do |t|
|
|
sh "lua5.1", "-v", {:verbose => false} do |ok, res|
|
|
if ! ok then
|
|
raise "lua5.1 needs to be installed!"
|
|
end
|
|
end
|
|
end
|
|
|
|
# Need to pull date_time.lua from the lua_sandbox repository because some tests
|
|
# depend on it indirectly
|
|
task :lua_libraries => ['tests/lua/mocks/date_time.lua', 'tests/lua/mocks/inspect.lua']
|
|
|
|
file 'tests/lua/mocks/date_time.lua' do |t|
|
|
sh "curl", "-s", "-o", t.name, "https://raw.githubusercontent.com/mozilla-services/lua_sandbox/dev/modules/date_time.lua" do |ok, res|
|
|
if ! ok then
|
|
raise "Fail to download date_time.lua from lua_sandbox repository!"
|
|
end
|
|
end
|
|
end
|
|
|
|
file 'tests/lua/mocks/inspect.lua' do |t|
|
|
sh "curl", "-s", "-o", t.name, "https://raw.githubusercontent.com/kikito/inspect.lua/master/inspect.lua" do |ok, res|
|
|
if ! ok then
|
|
raise "Fail to download inspect.lua from gitub repository!"
|
|
end
|
|
end
|
|
end
|
|
|
|
# Need to pull circular_buffer library from mozilla Github and compile it
|
|
task :lib_cbuf => ['./circular_buffer.so']
|
|
|
|
file './circular_buffer.so' do |t|
|
|
sh %{cd /tmp && rm -rf lua_circular_buffer && git clone https://github.com/mozilla-services/lua_circular_buffer.git && cd lua_circular_buffer && mkdir release && cd release && cmake -DCMAKE_BUILD_TYPE=release .. && make} do |ok, res|
|
|
if ! ok then
|
|
raise "failed to compile circular_buffer!"
|
|
end
|
|
end
|
|
sh %{cp /tmp/lua_circular_buffer/release/circular_buffer.so .} do |ok, res|
|
|
if ! ok then
|
|
raise "failed bloom_filter to compule!"
|
|
end
|
|
end
|
|
end
|