def check(filelist)
raise "Expected an array of files" unless filelist.is_a?(Array)
require 'puppet'
require 'puppet/face'
output = []
if (Puppet::PUPPETVERSION.to_i >= 3 && !Puppet.settings.app_defaults_initialized?)
Puppet.initialize_settings
end
Puppet::Util::Log.newdestination(Puppet::Test::LogCollector.new(output))
Puppet::Util::Log.level = :warning
filelist.each do |puppet_file|
begin
validate_manifest(puppet_file)
rescue SystemExit
rescue => error
output << error
end
end
Puppet::Util::Log.close_all
output.map! { |e| e.to_s }
output.reject! { |e|
e =~ /^You cannot collect( exported resources)? without storeconfigs being set/
}
output.reject! { |e|
e =~ /^tag is a metaparam; this value will inherit to all contained resources in the /
}
deprecations = output.select { |e|
e =~ /^Deprecation notice:|is deprecated/
}
has_errors = (output != deprecations)
return output, has_errors
end