puppet-check 2.5.0 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/puppet-check/data_parser.rb +2 -2
- data/lib/puppet-check/puppet_parser.rb +3 -3
- data/lib/puppet_check.rb +4 -4
- data/puppet-check.gemspec +1 -1
- data/spec/puppet-check/cli_spec.rb +2 -2
- data/spec/puppet-check/data_parser_spec.rb +38 -38
- data/spec/puppet-check/puppet_parser_spec.rb +31 -31
- data/spec/puppet-check/regression_check_spec.rb +6 -6
- data/spec/puppet-check/rspec_puppet_support_spec.rb +5 -5
- data/spec/puppet-check/ruby_parser_spec.rb +33 -33
- data/spec/puppet-check/tasks_spec.rb +3 -3
- data/spec/puppet_check_spec.rb +5 -5
- data/spec/spec_helper.rb +3 -16
- data/spec/system/system_spec.rb +5 -5
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a3c5911fe2362e7462d111f97705eea6b60842ce107bb94d35e6f8657cea6812
|
|
4
|
+
data.tar.gz: 52413822ec2375afd5fab3bb933220ad15bbcab285641f6717d94057c7fe0554
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fa0c790ee8186c5d1f2eb7091c78d789c68fef7d16292fe3a70c3d41a41d1eb65c3ece36462578bfe2874bb236316fa9b5737f7316f6902d1017bb15c182cf0a
|
|
7
|
+
data.tar.gz: 87e82df7685a13f4122838b225ef8e44d8de30b9e14f8cbb75577b76074fff5f40ca895c7bef00a7648862abba1edc31d5e237b0cb4ba8e0e5e1eb5aa4486304
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
### 2.5.1
|
|
2
|
+
- Fix explicit `fail_on_warnings` default value assignment.
|
|
3
|
+
- Improve message transformation for Puppet::Face errors and warnings.
|
|
4
|
+
- Improve EYAML certification validation check.
|
|
5
|
+
- Verify that files to be validated are readable by current user.
|
|
6
|
+
- Fix Puppet 5.4-6.4 syntax error output format.
|
|
7
|
+
|
|
1
8
|
### 2.5.0
|
|
2
9
|
- Minimum Ruby version increased to 3.1.
|
|
3
10
|
- Minimum Puppet-Lint increased to 5.0.
|
|
@@ -33,9 +33,9 @@ class DataParser
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
# keys exist?
|
|
36
|
-
unless File.
|
|
36
|
+
unless File.readable?(public) && File.readable?(private)
|
|
37
37
|
PuppetCheck.files[:ignored].concat(files)
|
|
38
|
-
return warn 'Specified Public X509 and/or Private RSA PKCS7 certs do not exist. EYAML checks will not be executed.'
|
|
38
|
+
return warn 'Specified Public X509 and/or Private RSA PKCS7 certs do not exist or are not readable. EYAML checks will not be executed.'
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
# setup decryption
|
|
@@ -32,12 +32,12 @@ class PuppetParser
|
|
|
32
32
|
new_error = Puppet::Face[:parser, :current].validate(file)
|
|
33
33
|
# puppet 6.5 output format is now a hash from the face api
|
|
34
34
|
if Gem::Version.new(Puppet::PUPPETVERSION) >= Gem::Version.new('6.5.0') && new_error != {}
|
|
35
|
-
messages.concat(new_error.values.map(&:to_s).map { |error| error.gsub(
|
|
35
|
+
messages.concat(new_error.values.map(&:to_s).map { |error| error.gsub(Regexp.escape(" (file: #{File.absolute_path(file)}(, |))"), '') }.map { |error| error.gsub('Could not parse for environment *root*: ', '') })
|
|
36
36
|
end
|
|
37
37
|
# this is the actual error that we need to rescue Puppet::Face from
|
|
38
38
|
rescue SystemExit
|
|
39
39
|
# puppet 5.4-6.4 has a new validator output format and eof errors have fake dir env info
|
|
40
|
-
messages.concat(errors.map(&:to_s).
|
|
40
|
+
messages.concat(errors.map(&:to_s).map { |error| error.gsub(Regexp.escape("file: #{File.absolute_path(file)}(, |))"), '') }.map { |error| error.gsub(/Could not parse.*: /, '') })
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
Puppet::Util::Log.close_all
|
|
@@ -50,7 +50,7 @@ class PuppetParser
|
|
|
50
50
|
# weirdly puppet >= 6.5 still does not return warnings and logs them instead unlike errors
|
|
51
51
|
unless errors.empty?
|
|
52
52
|
# puppet >= 5.4 has a new validator output format
|
|
53
|
-
warnings.concat(errors.map(&:to_s).join("\n").gsub("file: #{File.absolute_path(file)}, ", '').split("\n"))
|
|
53
|
+
warnings.concat(errors.map(&:to_s).join("\n").gsub(Regexp.escape("file: #{File.absolute_path(file)}(, |))"), '').split("\n"))
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
# check puppet style
|
data/lib/puppet_check.rb
CHANGED
|
@@ -75,7 +75,7 @@ class PuppetCheck
|
|
|
75
75
|
# return settings with defaults where unspecified
|
|
76
76
|
{
|
|
77
77
|
# initialize fail on warning, style check, and regression check bools
|
|
78
|
-
|
|
78
|
+
fail_on_warnings: false,
|
|
79
79
|
style: false,
|
|
80
80
|
smoke: false,
|
|
81
81
|
regression: false,
|
|
@@ -101,11 +101,11 @@ class PuppetCheck
|
|
|
101
101
|
paths.uniq.each do |path|
|
|
102
102
|
if File.directory?(path)
|
|
103
103
|
# glob all files in directory and concat them
|
|
104
|
-
files.concat(Dir.glob("#{path}/**/*").select { |subpath| File.file?(subpath) && !subpath.include?('fixtures') })
|
|
105
|
-
elsif File.file?(path) && !path.include?('fixtures')
|
|
104
|
+
files.concat(Dir.glob("#{path}/**/*").select { |subpath| File.file?(subpath) && File.readable?(subpath) && !subpath.include?('fixtures') })
|
|
105
|
+
elsif File.file?(path) && File.readable?(path) && !path.include?('fixtures')
|
|
106
106
|
files.push(path)
|
|
107
107
|
else
|
|
108
|
-
warn "puppet-check: #{path} is not a directory, file, or symlink, and will not be considered during parsing"
|
|
108
|
+
warn "puppet-check: #{path} is not a readable directory, file, or symlink, and will not be considered during parsing"
|
|
109
109
|
end
|
|
110
110
|
end
|
|
111
111
|
|
data/puppet-check.gemspec
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Gem::Specification.new do |spec|
|
|
2
2
|
spec.name = 'puppet-check'
|
|
3
|
-
spec.version = '2.5.
|
|
3
|
+
spec.version = '2.5.1'
|
|
4
4
|
spec.authors = ['Matt Schuchard']
|
|
5
5
|
spec.description = 'Puppet Check is a gem that provides a comprehensive, streamlined, and efficient analysis of the syntax, style, and validity of your entire Puppet code and data.'
|
|
6
6
|
spec.summary = 'A streamlined comprehensive set of checks for your entire Puppet code and data'
|
|
@@ -6,7 +6,7 @@ describe PuppetCheck::CLI do
|
|
|
6
6
|
it 'targets the current working directory if no paths were specified' do
|
|
7
7
|
expect { PuppetCheck::CLI.run(%w[--fail-on-warnings]) }.not_to raise_exception
|
|
8
8
|
expect(PuppetCheck.files[:clean].length).to eql(29)
|
|
9
|
-
if
|
|
9
|
+
if CI_ENV
|
|
10
10
|
expect(PuppetCheck.files[:ignored].length).to eql(8)
|
|
11
11
|
else
|
|
12
12
|
expect(PuppetCheck.files[:ignored].length).to eql(7)
|
|
@@ -40,7 +40,7 @@ describe PuppetCheck::CLI do
|
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
it 'correctly loads a .puppet-lint.rc' do
|
|
43
|
-
expect(PuppetCheck::CLI.send(:parse, %W[-c #{
|
|
43
|
+
expect(PuppetCheck::CLI.send(:parse, %W[-c #{FIXTURES_DIR}/manifests/.puppet-lint.rc])).to include(puppetlint_args: ['--puppetlint-arg-one', '--puppetlint-arg-two'])
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
it 'correctly parses Rubocop arguments' do
|
|
@@ -13,24 +13,24 @@ describe DataParser do
|
|
|
13
13
|
|
|
14
14
|
context '.yaml' do
|
|
15
15
|
it 'puts a bad syntax yaml file in the error files hash' do
|
|
16
|
-
DataParser.yaml(["#{
|
|
17
|
-
expect(PuppetCheck.files[:errors].keys).to eql(["#{
|
|
18
|
-
expect(PuppetCheck.files[:errors]["#{
|
|
16
|
+
DataParser.yaml(["#{FIXTURES_DIR}hieradata/syntax.yaml"])
|
|
17
|
+
expect(PuppetCheck.files[:errors].keys).to eql(["#{FIXTURES_DIR}hieradata/syntax.yaml"])
|
|
18
|
+
expect(PuppetCheck.files[:errors]["#{FIXTURES_DIR}hieradata/syntax.yaml"].join("\n")).to match(/^block sequence entries are not allowed/)
|
|
19
19
|
expect(PuppetCheck.files[:warnings]).to eql({})
|
|
20
20
|
expect(PuppetCheck.files[:clean]).to eql([])
|
|
21
21
|
end
|
|
22
22
|
it 'puts a good yaml file with potential hiera issues in the warning files array' do
|
|
23
|
-
DataParser.yaml(["#{
|
|
23
|
+
DataParser.yaml(["#{FIXTURES_DIR}hieradata/style.yaml"])
|
|
24
24
|
expect(PuppetCheck.files[:errors]).to eql({})
|
|
25
|
-
expect(PuppetCheck.files[:warnings].keys).to eql(["#{
|
|
26
|
-
expect(PuppetCheck.files[:warnings]["#{
|
|
25
|
+
expect(PuppetCheck.files[:warnings].keys).to eql(["#{FIXTURES_DIR}hieradata/style.yaml"])
|
|
26
|
+
expect(PuppetCheck.files[:warnings]["#{FIXTURES_DIR}hieradata/style.yaml"].join("\n")).to match(/^Value\(s\) missing in key.*\nValue\(s\) missing in key.*\nThe string --- appears more than once in this data and Hiera may fail to parse it correctly/)
|
|
27
27
|
expect(PuppetCheck.files[:clean]).to eql([])
|
|
28
28
|
end
|
|
29
29
|
it 'puts a good yaml file in the clean files array' do
|
|
30
|
-
DataParser.yaml(["#{
|
|
30
|
+
DataParser.yaml(["#{FIXTURES_DIR}hieradata/good.yaml"])
|
|
31
31
|
expect(PuppetCheck.files[:errors]).to eql({})
|
|
32
32
|
expect(PuppetCheck.files[:warnings]).to eql({})
|
|
33
|
-
expect(PuppetCheck.files[:clean]).to eql(["#{
|
|
33
|
+
expect(PuppetCheck.files[:clean]).to eql(["#{FIXTURES_DIR}hieradata/good.yaml"])
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
|
|
@@ -42,83 +42,83 @@ describe DataParser do
|
|
|
42
42
|
expect { DataParser.eyaml(['foo.eyaml'], 'public.pem', nil) }.to output("Public X509 and/or Private RSA PKCS7 certs were not specified. EYAML checks will not be executed.\n").to_stderr
|
|
43
43
|
end
|
|
44
44
|
it 'returns a warning if the public key or private key are not existing files' do
|
|
45
|
-
expect { DataParser.eyaml(['foo.eyaml'], 'public.pem', 'private.pem') }.to output("Specified Public X509 and/or Private RSA PKCS7 certs do not exist. EYAML checks will not be executed.\n").to_stderr
|
|
45
|
+
expect { DataParser.eyaml(['foo.eyaml'], 'public.pem', 'private.pem') }.to output("Specified Public X509 and/or Private RSA PKCS7 certs do not exist or are not readable. EYAML checks will not be executed.\n").to_stderr
|
|
46
46
|
end
|
|
47
47
|
it 'puts a bad syntax eyaml file in the error files hash' do
|
|
48
|
-
DataParser.eyaml(["#{
|
|
49
|
-
expect(PuppetCheck.files[:errors].keys).to eql(["#{
|
|
50
|
-
expect(PuppetCheck.files[:errors]["#{
|
|
48
|
+
DataParser.eyaml(["#{FIXTURES_DIR}hieradata/syntax.eyaml"], "#{FIXTURES_DIR}keys/public_key.pkcs7.pem", "#{FIXTURES_DIR}keys/private_key.pkcs7.pem")
|
|
49
|
+
expect(PuppetCheck.files[:errors].keys).to eql(["#{FIXTURES_DIR}hieradata/syntax.eyaml"])
|
|
50
|
+
expect(PuppetCheck.files[:errors]["#{FIXTURES_DIR}hieradata/syntax.eyaml"].join("\n")).to match(/^block sequence entries are not allowed/)
|
|
51
51
|
expect(PuppetCheck.files[:warnings]).to eql({})
|
|
52
52
|
expect(PuppetCheck.files[:clean]).to eql([])
|
|
53
53
|
end
|
|
54
54
|
it 'puts a good eyaml file with potential hiera issues in the warning files array' do
|
|
55
|
-
DataParser.eyaml(["#{
|
|
55
|
+
DataParser.eyaml(["#{FIXTURES_DIR}hieradata/style.eyaml"], "#{FIXTURES_DIR}keys/public_key.pkcs7.pem", "#{FIXTURES_DIR}keys/private_key.pkcs7.pem")
|
|
56
56
|
expect(PuppetCheck.files[:errors]).to eql({})
|
|
57
|
-
expect(PuppetCheck.files[:warnings].keys).to eql(["#{
|
|
58
|
-
expect(PuppetCheck.files[:warnings]["#{
|
|
57
|
+
expect(PuppetCheck.files[:warnings].keys).to eql(["#{FIXTURES_DIR}hieradata/style.eyaml"])
|
|
58
|
+
expect(PuppetCheck.files[:warnings]["#{FIXTURES_DIR}hieradata/style.eyaml"].join("\n")).to match(/^Value\(s\) missing in key.*\nValue\(s\) missing in key.*\nThe string --- appears more than once in this data and Hiera may fail to parse it correctly/)
|
|
59
59
|
expect(PuppetCheck.files[:clean]).to eql([])
|
|
60
60
|
end
|
|
61
61
|
it 'puts a good eyaml file in the clean files array' do
|
|
62
|
-
DataParser.eyaml(["#{
|
|
62
|
+
DataParser.eyaml(["#{FIXTURES_DIR}hieradata/good.eyaml"], "#{FIXTURES_DIR}keys/public_key.pkcs7.pem", "#{FIXTURES_DIR}keys/private_key.pkcs7.pem")
|
|
63
63
|
expect(PuppetCheck.files[:errors]).to eql({})
|
|
64
64
|
expect(PuppetCheck.files[:warnings]).to eql({})
|
|
65
|
-
expect(PuppetCheck.files[:clean]).to eql(["#{
|
|
65
|
+
expect(PuppetCheck.files[:clean]).to eql(["#{FIXTURES_DIR}hieradata/good.eyaml"])
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
context '.json' do
|
|
70
70
|
it 'puts a bad syntax json file in the error files hash' do
|
|
71
|
-
DataParser.json(["#{
|
|
72
|
-
expect(PuppetCheck.files[:errors].keys).to eql(["#{
|
|
73
|
-
expect(PuppetCheck.files[:errors]["#{
|
|
71
|
+
DataParser.json(["#{FIXTURES_DIR}hieradata/syntax.json"])
|
|
72
|
+
expect(PuppetCheck.files[:errors].keys).to eql(["#{FIXTURES_DIR}hieradata/syntax.json"])
|
|
73
|
+
expect(PuppetCheck.files[:errors]["#{FIXTURES_DIR}hieradata/syntax.json"].join("\n")).to match(/after object value, got.*at line 2 column 3/)
|
|
74
74
|
expect(PuppetCheck.files[:warnings]).to eql({})
|
|
75
75
|
expect(PuppetCheck.files[:clean]).to eql([])
|
|
76
76
|
end
|
|
77
77
|
it 'puts a bad metadata json file in the error files hash' do
|
|
78
|
-
DataParser.json(["#{
|
|
79
|
-
expect(PuppetCheck.files[:errors].keys).to eql(["#{
|
|
80
|
-
expect(PuppetCheck.files[:errors]["#{
|
|
78
|
+
DataParser.json(["#{FIXTURES_DIR}metadata_syntax/metadata.json"])
|
|
79
|
+
expect(PuppetCheck.files[:errors].keys).to eql(["#{FIXTURES_DIR}metadata_syntax/metadata.json"])
|
|
80
|
+
expect(PuppetCheck.files[:errors]["#{FIXTURES_DIR}metadata_syntax/metadata.json"].join("\n")).to match(/^Required field.*\nField 'requirements'.*\nDuplicate dependencies.*\nDeprecated field.*\nSummary exceeds/)
|
|
81
81
|
expect(PuppetCheck.files[:warnings]).to eql({})
|
|
82
82
|
expect(PuppetCheck.files[:clean]).to eql([])
|
|
83
83
|
end
|
|
84
84
|
it 'puts a bad style metadata json file in the warning files array' do
|
|
85
|
-
DataParser.json(["#{
|
|
85
|
+
DataParser.json(["#{FIXTURES_DIR}metadata_style/metadata.json"])
|
|
86
86
|
expect(PuppetCheck.files[:errors]).to eql({})
|
|
87
|
-
expect(PuppetCheck.files[:warnings].keys).to eql(["#{
|
|
88
|
-
expect(PuppetCheck.files[:warnings]["#{
|
|
87
|
+
expect(PuppetCheck.files[:warnings].keys).to eql(["#{FIXTURES_DIR}metadata_style/metadata.json"])
|
|
88
|
+
expect(PuppetCheck.files[:warnings]["#{FIXTURES_DIR}metadata_style/metadata.json"].join("\n")).to match(/^'pe' is missing an upper bound.\n.*operatingsystem_support.*\nLicense identifier/)
|
|
89
89
|
expect(PuppetCheck.files[:clean]).to eql([])
|
|
90
90
|
end
|
|
91
91
|
it 'puts another bad style metadata json file in the warning files array' do
|
|
92
|
-
DataParser.json(["#{
|
|
92
|
+
DataParser.json(["#{FIXTURES_DIR}metadata_style_two/metadata.json"])
|
|
93
93
|
expect(PuppetCheck.files[:errors]).to eql({})
|
|
94
|
-
expect(PuppetCheck.files[:warnings].keys).to eql(["#{
|
|
95
|
-
expect(PuppetCheck.files[:warnings]["#{
|
|
94
|
+
expect(PuppetCheck.files[:warnings].keys).to eql(["#{FIXTURES_DIR}metadata_style_two/metadata.json"])
|
|
95
|
+
expect(PuppetCheck.files[:warnings]["#{FIXTURES_DIR}metadata_style_two/metadata.json"].join("\n")).to match(%r{^'puppetlabs/one' has non-semantic versioning.*\n'puppetlabs/two' is missing an upper bound\.\n.*operatingsystem.*\n.*operatingsystemrelease})
|
|
96
96
|
expect(PuppetCheck.files[:clean]).to eql([])
|
|
97
97
|
end
|
|
98
98
|
it 'puts a bad task metadata json file in the warning files array' do
|
|
99
|
-
DataParser.json(["#{
|
|
99
|
+
DataParser.json(["#{FIXTURES_DIR}task_metadata/task_bad.json"])
|
|
100
100
|
expect(PuppetCheck.files[:errors]).to eql({})
|
|
101
|
-
expect(PuppetCheck.files[:warnings].keys).to eql(["#{
|
|
102
|
-
expect(PuppetCheck.files[:warnings]["#{
|
|
101
|
+
expect(PuppetCheck.files[:warnings].keys).to eql(["#{FIXTURES_DIR}task_metadata/task_bad.json"])
|
|
102
|
+
expect(PuppetCheck.files[:warnings]["#{FIXTURES_DIR}task_metadata/task_bad.json"].join("\n")).to match(/^description value is not a String\ninput_method value is not one of environment, stdin, or powershell\nparameters value is not a Hash\npuppet_task_version value is not an Integer\nsupports_noop value is not a Boolean/)
|
|
103
103
|
expect(PuppetCheck.files[:clean]).to eql([])
|
|
104
104
|
end
|
|
105
105
|
it 'puts a good json file in the clean files array' do
|
|
106
|
-
DataParser.json(["#{
|
|
106
|
+
DataParser.json(["#{FIXTURES_DIR}hieradata/good.json"])
|
|
107
107
|
expect(PuppetCheck.files[:errors]).to eql({})
|
|
108
108
|
expect(PuppetCheck.files[:warnings]).to eql({})
|
|
109
|
-
expect(PuppetCheck.files[:clean]).to eql(["#{
|
|
109
|
+
expect(PuppetCheck.files[:clean]).to eql(["#{FIXTURES_DIR}hieradata/good.json"])
|
|
110
110
|
end
|
|
111
111
|
it 'puts a good metadata json file in the clean files array' do
|
|
112
|
-
DataParser.json(["#{
|
|
112
|
+
DataParser.json(["#{FIXTURES_DIR}metadata_good/metadata.json"])
|
|
113
113
|
expect(PuppetCheck.files[:errors]).to eql({})
|
|
114
114
|
expect(PuppetCheck.files[:warnings]).to eql({})
|
|
115
|
-
expect(PuppetCheck.files[:clean]).to eql(["#{
|
|
115
|
+
expect(PuppetCheck.files[:clean]).to eql(["#{FIXTURES_DIR}metadata_good/metadata.json"])
|
|
116
116
|
end
|
|
117
117
|
it 'puts a good task metadata json file in the clean files array' do
|
|
118
|
-
DataParser.json(["#{
|
|
118
|
+
DataParser.json(["#{FIXTURES_DIR}task_metadata/task_good.json"])
|
|
119
119
|
expect(PuppetCheck.files[:errors]).to eql({})
|
|
120
120
|
expect(PuppetCheck.files[:warnings]).to eql({})
|
|
121
|
-
expect(PuppetCheck.files[:clean]).to eql(["#{
|
|
121
|
+
expect(PuppetCheck.files[:clean]).to eql(["#{FIXTURES_DIR}task_metadata/task_good.json"])
|
|
122
122
|
end
|
|
123
123
|
end
|
|
124
124
|
end
|
|
@@ -13,12 +13,12 @@ describe PuppetParser do
|
|
|
13
13
|
|
|
14
14
|
context '.manifest' do
|
|
15
15
|
it 'puts a bad syntax Puppet manifest in the error files hash' do
|
|
16
|
-
PuppetParser.manifest(["#{
|
|
17
|
-
expect(PuppetCheck.files[:errors].keys).to eql(["#{
|
|
16
|
+
PuppetParser.manifest(["#{FIXTURES_DIR}manifests/syntax.pp"], false, [])
|
|
17
|
+
expect(PuppetCheck.files[:errors].keys).to eql(["#{FIXTURES_DIR}manifests/syntax.pp"])
|
|
18
18
|
if Gem::Version.new(Puppet::PUPPETVERSION) >= Gem::Version.new('6.5.0')
|
|
19
|
-
expect(PuppetCheck.files[:errors]["#{
|
|
19
|
+
expect(PuppetCheck.files[:errors]["#{FIXTURES_DIR}manifests/syntax.pp"].join("\n")).to match(/^Language validation logged 2 errors/)
|
|
20
20
|
else
|
|
21
|
-
expect(PuppetCheck.files[:errors]["#{
|
|
21
|
+
expect(PuppetCheck.files[:errors]["#{FIXTURES_DIR}manifests/syntax.pp"].join("\n")).to match(/^This Variable has no effect.*\nIllegal variable name/)
|
|
22
22
|
end
|
|
23
23
|
expect(PuppetCheck.files[:warnings]).to eql({})
|
|
24
24
|
expect(PuppetCheck.files[:clean]).to eql([])
|
|
@@ -26,77 +26,77 @@ describe PuppetParser do
|
|
|
26
26
|
# puppet 5 api has output issues for this fixture
|
|
27
27
|
unless Gem::Version.new(Puppet::PUPPETVERSION) < Gem::Version.new('6.0.0')
|
|
28
28
|
it 'puts a bad syntax at eof Puppet manifest in the error files hash' do
|
|
29
|
-
PuppetParser.manifest(["#{
|
|
30
|
-
expect(PuppetCheck.files[:errors].keys).to eql(["#{
|
|
31
|
-
expect(PuppetCheck.files[:errors]["#{
|
|
29
|
+
PuppetParser.manifest(["#{FIXTURES_DIR}manifests/eof_syntax.pp"], false, [])
|
|
30
|
+
expect(PuppetCheck.files[:errors].keys).to eql(["#{FIXTURES_DIR}manifests/eof_syntax.pp"])
|
|
31
|
+
expect(PuppetCheck.files[:errors]["#{FIXTURES_DIR}manifests/eof_syntax.pp"].join("\n")).to match(/^Syntax error at end of input/)
|
|
32
32
|
expect(PuppetCheck.files[:warnings]).to eql({})
|
|
33
33
|
expect(PuppetCheck.files[:clean]).to eql([])
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
it 'puts a bad syntax Puppet plan in the error files hash' do
|
|
37
|
-
PuppetParser.manifest(["#{
|
|
38
|
-
expect(PuppetCheck.files[:errors].keys).to eql(["#{
|
|
39
|
-
expect(PuppetCheck.files[:errors]["#{
|
|
37
|
+
PuppetParser.manifest(["#{FIXTURES_DIR}plans/syntax.pp"], false, [])
|
|
38
|
+
expect(PuppetCheck.files[:errors].keys).to eql(["#{FIXTURES_DIR}plans/syntax.pp"])
|
|
39
|
+
expect(PuppetCheck.files[:errors]["#{FIXTURES_DIR}plans/syntax.pp"].join("\n")).to match(/^Syntax error at '\)'/)
|
|
40
40
|
expect(PuppetCheck.files[:warnings]).to eql({})
|
|
41
41
|
expect(PuppetCheck.files[:clean]).to eql([])
|
|
42
42
|
end
|
|
43
43
|
it 'puts a bad parser style and lint style Puppet manifest in the warning files array' do
|
|
44
|
-
PuppetParser.manifest(["#{
|
|
44
|
+
PuppetParser.manifest(["#{FIXTURES_DIR}manifests/style_parser.pp"], true, [])
|
|
45
45
|
expect(PuppetCheck.files[:errors]).to eql({})
|
|
46
|
-
expect(PuppetCheck.files[:warnings].keys).to eql(["#{
|
|
47
|
-
expect(PuppetCheck.files[:warnings]["#{
|
|
46
|
+
expect(PuppetCheck.files[:warnings].keys).to eql(["#{FIXTURES_DIR}manifests/style_parser.pp"])
|
|
47
|
+
expect(PuppetCheck.files[:warnings]["#{FIXTURES_DIR}manifests/style_parser.pp"].join("\n")).to match(/^Unrecognized escape sequence.*\nUnrecognized escape sequence.*\n.*double quoted string containing/)
|
|
48
48
|
expect(PuppetCheck.files[:clean]).to eql([])
|
|
49
49
|
end
|
|
50
50
|
it 'puts a bad lint style Puppet manifest in the warning files array' do
|
|
51
|
-
PuppetParser.manifest(["#{
|
|
51
|
+
PuppetParser.manifest(["#{FIXTURES_DIR}manifests/style_lint.pp"], true, [])
|
|
52
52
|
expect(PuppetCheck.files[:errors]).to eql({})
|
|
53
|
-
expect(PuppetCheck.files[:warnings].keys).to eql(["#{
|
|
54
|
-
expect(PuppetCheck.files[:warnings]["#{
|
|
53
|
+
expect(PuppetCheck.files[:warnings].keys).to eql(["#{FIXTURES_DIR}manifests/style_lint.pp"])
|
|
54
|
+
expect(PuppetCheck.files[:warnings]["#{FIXTURES_DIR}manifests/style_lint.pp"].join("\n")).to match(/(?:indentation of|double quoted string containing).*\n.*(?:indentation of|double quoted string containing)/)
|
|
55
55
|
expect(PuppetCheck.files[:clean]).to eql([])
|
|
56
56
|
end
|
|
57
57
|
it 'puts a bad style Puppet manifest in the clean files array when puppetlint_args ignores its warnings' do
|
|
58
|
-
PuppetParser.manifest(["#{
|
|
58
|
+
PuppetParser.manifest(["#{FIXTURES_DIR}manifests/style_lint.pp"], true, ['--no-double_quoted_strings-check', '--no-arrow_alignment-check'])
|
|
59
59
|
expect(PuppetCheck.files[:errors]).to eql({})
|
|
60
60
|
expect(PuppetCheck.files[:warnings]).to eql({})
|
|
61
|
-
expect(PuppetCheck.files[:clean]).to eql(["#{
|
|
61
|
+
expect(PuppetCheck.files[:clean]).to eql(["#{FIXTURES_DIR}manifests/style_lint.pp"])
|
|
62
62
|
end
|
|
63
63
|
it 'puts a bad style Puppet plan in the warning files array' do
|
|
64
|
-
PuppetParser.manifest(["#{
|
|
64
|
+
PuppetParser.manifest(["#{FIXTURES_DIR}plans/style.pp"], true, [])
|
|
65
65
|
expect(PuppetCheck.files[:errors]).to eql({})
|
|
66
|
-
expect(PuppetCheck.files[:warnings].keys).to eql(["#{
|
|
67
|
-
expect(PuppetCheck.files[:warnings]["#{
|
|
66
|
+
expect(PuppetCheck.files[:warnings].keys).to eql(["#{FIXTURES_DIR}plans/style.pp"])
|
|
67
|
+
expect(PuppetCheck.files[:warnings]["#{FIXTURES_DIR}plans/style.pp"].join("\n")).to match(/variable not enclosed in {}/)
|
|
68
68
|
expect(PuppetCheck.files[:clean]).to eql([])
|
|
69
69
|
end
|
|
70
70
|
it 'puts a good Puppet manifest in the clean files array' do
|
|
71
|
-
PuppetParser.manifest(["#{
|
|
71
|
+
PuppetParser.manifest(["#{FIXTURES_DIR}manifests/good.pp"], true, [])
|
|
72
72
|
expect(PuppetCheck.files[:errors]).to eql({})
|
|
73
73
|
expect(PuppetCheck.files[:warnings]).to eql({})
|
|
74
|
-
expect(PuppetCheck.files[:clean]).to eql(["#{
|
|
74
|
+
expect(PuppetCheck.files[:clean]).to eql(["#{FIXTURES_DIR}manifests/good.pp"])
|
|
75
75
|
end
|
|
76
76
|
it 'puts a good Puppet plan in the clean files array' do
|
|
77
|
-
PuppetParser.manifest(["#{
|
|
77
|
+
PuppetParser.manifest(["#{FIXTURES_DIR}plans/good.pp"], true, [])
|
|
78
78
|
expect(PuppetCheck.files[:errors]).to eql({})
|
|
79
79
|
expect(PuppetCheck.files[:warnings]).to eql({})
|
|
80
|
-
expect(PuppetCheck.files[:clean]).to eql(["#{
|
|
80
|
+
expect(PuppetCheck.files[:clean]).to eql(["#{FIXTURES_DIR}plans/good.pp"])
|
|
81
81
|
end
|
|
82
82
|
it 'throws a well specified error for an invalid PuppetLint argument' do
|
|
83
|
-
expect { PuppetParser.manifest(["#{
|
|
83
|
+
expect { PuppetParser.manifest(["#{FIXTURES_DIR}manifests/style_lint.pp"], true, ['--non-existent', '--does-not-exist']) }.to raise_error(RuntimeError, 'puppet-lint: invalid option supplied among --non-existent --does-not-exist')
|
|
84
84
|
end
|
|
85
85
|
end
|
|
86
86
|
|
|
87
87
|
context '.template' do
|
|
88
88
|
it 'puts a bad syntax Puppet template in the error files hash' do
|
|
89
|
-
PuppetParser.template(["#{
|
|
90
|
-
expect(PuppetCheck.files[:errors].keys).to eql(["#{
|
|
91
|
-
expect(PuppetCheck.files[:errors]["#{
|
|
89
|
+
PuppetParser.template(["#{FIXTURES_DIR}templates/syntax.epp"])
|
|
90
|
+
expect(PuppetCheck.files[:errors].keys).to eql(["#{FIXTURES_DIR}templates/syntax.epp"])
|
|
91
|
+
expect(PuppetCheck.files[:errors]["#{FIXTURES_DIR}templates/syntax.epp"].join("\n")).to match(/^This Name has no effect/)
|
|
92
92
|
expect(PuppetCheck.files[:warnings]).to eql({})
|
|
93
93
|
expect(PuppetCheck.files[:clean]).to eql([])
|
|
94
94
|
end
|
|
95
95
|
it 'puts a good Puppet template in the clean files array' do
|
|
96
|
-
PuppetParser.template(["#{
|
|
96
|
+
PuppetParser.template(["#{FIXTURES_DIR}templates/good.epp"])
|
|
97
97
|
expect(PuppetCheck.files[:errors]).to eql({})
|
|
98
98
|
expect(PuppetCheck.files[:warnings]).to eql({})
|
|
99
|
-
expect(PuppetCheck.files[:clean]).to eql(["#{
|
|
99
|
+
expect(PuppetCheck.files[:clean]).to eql(["#{FIXTURES_DIR}templates/good.epp"])
|
|
100
100
|
end
|
|
101
101
|
end
|
|
102
102
|
end
|
|
@@ -7,10 +7,10 @@ begin
|
|
|
7
7
|
context '.config' do
|
|
8
8
|
# json gem is messed up for the EOL Ruby versions
|
|
9
9
|
it 'raise an appropriate error if the file is malformed' do
|
|
10
|
-
expect { RegressionCheck.send(:config, "#{
|
|
10
|
+
expect { RegressionCheck.send(:config, "#{FIXTURES_DIR}metadata.json") }.to raise_error(OctocatalogDiff::Errors::ConfigurationFileContentError, 'Configuration must define OctocatalogDiff::Config!')
|
|
11
11
|
end
|
|
12
12
|
it 'loads in a good octocatalog-diff config file' do
|
|
13
|
-
expect { RegressionCheck.send(:config, "#{
|
|
13
|
+
expect { RegressionCheck.send(:config, "#{OCTOCATALOG_DIFF_DIR}octocatalog_diff.cfg.rb") }.not_to raise_exception
|
|
14
14
|
end
|
|
15
15
|
it 'loads in the settings from the file correctly' do
|
|
16
16
|
# TODO
|
|
@@ -19,16 +19,16 @@ begin
|
|
|
19
19
|
|
|
20
20
|
context '.smoke' do
|
|
21
21
|
# octocatalog-diff is returning a blank error for these tests
|
|
22
|
-
unless
|
|
22
|
+
unless CI_ENV
|
|
23
23
|
it 'returns a pass for a successful catalog compilation' do
|
|
24
|
-
expect { RegressionCheck.smoke(['good.example.com'], "#{
|
|
24
|
+
expect { RegressionCheck.smoke(['good.example.com'], "#{OCTOCATALOG_DIFF_DIR}octocatalog_diff.cfg.rb") }.not_to raise_exception
|
|
25
25
|
end
|
|
26
26
|
it 'returns a failure for a catalog with an error' do
|
|
27
|
-
expect { RegressionCheck.smoke(['does_not_exist.example.com'], "#{
|
|
27
|
+
expect { RegressionCheck.smoke(['does_not_exist.example.com'], "#{OCTOCATALOG_DIFF_DIR}octocatalog_diff.cfg.rb") }.to raise_error(OctocatalogDiff::Errors::CatalogError)
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
it 'returns a failure for a good and bad catalog' do
|
|
31
|
-
# RegressionCheck.smoke(['good.example.com', 'syntax_error.example.com'], "#{
|
|
31
|
+
# RegressionCheck.smoke(['good.example.com', 'syntax_error.example.com'], "#{FIXTURES_DIR}octocatalog_diff.cfg.rb")
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
|
|
@@ -5,17 +5,17 @@ require 'fileutils'
|
|
|
5
5
|
describe RSpecPuppetSupport do
|
|
6
6
|
after(:all) do
|
|
7
7
|
# cleanup rspec_puppet_setup
|
|
8
|
-
File.delete("#{
|
|
9
|
-
%w[manifests modules].each { |dir| FileUtils.rm_r("#{
|
|
8
|
+
File.delete("#{FIXTURES_DIR}/spec/spec_helper.rb")
|
|
9
|
+
%w[manifests modules].each { |dir| FileUtils.rm_r("#{FIXTURES_DIR}/spec/fixtures/#{dir}") }
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
context '.run' do
|
|
13
13
|
let(:rspec_puppet_setup) { RSpecPuppetSupport.run }
|
|
14
|
-
before(:each) { Dir.chdir(
|
|
14
|
+
before(:each) { Dir.chdir(FIXTURES_DIR) }
|
|
15
15
|
|
|
16
16
|
it 'creates missing directories, missing site.pp, missing symlinks, and a missing spec_helper' do
|
|
17
17
|
# circle ci and gh actions
|
|
18
|
-
if
|
|
18
|
+
if CI_ENV
|
|
19
19
|
expect { rspec_puppet_setup }.to output("git is not installed and cannot be used to retrieve dependency modules\nsubversion is not installed and cannot be used to retrieve dependency modules\npuppetlabs/gruntmaster has an unspecified, or specified but unsupported, download method.\n").to_stderr
|
|
20
20
|
else
|
|
21
21
|
expect { rspec_puppet_setup }.to output("subversion is not installed and cannot be used to retrieve dependency modules\npuppetlabs/gruntmaster has an unspecified, or specified but unsupported, download method.\n").to_stderr
|
|
@@ -29,7 +29,7 @@ describe RSpecPuppetSupport do
|
|
|
29
29
|
expect(File.file?('spec/spec_helper.rb')).to be true
|
|
30
30
|
|
|
31
31
|
# .dependency_setup
|
|
32
|
-
expect(File.directory?('spec/fixtures/modules/puppetlabs-lvm')).to be true unless
|
|
32
|
+
expect(File.directory?('spec/fixtures/modules/puppetlabs-lvm')).to be true unless CI_ENV
|
|
33
33
|
expect(File.directory?('spec/fixtures/modules/stdlib')).to be true
|
|
34
34
|
end
|
|
35
35
|
end
|
|
@@ -13,96 +13,96 @@ describe RubyParser do
|
|
|
13
13
|
|
|
14
14
|
context '.ruby' do
|
|
15
15
|
it 'puts a bad syntax ruby file in the error files hash' do
|
|
16
|
-
RubyParser.ruby(["#{
|
|
17
|
-
expect(PuppetCheck.files[:errors].keys).to eql(["#{
|
|
18
|
-
expect(PuppetCheck.files[:errors]["#{
|
|
16
|
+
RubyParser.ruby(["#{FIXTURES_DIR}lib/syntax.rb"], false, [])
|
|
17
|
+
expect(PuppetCheck.files[:errors].keys).to eql(["#{FIXTURES_DIR}lib/syntax.rb"])
|
|
18
|
+
expect(PuppetCheck.files[:errors]["#{FIXTURES_DIR}lib/syntax.rb"].join("\n")).to match(/^.*syntax error/)
|
|
19
19
|
expect(PuppetCheck.files[:warnings]).to eql({})
|
|
20
20
|
expect(PuppetCheck.files[:clean]).to eql([])
|
|
21
21
|
end
|
|
22
22
|
it 'puts a bad style ruby file in the warning files array' do
|
|
23
|
-
RubyParser.ruby(["#{
|
|
23
|
+
RubyParser.ruby(["#{FIXTURES_DIR}lib/style.rb"], true, [])
|
|
24
24
|
expect(PuppetCheck.files[:errors]).to eql({})
|
|
25
|
-
expect(PuppetCheck.files[:warnings].keys).to eql(["#{
|
|
26
|
-
unless
|
|
27
|
-
expect(PuppetCheck.files[:warnings]["#{
|
|
25
|
+
expect(PuppetCheck.files[:warnings].keys).to eql(["#{FIXTURES_DIR}lib/style.rb"])
|
|
26
|
+
unless CI_ENV
|
|
27
|
+
expect(PuppetCheck.files[:warnings]["#{FIXTURES_DIR}lib/style.rb"].length).to eql(8)
|
|
28
28
|
else
|
|
29
|
-
expect(PuppetCheck.files[:warnings]["#{
|
|
29
|
+
expect(PuppetCheck.files[:warnings]["#{FIXTURES_DIR}lib/style.rb"].join("\n")).to match(/Useless assignment.*\n.*Use the new.*\n.*Do not introduce.*\n.*Prefer single.*\n.*Remove unnecessary empty.*\n.*Source code comment is empty/)
|
|
30
30
|
end
|
|
31
31
|
expect(PuppetCheck.files[:clean]).to eql([])
|
|
32
32
|
end
|
|
33
33
|
it 'puts a bad style ruby file in the clean files array when rubocop_args ignores its warnings' do
|
|
34
|
-
RubyParser.ruby(["#{
|
|
34
|
+
RubyParser.ruby(["#{FIXTURES_DIR}lib/rubocop_style.rb"], true, ['--except', 'Lint/UselessAssignment,Style/HashSyntax,Style/GlobalVars,Style/StringLiterals'])
|
|
35
35
|
expect(PuppetCheck.files[:errors]).to eql({})
|
|
36
36
|
expect(PuppetCheck.files[:warnings]).to eql({})
|
|
37
|
-
expect(PuppetCheck.files[:clean]).to eql(["#{
|
|
37
|
+
expect(PuppetCheck.files[:clean]).to eql(["#{FIXTURES_DIR}lib/rubocop_style.rb"])
|
|
38
38
|
end
|
|
39
39
|
it 'puts a good ruby file in the clean files array' do
|
|
40
|
-
RubyParser.ruby(["#{
|
|
40
|
+
RubyParser.ruby(["#{FIXTURES_DIR}lib/good.rb"], true, [])
|
|
41
41
|
expect(PuppetCheck.files[:errors]).to eql({})
|
|
42
42
|
expect(PuppetCheck.files[:warnings]).to eql({})
|
|
43
|
-
expect(PuppetCheck.files[:clean]).to eql(["#{
|
|
43
|
+
expect(PuppetCheck.files[:clean]).to eql(["#{FIXTURES_DIR}lib/good.rb"])
|
|
44
44
|
end
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
context '.template' do
|
|
48
48
|
it 'puts a bad syntax ruby template file in the error files hash' do
|
|
49
|
-
RubyParser.template(["#{
|
|
50
|
-
expect(PuppetCheck.files[:errors].keys).to eql(["#{
|
|
49
|
+
RubyParser.template(["#{FIXTURES_DIR}templates/syntax.erb"])
|
|
50
|
+
expect(PuppetCheck.files[:errors].keys).to eql(["#{FIXTURES_DIR}templates/syntax.erb"])
|
|
51
51
|
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7')
|
|
52
|
-
expect(PuppetCheck.files[:errors]["#{
|
|
52
|
+
expect(PuppetCheck.files[:errors]["#{FIXTURES_DIR}templates/syntax.erb"].join("\n")).to match(/1: syntax error, unexpected.*\n.*ruby/)
|
|
53
53
|
else
|
|
54
|
-
expect(PuppetCheck.files[:errors]["#{
|
|
54
|
+
expect(PuppetCheck.files[:errors]["#{FIXTURES_DIR}templates/syntax.erb"].join("\n")).to match(/syntax error, unexpected tIDENTIFIER/)
|
|
55
55
|
end
|
|
56
56
|
expect(PuppetCheck.files[:warnings]).to eql({})
|
|
57
57
|
expect(PuppetCheck.files[:clean]).to eql([])
|
|
58
58
|
end
|
|
59
59
|
it 'puts a bad style ruby template file in the warning files array' do
|
|
60
|
-
RubyParser.template(["#{
|
|
60
|
+
RubyParser.template(["#{FIXTURES_DIR}templates/style.erb"])
|
|
61
61
|
expect(PuppetCheck.files[:errors]).to eql({})
|
|
62
|
-
expect(PuppetCheck.files[:warnings].keys).to eql(["#{
|
|
63
|
-
expect(PuppetCheck.files[:warnings]["#{
|
|
62
|
+
expect(PuppetCheck.files[:warnings].keys).to eql(["#{FIXTURES_DIR}templates/style.erb"])
|
|
63
|
+
expect(PuppetCheck.files[:warnings]["#{FIXTURES_DIR}templates/style.erb"].join("\n")).to match(/already initialized constant.*\n.*previous definition of/)
|
|
64
64
|
expect(PuppetCheck.files[:clean]).to eql([])
|
|
65
65
|
end
|
|
66
66
|
it 'puts a ruby template file with ignored errors in the clean files array' do
|
|
67
|
-
RubyParser.template(["#{
|
|
67
|
+
RubyParser.template(["#{FIXTURES_DIR}templates/no_method_error.erb"])
|
|
68
68
|
expect(PuppetCheck.files[:errors]).to eql({})
|
|
69
69
|
expect(PuppetCheck.files[:warnings]).to eql({})
|
|
70
|
-
expect(PuppetCheck.files[:clean]).to eql(["#{
|
|
70
|
+
expect(PuppetCheck.files[:clean]).to eql(["#{FIXTURES_DIR}templates/no_method_error.erb"])
|
|
71
71
|
end
|
|
72
72
|
it 'puts a good ruby template file in the clean files array' do
|
|
73
|
-
RubyParser.template(["#{
|
|
73
|
+
RubyParser.template(["#{FIXTURES_DIR}templates/good.erb"])
|
|
74
74
|
expect(PuppetCheck.files[:errors]).to eql({})
|
|
75
75
|
expect(PuppetCheck.files[:warnings]).to eql({})
|
|
76
|
-
expect(PuppetCheck.files[:clean]).to eql(["#{
|
|
76
|
+
expect(PuppetCheck.files[:clean]).to eql(["#{FIXTURES_DIR}templates/good.erb"])
|
|
77
77
|
end
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
context '.librarian' do
|
|
81
81
|
it 'puts a bad syntax librarian Puppet file in the error files hash' do
|
|
82
|
-
RubyParser.librarian(["#{
|
|
83
|
-
expect(PuppetCheck.files[:errors].keys).to eql(["#{
|
|
84
|
-
expect(PuppetCheck.files[:errors]["#{
|
|
82
|
+
RubyParser.librarian(["#{FIXTURES_DIR}librarian/Puppetfile_syntax"], false, [])
|
|
83
|
+
expect(PuppetCheck.files[:errors].keys).to eql(["#{FIXTURES_DIR}librarian/Puppetfile_syntax"])
|
|
84
|
+
expect(PuppetCheck.files[:errors]["#{FIXTURES_DIR}librarian/Puppetfile_syntax"].join("\n")).to match(/^.*syntax error/)
|
|
85
85
|
expect(PuppetCheck.files[:warnings]).to eql({})
|
|
86
86
|
expect(PuppetCheck.files[:clean]).to eql([])
|
|
87
87
|
end
|
|
88
88
|
it 'puts a bad style librarian Puppet file in the warning files array' do
|
|
89
|
-
RubyParser.librarian(["#{
|
|
89
|
+
RubyParser.librarian(["#{FIXTURES_DIR}librarian/Puppetfile_style"], true, [])
|
|
90
90
|
expect(PuppetCheck.files[:errors]).to eql({})
|
|
91
|
-
expect(PuppetCheck.files[:warnings].keys).to eql(["#{
|
|
92
|
-
expect(PuppetCheck.files[:warnings]["#{
|
|
91
|
+
expect(PuppetCheck.files[:warnings].keys).to eql(["#{FIXTURES_DIR}librarian/Puppetfile_style"])
|
|
92
|
+
expect(PuppetCheck.files[:warnings]["#{FIXTURES_DIR}librarian/Puppetfile_style"].join("\n")).to match(/Align the arguments.*\n.*Use the new/)
|
|
93
93
|
expect(PuppetCheck.files[:clean]).to eql([])
|
|
94
94
|
end
|
|
95
95
|
it 'puts a bad style librarian Puppet file in the clean files array when rubocop_args ignores its warnings' do
|
|
96
|
-
RubyParser.librarian(["#{
|
|
96
|
+
RubyParser.librarian(["#{FIXTURES_DIR}librarian/Puppetfile_style"], true, ['--except', 'Layout/ArgumentAlignment,Style/HashSyntax'])
|
|
97
97
|
expect(PuppetCheck.files[:errors]).to eql({})
|
|
98
98
|
expect(PuppetCheck.files[:warnings]).to eql({})
|
|
99
|
-
expect(PuppetCheck.files[:clean]).to eql(["#{
|
|
99
|
+
expect(PuppetCheck.files[:clean]).to eql(["#{FIXTURES_DIR}librarian/Puppetfile_style"])
|
|
100
100
|
end
|
|
101
101
|
it 'puts a good librarian Puppet file in the clean files array' do
|
|
102
|
-
RubyParser.librarian(["#{
|
|
102
|
+
RubyParser.librarian(["#{FIXTURES_DIR}librarian/Puppetfile_good"], true, [])
|
|
103
103
|
expect(PuppetCheck.files[:errors]).to eql({})
|
|
104
104
|
expect(PuppetCheck.files[:warnings]).to eql({})
|
|
105
|
-
expect(PuppetCheck.files[:clean]).to eql(["#{
|
|
105
|
+
expect(PuppetCheck.files[:clean]).to eql(["#{FIXTURES_DIR}librarian/Puppetfile_good"])
|
|
106
106
|
end
|
|
107
107
|
end
|
|
108
108
|
end
|
|
@@ -5,15 +5,15 @@ require_relative '../../lib/puppet-check/tasks'
|
|
|
5
5
|
describe PuppetCheck::Tasks do
|
|
6
6
|
after(:all) do
|
|
7
7
|
# cleanup rspec_puppet_setup
|
|
8
|
-
File.delete("#{
|
|
9
|
-
%w[manifests modules].each { |dir| FileUtils.rm_r("#{
|
|
8
|
+
File.delete("#{FIXTURES_DIR}/spec/spec_helper.rb")
|
|
9
|
+
%w[manifests modules].each { |dir| FileUtils.rm_r("#{FIXTURES_DIR}/spec/fixtures/#{dir}") }
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
context 'puppetcheck:spec' do
|
|
13
13
|
let(:spec_tasks) { Rake::Task[:'puppetcheck:spec'].invoke }
|
|
14
14
|
|
|
15
15
|
it 'executes RSpec and RSpec-Puppet checks in the expected manner' do
|
|
16
|
-
Dir.chdir(
|
|
16
|
+
Dir.chdir(FIXTURES_DIR)
|
|
17
17
|
|
|
18
18
|
# rspec task executed
|
|
19
19
|
expect { spec_tasks }.to output(%r{spec/facter/facter_spec.rb}).to_stdout
|
data/spec/puppet_check_spec.rb
CHANGED
|
@@ -35,7 +35,7 @@ describe PuppetCheck do
|
|
|
35
35
|
it 'returns defaults correctly' do
|
|
36
36
|
expect(PuppetCheck.send(:defaults)).to eql(
|
|
37
37
|
{
|
|
38
|
-
|
|
38
|
+
fail_on_warnings: false,
|
|
39
39
|
style: false,
|
|
40
40
|
smoke: false,
|
|
41
41
|
regression: false,
|
|
@@ -52,7 +52,7 @@ describe PuppetCheck do
|
|
|
52
52
|
|
|
53
53
|
it 'modifies settings correctly' do
|
|
54
54
|
settings = {
|
|
55
|
-
|
|
55
|
+
fail_on_warnings: true,
|
|
56
56
|
style: true,
|
|
57
57
|
smoke: true,
|
|
58
58
|
regression: true,
|
|
@@ -69,7 +69,7 @@ describe PuppetCheck do
|
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
context '.parse_paths' do
|
|
72
|
-
before(:each) { Dir.chdir(
|
|
72
|
+
before(:each) { Dir.chdir(FIXTURES_DIR) }
|
|
73
73
|
|
|
74
74
|
let(:no_files) { PuppetCheck.send(:parse_paths, %w[foo bar baz]) }
|
|
75
75
|
let(:mixed_files) { PuppetCheck.send(:parse_paths, %w[foo lib/good.rb]) }
|
|
@@ -83,7 +83,7 @@ describe PuppetCheck do
|
|
|
83
83
|
end
|
|
84
84
|
|
|
85
85
|
it 'warns on invalid path and correctly parses a valid file path' do
|
|
86
|
-
expect { mixed_files }.to output("puppet-check: foo is not a directory, file, or symlink, and will not be considered during parsing\n").to_stderr
|
|
86
|
+
expect { mixed_files }.to output("puppet-check: foo is not a readable directory, file, or symlink, and will not be considered during parsing\n").to_stderr
|
|
87
87
|
expect(mixed_files[0]).to eql('lib/good.rb')
|
|
88
88
|
end
|
|
89
89
|
|
|
@@ -93,7 +93,7 @@ describe PuppetCheck do
|
|
|
93
93
|
|
|
94
94
|
it 'correctly parses one directory and returns all of its files' do
|
|
95
95
|
dir.each { |file| expect(File.file?(file)).to be true }
|
|
96
|
-
if
|
|
96
|
+
if CI_ENV
|
|
97
97
|
expect(dir.length).to eql(37)
|
|
98
98
|
else
|
|
99
99
|
expect(dir.length).to eql(40)
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,23 +1,10 @@
|
|
|
1
1
|
require 'rspec'
|
|
2
2
|
|
|
3
3
|
# for path to fixtures
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def fixtures_dir
|
|
8
|
-
@fixtures_dir = "#{File.dirname(__FILE__)}/fixtures/"
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def octocatalog_diff_dir
|
|
12
|
-
@octocatalog_diff_dir = "#{File.dirname(__FILE__)}/octocatalog-diff/"
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def ci_env
|
|
16
|
-
@ci_env = ENV['CIRCLECI'] == 'true' || ENV['GITHUB_ACTIONS'] == 'true'
|
|
17
|
-
end
|
|
18
|
-
end
|
|
4
|
+
FIXTURES_DIR = "#{File.dirname(__FILE__)}/fixtures/".freeze
|
|
5
|
+
OCTOCATALOG_DIFF_DIR = "#{File.dirname(__FILE__)}/octocatalog-diff/".freeze
|
|
6
|
+
CI_ENV = ENV['CIRCLECI'] == 'true' || ENV['GITHUB_ACTIONS'] == 'true'
|
|
19
7
|
|
|
20
8
|
RSpec.configure do |config|
|
|
21
|
-
config.include Variables
|
|
22
9
|
config.color = true
|
|
23
10
|
end
|
data/spec/system/system_spec.rb
CHANGED
|
@@ -6,10 +6,10 @@ require_relative '../../lib/puppet-check/tasks'
|
|
|
6
6
|
describe PuppetCheck do
|
|
7
7
|
context 'executed as a system from the CLI with arguments and various files to be processed' do
|
|
8
8
|
it 'outputs diagnostic results correctly after processing all of the files' do
|
|
9
|
-
Dir.chdir(
|
|
9
|
+
Dir.chdir(FIXTURES_DIR)
|
|
10
10
|
|
|
11
11
|
# see regression_check_spec
|
|
12
|
-
if
|
|
12
|
+
if CI_ENV
|
|
13
13
|
expect(PuppetCheck::CLI.run(%w[-s --puppet-lint no-hard_tabs-check,no-140chars-check --rubocop Layout/LineLength,Style/Encoding --public keys/public_key.pkcs7.pem --private keys/private_key.pkcs7.pem .])).to eql(2)
|
|
14
14
|
else
|
|
15
15
|
expect(PuppetCheck::CLI.run(%w[-s --puppet-lint no-hard_tabs-check,no-140chars-check --rubocop Layout/LineLength,Style/Encoding --public keys/public_key.pkcs7.pem --private keys/private_key.pkcs7.pem --smoke -n good.example.com --octoconfig spec/octocatalog-diff/octocatalog-diff.cfg.rb .])).to eql(2)
|
|
@@ -25,7 +25,7 @@ describe PuppetCheck do
|
|
|
25
25
|
context 'executed as a system from the Rakefile with arguments and various files to be processed' do
|
|
26
26
|
it 'outputs diagnostic results correctly after processing all of the files' do
|
|
27
27
|
# ensure rake only checks the files inside fixtures
|
|
28
|
-
Dir.chdir(
|
|
28
|
+
Dir.chdir(FIXTURES_DIR)
|
|
29
29
|
|
|
30
30
|
# clear out files member from previous system test
|
|
31
31
|
PuppetCheck.files = {
|
|
@@ -47,7 +47,7 @@ describe PuppetCheck do
|
|
|
47
47
|
|
|
48
48
|
it 'uses override settings and outputs diagnostic results correctly after processing all of the files' do
|
|
49
49
|
# ensure rake only checks the files inside fixtures
|
|
50
|
-
Dir.chdir(
|
|
50
|
+
Dir.chdir(FIXTURES_DIR)
|
|
51
51
|
|
|
52
52
|
# clear out files member from previous system test
|
|
53
53
|
PuppetCheck.files = {
|
|
@@ -60,7 +60,7 @@ describe PuppetCheck do
|
|
|
60
60
|
# assign settings
|
|
61
61
|
settings = { style: true }
|
|
62
62
|
# see regression_check_spec
|
|
63
|
-
unless
|
|
63
|
+
unless CI_ENV
|
|
64
64
|
settings[:smoke] = true
|
|
65
65
|
settings[:octonodes] = %w[good.example.com]
|
|
66
66
|
settings[:octoconfig] = 'spec/octocatalog-diff/octocatalog-diff.cfg.rb'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: puppet-check
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.5.
|
|
4
|
+
version: 2.5.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matt Schuchard
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-02
|
|
11
|
+
date: 2026-05-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: puppet
|