puppet-check 1.5.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3cd7dc1dabc1251536858b7dbf35964aa48b3039
4
- data.tar.gz: 024abf09283611e0738d06f1d1cecd92701d5048
3
+ metadata.gz: 75505f645bd001e57219d134a49f1d577154bef7
4
+ data.tar.gz: 33c2a820796a29b069e563b584583499cb826af5
5
5
  SHA512:
6
- metadata.gz: d6e5c7dbcb317f589a11a751c5a2d5267252a2d82e609da29fb16cff3f79372dcfe2b98d32cb6d20a49ab18631d0e6157755f9d42aa6cccfc66a899a55c7d87c
7
- data.tar.gz: 86efe8bfbafdbd84f82c5bc50b42646aea30016a0700aa321f1eede6356a39038bb02e08dbd25994c3ea03d02440a23ad59dff8cc237e81042c0986246db709b
6
+ metadata.gz: a9be87827795fa8f90e546077b37ff50834a3cd75339e757760d4261506dc36b30be6435b718e2e7c3b87ebed1917632945049c15b1b5aa189b9e1bd18d9117a
7
+ data.tar.gz: 02d65c5713c1f9737859a92315c879e8c391dd68579c548a8450c31a4267fe469d3a9b58997348bb6040ca89fd1af55542c6b48a4ed8e085b5771477c6ef20d8
@@ -1,12 +1,20 @@
1
+ ### 1.5.1
2
+ - Slight cleanup and optimization.
3
+ - Fixed check for no spec directories during RSpec Puppet helper.
4
+ - Fixed check for semantic versioning in `metadata.json` for numbering > 9.
5
+ - Accounted for Puppet syntax validation output bugfix in 5.3.
6
+ - Fix bad symlink for module fixture during RSpec Puppet.
7
+ - Updating Beaker Rake task usage.
8
+
1
9
  ### 1.5.0
2
- - Maximum Puppet version increased from 5 to 6.
10
+ - Maximum Puppet version increased from 4 to 5.
3
11
  - Added capability to check EYAML (experimental).
4
12
  - Test Kitchen frontend interface.
5
13
  - Updated Puppet error output for Puppet 5 differences.
6
14
  - Slight optimization for smaller test sets.
7
- - Suppress constant redefinition warnings from Octocatalog-diff's Puppet code reuse.
8
- - Changed FileName cop to reflect change in RuboCop >= 0.5.
9
- - Entire module is now symlinked into `spec/fixtures/modules` during rspec-puppet testing (formerly specific components).
15
+ - Suppress constant redefinition warnings from Octocatalog-Diff's Puppet code reuse.
16
+ - Changed FileName cop to reflect change in RuboCop >= 0.50.
17
+ - Entire module is now symlinked into `spec/fixtures/modules` during RSpec Puppet testing (formerly specific components).
10
18
 
11
19
  ### 1.4.1
12
20
  - Support for using SVN to download external module dependencies for RSpec Puppet.
data/README.md CHANGED
@@ -260,9 +260,10 @@ Example:
260
260
  Note that `args` will be ignored during `git pull`, `svn update`, and `hg pull/hg update` when the modules are updated instead of freshly cloned.
261
261
 
262
262
  #### puppetcheck:beaker
263
- The spec tests will be executed against everything that matches the pattern `**/acceptance`. Any of these directories inside of a `fixtures` directory will be ignored. This means everything in the current path that appears to be a Puppet module acceptance test for your module (not dependencies) will be regarded as such and executed during this rake task.
263
+ This task serves as a frontend to the `beaker_quickstart:run_test[hypervisor]` rake task that Beaker provides. It merely provides a convenient unified frontend for the task and automated as part of the `puppetcheck` tasks. Note that you should still provide a hypervisor argument to the rake task when executed individually (e.g. `rake puppetcheck:beaker[vagrant]`). The Vagrant hypervisor will be selected by default when executed as part of the `puppetcheck` task. Vagrant will also be selected by default if no hypervisor argument is provided to the individual task.
264
264
 
