3
4
5
6
7
8
9
10
11
12
13
14
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/puppet-syntax/manifests.rb', line 3
def check(filelist)
raise "Expected an array of files" unless filelist.is_a?(Array)
require 'puppet'
require 'puppet/face'
require 'puppet/test/test_helper'
output = []
if Puppet::Test::TestHelper.respond_to?(:initialize) Puppet::Test::TestHelper.initialize
end
Puppet::Test::TestHelper.before_all_tests
called_before_all_tests = true
Puppet::Util::Log.newdestination(Puppet::Test::LogCollector.new(output))
Puppet::Util::Log.level = :warning
filelist.each do |puppet_file|
Puppet::Test::TestHelper.before_each_test
begin
validate_manifest(puppet_file)
rescue SystemExit
rescue => error
output << error
ensure
Puppet::Test::TestHelper.after_each_test
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
ensure
Puppet::Test::TestHelper.after_all_tests if called_before_all_tests
end
|