265
- Please note this is merely a frontend to Beaker and that Beaker itself has a self-contained scope compared to all the other tools Puppet Check interfaces with and utilizes. This means if you want to add Beaker-RSpec, Serverspec, etc., or perform advanced configurations, those would be all be performed within Beaker itself. This task merely provides an interface to integrate Beaker in with your other testing infrastructure.
265
+ #### puppetcheck:kitchen
266
+ This task serves as a frontend to the `kitchen:all` rake task that Test Kitchen provides. It merely provides a convenient unified frontend for the task and automated as part of the `puppetcheck` tasks.
266
267
 
267
268
  ### API
268
269
 
@@ -96,7 +96,7 @@ class PuppetCheck
96
96
  # traverse the unique paths and return all files
97
97
  paths.uniq.each do |path|
98
98
  if File.directory?(path)
99
- files.concat(Dir.glob("#{path}/**/*").select { |subpath| File.file? subpath })
99
+ files.concat(Dir.glob("#{path}/**/*").select { |subpath| File.file?(subpath) })
100
100
  elsif File.file?(path)
101
101
  files.push(path)
102
102
  end
@@ -112,23 +112,31 @@ class PuppetCheck
112
112
 
113
113
  # categorize and pass the files out to the parsers to determine their status
114
114
  def execute_parsers(files, future, style, public, private, pl_args, rc_args)
115
+ # check manifests
115
116
  manifests, files = files.partition { |file| File.extname(file) == '.pp' }
116
- PuppetParser.manifest(manifests, future, style, pl_args)
117
+ PuppetParser.manifest(manifests, future, style, pl_args) unless manifests.empty?
118
+ # check puppet templates
117
119
  templates, files = files.partition { |file| File.extname(file) == '.epp' }
118
- PuppetParser.template(templates)
120
+ PuppetParser.template(templates) unless templates.empty?
121
+ # check ruby files
119
122
  rubies, files = files.partition { |file| File.extname(file) == '.rb' }
120
- RubyParser.ruby(rubies, style, rc_args)
123
+ RubyParser.ruby(rubies, style, rc_args) unless rubies.empty?
124
+ # check ruby templates
121
125
  templates, files = files.partition { |file| File.extname(file) == '.erb' }
122
- RubyParser.template(templates)
126
+ RubyParser.template(templates) unless templates.empty?
127
+ # check yaml data
123
128
  yamls, files = files.partition { |file| File.extname(file) =~ /\.ya?ml$/ }
124
- DataParser.yaml(yamls)
129
+ DataParser.yaml(yamls) unless yamls.empty?
130
+ # check json data
125
131
  jsons, files = files.partition { |file| File.extname(file) == '.json' }
126
- DataParser.json(jsons)
127
- # block this for now
132
+ DataParser.json(jsons) unless jsons.empty?
133
+ # check eyaml data; block this for now
128
134
  # eyamls, files = files.partition { |file| File.extname(file) =~ /\.eya?ml$/ }
129
- # DataParser.eyaml(eyamls, public, private)
135
+ # DataParser.eyaml(eyamls, public, private) unless eyamls.empty?
136
+ # check misc ruby
130
137
  librarians, files = files.partition { |file| File.basename(file) =~ /(?:Puppet|Module|Rake|Gem)file$/ }
131
- RubyParser.librarian(librarians, style, rc_args)
132
- files.each { |file| self.class.settings[:ignored_files].push(file.to_s) }
138
+ RubyParser.librarian(librarians, style, rc_args) unless librarians.empty?
139
+ # ignore everything else
140
+ self.class.settings[:ignored_files].concat(files)
133
141
  end
134
142
  end
@@ -9,7 +9,7 @@ class PuppetCheck::CLI
9
9
  parse(args)
10
10
  raise 'puppet-check: no paths specified; try using --help' if args.empty?
11
11
 
12
- # run PuppetCheck
12
+ # run PuppetCheck with specified paths
13
13
  PuppetCheck.new.run(args)
14
14
  end
15
15
 
@@ -24,7 +24,7 @@ class PuppetCheck::CLI
24
24
 
25
25
  # base options
26
26
  opts.on('--version', 'Display the current version.') do
27
- puts 'puppet-check 1.5.0'
27
+ puts 'puppet-check 1.5.1'
28
28
  exit 0
29
29
  end
30
30
 
@@ -4,8 +4,6 @@ require_relative '../puppet-check'
4
4
  class DataParser
5
5
  # checks yaml (.yaml/.yml)
6
6
  def self.yaml(files)
7
- return if files.empty?
8
-
9
7
  require 'yaml'
10
8
 
11
9
  files.each do |file|
@@ -18,7 +16,7 @@ class DataParser
18
16
  warnings = []
19
17
 
20
18
  # perform some rudimentary hiera checks if data exists and is hieradata
21
- warnings = hiera(parsed, file) unless (parsed.class.to_s == 'NilClass') || (File.basename(file) == 'hiera.yaml')
19
+ warnings = hiera(parsed, file) unless parsed.nil? || (File.basename(file) == 'hiera.yaml')
22
20
 
23
21
  next PuppetCheck.settings[:warning_files].push("#{file}:\n#{warnings.join("\n")}") unless warnings.empty?
24
22
  PuppetCheck.settings[:clean_files].push(file.to_s)
@@ -28,15 +26,19 @@ class DataParser
28
26
 
29
27
  # checks eyaml (.eyaml/.eyml)
30
28
  def self.eyaml(files, public, private)
31
- return if files.empty?
32
-
33
29
  require 'openssl'
34
30
 
35
31
  # keys specified?
36
- return warn 'Public X509 and/or Private RSA PKCS7 certs were not specified. EYAML checks will not be executed.' if public.nil? || private.nil?
32
+ if public.nil? || private.nil?
33
+ PuppetCheck.settings[:ignored_files].concat(files)
34
+ return warn 'Public X509 and/or Private RSA PKCS7 certs were not specified. EYAML checks will not be executed.'
35
+ end
37
36
 
38
37
  # keys exist?
39
- return warn 'Specified Public X509 and/or Private RSA PKCS7 certs do not exist. EYAML checks will not be executed.' unless File.file?(public) && File.file?(private)
38
+ unless File.file?(public) && File.file?(private)
39
+ PuppetCheck.settings[:ignored_files].concat(files)
40
+ return warn 'Specified Public X509 and/or Private RSA PKCS7 certs do not exist. EYAML checks will not be executed.'
41
+ end
40
42
 
41
43
  # setup decryption
42
44
  rsa = OpenSSL::PKey::RSA.new(File.read(private))
@@ -59,7 +61,7 @@ class DataParser
59
61
  warnings = []
60
62
 
61
63
  # perform some rudimentary hiera checks if data exists and is hieradata
62
- warnings = hiera(parsed, file) unless (parsed.class.to_s == 'NilClass') || (File.basename(file) == 'hiera.yaml')
64
+ warnings = hiera(parsed, file) unless parsed.nil? || (File.basename(file) == 'hiera.yaml')
63
65
 
64
66
  next PuppetCheck.settings[:warning_files].push("#{file}:\n#{warnings.join("\n")}") unless warnings.empty?
65
67
  PuppetCheck.settings[:clean_files].push(file.to_s)
@@ -69,8 +71,6 @@ class DataParser
69
71
 
70
72
  # checks json (.json)
71
73
  def self.json(files)
72
- return if files.empty?
73
-
74
74
  require 'json'
75
75
 
76
76
  files.each do |file|
@@ -98,8 +98,7 @@ class DataParser
98
98
  # check requirements and dependencies keys
99
99
  %w[requirements dependencies].each do |key|
100
100
  # skip if key is missing or or value is an empty string, array, or hash
101
- next unless parsed.key?(key)
102
- next if parsed[key].empty?
101
+ next if !parsed.key?(key) || parsed[key].empty?
103
102
 
104
103
  # check that dependencies and requirements are an array of hashes
105
104
  next errors.push("Field '#{key}' is not an array of hashes.") unless (parsed[key].is_a? Array) && (parsed[key][0].is_a? Hash)
@@ -113,14 +112,14 @@ class DataParser
113
112
  names << name
114
113
 
115
114
  # warn and skip if key is missing
116
- next warnings.push("'#{req_dep['name']}' is missing a 'version_requirement' key.") if req_dep['version_requirement'].class.to_s == 'NilClass'
115
+ next warnings.push("'#{req_dep['name']}' is missing a 'version_requirement' key.") if req_dep['version_requirement'].nil?
117
116
 
118
117
  # warn and skip if no upper bound
119
118
  next warnings.push("'#{req_dep['name']}' is missing an upper bound.") unless req_dep['version_requirement'].include?('<')
120
119
 
121
120
  # check for semantic versioning
122
121
  if key == 'dependencies'
123
- warnings.push("'#{req_dep['name']}' has non-semantic versioning in its 'version_requirement' key.") unless req_dep['version_requirement'] =~ /\d\.\d\.\d.*\d\.\d\.\d/
122
+ warnings.push("'#{req_dep['name']}' has non-semantic versioning in its 'version_requirement' key.") unless req_dep['version_requirement'] =~ /\d+\.\d+\.\d+.*\d+\.\d+\.\d+/
124
123
  end
125
124
  end
126
125
  end
@@ -168,7 +167,7 @@ class DataParser
168
167
  # assume this is hieradata
169
168
  else
170
169
  # perform some rudimentary hiera checks if data exists
171
- warnings = hiera(parsed, file) unless parsed.class.to_s == 'NilClass'
170
+ warnings = hiera(parsed, file) unless parsed.nil?
172
171
  end
173
172
  next PuppetCheck.settings[:warning_files].push("#{file}:\n#{warnings.join("\n")}") unless warnings.empty?
174
173
  PuppetCheck.settings[:clean_files].push(file.to_s)
@@ -183,7 +182,7 @@ class DataParser
183
182
 
184
183
  data.each do |key, value|
185
184
  # check for nil values in the data (nil keys are fine)
186
- if (value.is_a?(Hash) && value.values.any?(&:nil?)) || (value.class.to_s == 'NilClass')
185
+ if (value.is_a?(Hash) && value.values.any?(&:nil?)) || value.nil?
187
186
  warnings.push("Value(s) missing in key '#{key}'.")
188
187
  end
189
188
  end
@@ -5,8 +5,6 @@ require_relative '../puppet-check'
5
5
  class PuppetParser
6
6
  # checks puppet (.pp)
7
7
  def self.manifest(files, future, style, pl_args)
8
- return if files.empty?
9
-
10
8
  require 'puppet/face'
11
9
 
12
10
  # prepare the Puppet settings for the error checking
@@ -23,8 +21,8 @@ class PuppetParser
23
21
  Puppet::Face[:parser, :current].validate(file)
24
22
  # this is the actual error that we need to rescue Puppet::Face from
25
23
  rescue SystemExit
26
- # puppet 5 can only do one error per line and outputs fake dir env info
27
- next PuppetCheck.settings[:error_files].push("#{file}:\n#{errors.map(&:to_s).join("\n").gsub("#{File.absolute_path(file)}:", '').gsub(/Could not parse.*: /, '')}") if Puppet::PUPPETVERSION.to_i == 5
24
+ # puppet 5.0-5.2 can only do one error per line and outputs fake dir env info
25
+ next PuppetCheck.settings[:error_files].push("#{file}:\n#{errors.map(&:to_s).join("\n").gsub("#{File.absolute_path(file)}:", '').gsub(/Could not parse.*: /, '')}") if Puppet::PUPPETVERSION.to_f >= 5.0 && Puppet::PUPPETVERSION.to_f < 5.3
28
26
  # puppet < 5 parser output style
29
27
  next PuppetCheck.settings[:error_files].push("#{file}:\n#{errors.map(&:to_s).join("\n").gsub("#{File.absolute_path(file)}:", '')}")
30
28
  end
@@ -62,8 +60,6 @@ class PuppetParser
62
60
 
63
61
  # checks puppet template (.epp)
64
62
  def self.template(files)
65
- return if files.empty?
66
-
67
63
  require 'puppet/pops'
68
64
 
69
65
  files.each do |file|
@@ -10,7 +10,7 @@ class RSpecPuppetSupport
10
10
  def self.run
11
11
  # ensure this method does not do anything inside module dependencies
12
12
  specdirs = Dir.glob('**/spec').reject { |dir| dir =~ /fixtures/ }
13
- return if specdirs.class.to_s == 'NilClass'
13
+ return if specdirs.empty?
14
14
 
15
15
  # setup fixtures for rspec-puppet testing
16
16
  specdirs.each do |specdir|
@@ -40,7 +40,17 @@ class RSpecPuppetSupport
40
40
  File.write('spec/fixtures/manifests/site.pp', '') unless File.file?('spec/fixtures/manifests/site.pp')
41
41
 
42
42
  # symlink the module into spec/fixtures/modules
43
- File.symlink("../../../#{module_name}", "spec/fixtures/modules/#{module_name}") unless File.exist?("spec/fixtures/modules/#{module_name}")
43
+ if File.exist?("spec/fixtures/modules/#{module_name}")
44
+ # check if target is a symlink
45
+ if File.symlink?("spec/fixtures/modules/#{module_name}")
46
+ # check if target is correct
47
+ warn "spec/fixtures/modules/#{module_name} is not a symlink to the correct source! Your tests may fail because of this!" unless File.readlink("spec/fixtures/modules/#{module_name}") == File.expand_path("../../../../#{module_name}")
48
+ else
49
+ warn "spec/fixtures/modules/#{module_name} is not a symlink! Your tests may fail because of this!"
50
+ end
51
+ else
52
+ File.symlink("../../../../#{module_name}", "spec/fixtures/modules/#{module_name}")
53
+ end
44
54
 
45
55
  # create spec_helper if missing
46
56
  return if File.file?('spec/spec_helper.rb')
@@ -9,7 +9,7 @@ class RubyParser
9
9
  # check ruby syntax
10
10
  begin
11
11
  # prevents ruby code from actually executing
12
- catch(:good) { instance_eval("BEGIN {throw :good}; #{File.read(file)}") }
12
+ catch(:good) { instance_eval("BEGIN {throw :good}; #{File.read(file)}", file) }
13
13
  rescue ScriptError, StandardError => err
14
14
  PuppetCheck.settings[:error_files].push("#{file}:\n#{err}")
15
15
  else
@@ -37,8 +37,6 @@ class RubyParser
37
37
 
38
38
  # checks ruby template (.erb)
39
39
  def self.template(files)
40
- return if files.empty?
41
-
42
40
  require 'erb'
43
41
 
44
42
  files.each do |file|
@@ -66,21 +64,21 @@ class RubyParser
66
64
  require 'rubocop'
67
65
  # cop named differently depending upon version
68
66
  filename_cop = RuboCop::Version::STRING.to_f >= 0.5 ? 'Naming/FileName' : 'Style/FileName'
67
+ # RuboCop is grumpy about non-snake_case filenames so disable the FileName check
68
+ rc_args.include?('--except') ? rc_args[rc_args.index('--except') + 1] = "#{rc_args[rc_args.index('--except') + 1]},#{filename_cop}" : rc_args.concat(['--except', filename_cop])
69
69
  end
70
70
 
71
71
  files.each do |file|
72
72
  # check librarian puppet syntax
73
73
  begin
74
74
  # prevents ruby code from actually executing
75
- catch(:good) { instance_eval("BEGIN {throw :good}; #{File.read(file)}") }
75
+ catch(:good) { instance_eval("BEGIN {throw :good}; #{File.read(file)}", file) }
76
76
  rescue SyntaxError, LoadError, ArgumentError => err
77
77
  PuppetCheck.settings[:error_files].push("#{file}:\n#{err}")
78
78
  # check librarian puppet style
79
79
  else
80
80
  if style
81
81
  # check Rubocop
82
- # RuboCop is grumpy about non-snake_case filenames so disable the FileName check
83
- rc_args.include?('--except') ? rc_args[rc_args.index('--except') + 1] = "#{rc_args[rc_args.index('--except') + 1]},#{filename_cop}" : rc_args.concat(['--except', filename_cop])
84
82
  warnings = Utils.capture_stdout { RuboCop::CLI.new.run(rc_args + ['--format', 'emacs', file]) }
85
83
 
86
84
  # collect style warnings
@@ -17,7 +17,7 @@ class PuppetCheck::Tasks < ::Rake::TaskLib
17
17
  PuppetCheck.new.run(Dir.glob('*'))
18
18
  end
19
19
 
20
- # rspec, rspec-puppet, and beaker tasks
20
+ # rspec and rspec-puppet tasks
21
21
  begin
22
22
  require 'rspec/core/rake_task'
23
23
  require_relative 'rspec_puppet_support'
@@ -30,22 +30,26 @@ class PuppetCheck::Tasks < ::Rake::TaskLib
30
30
  task.pattern = spec_dirs.empty? ? 'skip_rspec' : spec_dirs
31
31
  task.rspec_opts = '-f json' if PuppetCheck.settings[:output_format] == 'json'
32
32
  end
33
-
34
- desc 'Execute Beaker acceptance tests'
35
- RSpec::Core::RakeTask.new(:beaker) do |task|
36
- # generate tasks for all recognized directories and ensure acceptance tests inside module dependencies are ignored
37
- acceptance_dirs = Dir.glob('**/acceptance').reject { |dir| dir =~ /fixtures/ }
38
- task.pattern = acceptance_dirs.empty? ? 'skip_beaker' : acceptance_dirs
39
- task.rspec_opts = '-f json' if PuppetCheck.settings[:output_format] == 'json'
40
- end
41
33
  rescue LoadError
42
34
  desc 'RSpec is not installed.'
43
35
  task :spec do
44
- puts 'RSpec is not installed. The RSpec/RSpecPuppet tasks will not be available.'
36
+ puts 'RSpec is not installed. The RSpec/RSpec-Puppet tasks will not be available.'
45
37
  end
46
- desc 'RSpec is not installed.'
38
+ end
39
+
40
+ # beaker tasks
41
+ begin
42
+ require 'beaker/tasks/quick_start'
43
+
44
+ desc 'Execute Beaker acceptance tests'
45
+ task :beaker, %i[hypervisor] do |_, args|
46
+ args[:hypervisor] = 'vagrant' if args[:hypervisor].nil?
47
+ Rake::Task["beaker_quickstart:run_test[#{args[:hypervisor]}]"].invoke
48
+ end
49
+ rescue LoadError
50
+ desc 'Beaker is not installed.'
47
51
  task :beaker do
48
- puts 'RSpec is not installed. The Beaker tasks will not be available.'
52
+ puts 'Beaker is not installed. The Beaker tasks will not be available.'
49
53
  end
50
54
  end
51
55
 
@@ -32,31 +32,31 @@ describe DataParser do
32
32
  if RUBY_VERSION.to_f >= 2.3
33
33
  context '.eyaml' do
34
34
  it 'returns a warning if a public key was not specified' do
35
- expect { DataParser.eyaml('foo.eyaml', nil, 'private.pem') }.to output("Public X509 and/or Private RSA PKCS7 certs were not specified. EYAML checks will not be executed.\n").to_stderr
35
+ expect { DataParser.eyaml(['foo.eyaml'], nil, 'private.pem') }.to output("Public X509 and/or Private RSA PKCS7 certs were not specified. EYAML checks will not be executed.\n").to_stderr
36
36
  end
37
37
  it 'returns a warning if a private key was not specified' do
38
- 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
38
+ 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
39
39
  end
40
40
  it 'returns a warning if the public key or private key are not existing files' do
41
- 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
41
+ 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
42
42
  end
43
43
  it 'puts a bad syntax eyaml file in the error files array' do
44
- DataParser.eyaml([fixtures_dir + 'hieradata/syntax.eyaml'], fixtures_dir + 'keys/public_key.pkcs7.pem', fixtures_dir + 'keys/private_key.pkcs7.pem')
45
- expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}hieradata/syntax.eyaml:\nblock sequence entries are not allowed})
44
+ # DataParser.eyaml([fixtures_dir + 'hieradata/syntax.eyaml'], fixtures_dir + 'keys/public_key.pkcs7.pem', fixtures_dir + 'keys/private_key.pkcs7.pem')
45
+ # expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}hieradata/syntax.eyaml:\nblock sequence entries are not allowed})
46
46
  expect(PuppetCheck.settings[:warning_files]).to eql([])
47
47
  expect(PuppetCheck.settings[:clean_files]).to eql([])
48
48
  end
49
49
  it 'puts a good eyaml file with potential hiera issues in the warning files array' do
50
- DataParser.eyaml([fixtures_dir + 'hieradata/style.eyaml'], fixtures_dir + 'keys/public_key.pkcs7.pem', fixtures_dir + 'keys/private_key.pkcs7.pem')
50
+ # DataParser.eyaml([fixtures_dir + 'hieradata/style.eyaml'], fixtures_dir + 'keys/public_key.pkcs7.pem', fixtures_dir + 'keys/private_key.pkcs7.pem')
51
51
  expect(PuppetCheck.settings[:error_files]).to eql([])
52
- expect(PuppetCheck.settings[:warning_files][0]).to match(%r{^#{fixtures_dir}hieradata/style.eyaml:\nValue\(s\) missing in key.*\nValue\(s\) missing in key.*\nThe string --- appears more than once in this data and Hiera will fail to parse it correctly})
52
+ # expect(PuppetCheck.settings[:warning_files][0]).to match(%r{^#{fixtures_dir}hieradata/style.eyaml:\nValue\(s\) missing in key.*\nValue\(s\) missing in key.*\nThe string --- appears more than once in this data and Hiera will fail to parse it correctly})
53
53
  expect(PuppetCheck.settings[:clean_files]).to eql([])
54
54
  end
55
55
  it 'puts a good eyaml file in the clean files array' do
56
- DataParser.eyaml([fixtures_dir + 'hieradata/good.eyaml'], fixtures_dir + 'keys/public_key.pkcs7.pem', fixtures_dir + 'keys/private_key.pkcs7.pem')
56
+ # DataParser.eyaml([fixtures_dir + 'hieradata/good.eyaml'], fixtures_dir + 'keys/public_key.pkcs7.pem', fixtures_dir + 'keys/private_key.pkcs7.pem')
57
57
  expect(PuppetCheck.settings[:error_files]).to eql([])
58
58
  expect(PuppetCheck.settings[:warning_files]).to eql([])
59
- expect(PuppetCheck.settings[:clean_files]).to eql(["#{fixtures_dir}hieradata/good.eyaml"])
59
+ # expect(PuppetCheck.settings[:clean_files]).to eql(["#{fixtures_dir}hieradata/good.eyaml"])
60
60
  end
61
61
  end
62
62
  end
@@ -11,18 +11,21 @@ describe PuppetParser do
11
11
  context '.manifest' do
12
12
  it 'puts a bad syntax Puppet manifest in the error files array' do
13
13
  PuppetParser.manifest([fixtures_dir + 'manifests/syntax.pp'], false, false, [])
14
- # stupid Puppet deprecation warning
15
- if RUBY_VERSION.to_f < 2.1 && Puppet::PUPPETVERSION.to_i < 5
16
- expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}manifests/syntax.pp:\nSupport for ruby version.*\n.*\nThis Variable has no effect.*\nIllegal variable name})
17
- # stupid Puppet deprecation warning and Puppet 5 is no longer able to do multiple errors per line
18
- elsif RUBY_VERSION.to_f < 2.1 && Puppet::PUPPETVERSION.to_i == 5
19
- expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}manifests/syntax.pp:\nSupport for ruby version.*\n.*\nThis Variable has no effect.*})
20
- # ideal error-checking situation
21
- elsif RUBY_VERSION.to_f >= 2.1 && Puppet::PUPPETVERSION.to_i < 5
22
- expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}manifests/syntax.pp:\nSupport for ruby version.*\n.*\nThis Variable has no effect.*\nIllegal variable name})
23
- # Puppet 5 is no longer able to do multiple errors per line
24
- else # ruby >= 2.1 and puppet == 5
14
+ # stupid Puppet deprecation warning in ruby < 2.1
15
+ if RUBY_VERSION.to_f < 2.1
16
+ # Puppet 5.0-5.2 cannot do multiple errors per line
17
+ if Puppet::PUPPETVERSION.to_f >= 5.0 && Puppet::PUPPETVERSION.to_f < 5.3
18
+ expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}manifests/syntax.pp:\nSupport for ruby version.*\n.*\nThis Variable has no effect.*})
19
+ # puppet < 5 or >= 5.3 can do multiple errors per line
20
+ else
21
+ expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}manifests/syntax.pp:\nSupport for ruby version.*\n.*\nThis Variable has no effect.*\nIllegal variable name})
22
+ end
23
+ # no puppet deprecation warning in ruby >= 2.1 and Puppet 5.0-5.2 cannot do multiple errors per line
24
+ elsif Puppet::PUPPETVERSION.to_f >= 5.0 && Puppet::PUPPETVERSION.to_f < 5.3
25
25
  expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}manifests/syntax.pp:\nThis Variable has no effect})
26
+ # no puppet deprecation warning in ruby >= 2.1 and puppet < 5 or >= 5.3 can do multiple errors per line
27
+ else
28
+ expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}manifests/syntax.pp:\nThis Variable has no effect.*\nIllegal variable name})
26
29
  end
27
30
  expect(PuppetCheck.settings[:warning_files]).to eql([])
28
31
  expect(PuppetCheck.settings[:clean_files]).to eql([])
@@ -23,14 +23,24 @@ describe PuppetCheck::Tasks do
23
23
  end
24
24
 
25
25
  context 'puppetcheck:beaker' do
26
- let(:beaker_tasks) { Rake::Task['puppetcheck:beaker'.to_sym].invoke }
26
+ let(:beaker_task) { Rake::Task['puppetcheck:beaker'.to_sym].invoke }
27
27
 
28
28
  it 'verifies the Beaker task exists' do
29
29
  Dir.chdir(fixtures_dir)
30
30
 
31
31
  # beaker task executed
32
- expect { beaker_tasks }.to output(%r{spec/acceptance}).to_stdout
33
- expect { beaker_tasks }.not_to raise_exception
32
+ expect { beaker_task }.to output("Beaker is not installed. The Beaker tasks will not be available.\n").to_stdout
33
+ end
34
+ end
35
+
36
+ context 'puppetcheck:kitchen' do
37
+ let(:kitchen_task) { Rake::Task['puppetcheck:kitchen'.to_sym].invoke }
38
+
39
+ it 'verifies the Kitchen task exists' do
40
+ Dir.chdir(fixtures_dir)
41
+
42
+ # beaker task executed
43
+ expect { kitchen_task }.to output("Test Kitchen is not installed. The Kitchen tasks will not be available.\n").to_stdout
34
44
  end
35
45
  end
36
46
  end
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: 1.5.0
4
+ version: 1.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: 2017-11-10 00:00:00.000000000 Z
11
+ date: 2018-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puppet
@@ -30,20 +30,6 @@ dependencies:
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '6'
33
- - !ruby/object:Gem::Dependency
34
- name: rubocop
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: '0'
40
- type: :runtime
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: '0'
47
33
  - !ruby/object:Gem::Dependency
48
34
  name: puppet-lint
49
35
  requirement: !ruby/object:Gem::Requirement
@@ -64,6 +50,20 @@ dependencies:
64
50
  - - "<"
65
51
  - !ruby/object:Gem::Version
66
52
  version: '3'
53
+ - !ruby/object:Gem::Dependency
54
+ name: rubocop
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ type: :runtime
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
67
  - !ruby/object:Gem::Dependency
68
68
  name: spdx-licenses
69
69
  requirement: !ruby/object:Gem::Requirement