puppet-check 2.3.0 → 2.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: caea7da11b0b884512bc9e078c71caece3bfb2045f5798c55b41201b948e5d3f
4
- data.tar.gz: 6e4eae239a2cbbeda1709741c523161720dd8b28399d9e1e5cae6add54cef59b
3
+ metadata.gz: d04c10fa6bc7d10b70113b7d93ab7be0d0f5cc1e65e0976e2e40e3edcc561ff8
4
+ data.tar.gz: 5e0fc0e541f9aa21bc65015cc0bc5958a8d44b3aaf36b8d1ce5e69f3942b9221
5
5
  SHA512:
6
- metadata.gz: 18d8d802b337a1b47de63aa25a4f0c2b7e6f6f6678047b2f941a28766ee7d1a18f07244b287faf37747170d170230dfb58073f67a63dce95513421acd125ca5a
7
- data.tar.gz: '09031de8c432747e7967241ff0abd4290d34d38892eb4df0443e3f7e88acd5d30c177fbabf811a6958874533fe951ea795965acea0617d21e0f2f28832987e17'
6
+ metadata.gz: d762b4386dc42703ffea264872629684f35a98ddbf69b2eb3fb82f9039a614e146a9a6d6961c51086c33dffd80e8d192a973f4025adc355d355d1d20e442d039
7
+ data.tar.gz: 90cea3c4ebc6a20d48793276f3563f7d82e8067b94ab3f3ff0c6e51bbbe8de00333c34b157baec92ed919d110eb9eb29065d90e04c01c1e7a287ae2ce3ed78fc
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ### 2.3.1
2
+ - No input target paths now defaults to current working directory instead of error.
3
+ - Additionally check `Vagrantfile` and `gemspec` files.
4
+ - Fix and improve behavior for when optional dependency `octocatalog-diff` is absent.
5
+
1
6
  ### 2.3.0
2
7
  - Minimum Ruby version increased to 2.7.
3
8
  - Support Puppet 8.
@@ -6,7 +6,9 @@ class PuppetCheck::CLI
6
6
  def self.run(args)
7
7
  # gather the user arguments
8
8
  settings = parse(args)
9
- raise 'puppet-check: no file paths specified; try using --help' if args.empty?
9
+
10
+ # target cwd if no paths input as variadic
11
+ args = [Dir.pwd] if args.empty?
10
12
 
11
13
  # run PuppetCheck with specified paths
12
14
  PuppetCheck.new.run(settings, args)
@@ -2,6 +2,13 @@ require_relative '../puppet_check'
2
2
 
3
3
  # class to handle outputting diagnostic results in desired format
4
4
  class OutputResults
5
+ HEADER = {
6
+ errors: "\033[31mThe following files have errors:\033[0m\n",
7
+ warnings: "\033[33mThe following files have warnings:\033[0m\n",
8
+ clean: "\033[32mThe following files have no errors or warnings:\033[0m\n-- ",
9
+ ignored: "\033[36mThe following files have unrecognized formats and therefore were not processed:\033[0m\n-- "
10
+ }.freeze
11
+
5
12
  # output the results in various formats
6
13
  def self.run(files, format)
7
14
  # remove empty entries
@@ -28,31 +35,26 @@ class OutputResults
28
35
  def self.text(files)
29
36
  private_class_method :method
30
37
 
31
- # errors
32
- category_info("\033[31mThe following files have errors:\033[0m\n", files[:errors]) if files.key?(:errors)
33
- # warnings
34
- category_info("\033[33mThe following files have warnings:\033[0m\n", files[:warnings]) if files.key?(:warnings)
35
- # cleans
36
- category_info("\033[32mThe following files have no errors or warnings:\033[0m\n-- ", files[:clean]) if files.key?(:clean)
37
- # ignores
38
- return unless files.key?(:ignored)
39
- category_info("\033[36mThe following files have unrecognized formats and therefore were not processed:\033[0m\n-- ", files[:ignored])
40
- end
38
+ # output text for each of four file categories
39
+ %i[errors warnings clean ignored].each do |category|
40
+ # immediately return if category is empty
41
+ next unless files.key?(category)
41
42
 
42
- # display heading, files, and file messages per category for text formatting
43
- def self.category_info(heading, files)
44
- private_class_method :method
45
- # display category heading
46
- print heading
47
-
48
- # display files and optionally messages
49
- case files
50
- when Hash then files.each { |file, messages| puts "-- #{file}:\n#{messages.join("\n")}" }
51
- when Array then puts files.join("\n-- ")
52
- else raise "puppet-check: The category files were of unexpected type #{files.class}. Please file an issue with this log message, category heading, and information about the parsed files."
53
- end
43
+ # display heading, files, and file messages per category for text formatting
44
+ category_files = files[category]
54
45
 
55
- # newline between categories for easier visual parsing
56
- puts ''
46
+ # display category heading
47
+ print HEADER[category]
48
+
49
+ # display files and optionally messages
50
+ case category_files
51
+ when Hash then category_files.each { |file, messages| puts "-- #{file}:\n#{messages.join("\n")}" }
52
+ when Array then puts category_files.join("\n-- ")
53
+ else raise "puppet-check: The files category was of unexpected type #{category_files.class}. Please file an issue with this log message, category heading, and information about the parsed files."
54
+ end
55
+
56
+ # newline between categories for easier visual parsing
57
+ puts ''
58
+ end
57
59
  end
58
60
  end
@@ -1,29 +1,34 @@
1
- # temporarily supress warning messages for octocatalog-diff redefining puppet constants and then reactivate
2
- $VERBOSE = nil
3
- require 'octocatalog-diff'
4
- $VERBOSE = false
1
+ begin
2
+ # temporarily supress warning messages for octocatalog-diff redefining puppet constants and then reactivate
3
+ $VERBOSE = nil
4
+ require 'octocatalog-diff'
5
+ $VERBOSE = false
5
6
 
6
- # executes smoke and regression tests on catalogs
7
- class RegressionCheck
8
- # smoke testing
9
- def self.smoke(interface_nodes, octoconfig)
10
- options = config(octoconfig)
11
- nodes = options.key?(:node) ? [options[:node]] : interface_nodes
12
- nodes.each do |node|
13
- options[:node] = node
14
- OctocatalogDiff::API::V1.catalog(options)
7
+ # executes smoke and regression tests on catalogs
8
+ class RegressionCheck
9
+ # smoke testing
10
+ def self.smoke(interface_nodes, octoconfig)
11
+ options = config(octoconfig)
12
+ nodes = options.key?(:node) ? [options[:node]] : interface_nodes
13
+ nodes.each do |node|
14
+ options[:node] = node
15
+ OctocatalogDiff::API::V1.catalog(options)
16
+ end
15
17
  end
16
- end
17
18
 
18
- # regression testing
19
- # def self.regression(nodes, octoconfig)
20
- # options = RegressionCheck.config(octoconfig)
21
- # nodes.each { |node| stuff }
22
- # end
19
+ # regression testing
20
+ # def self.regression(nodes, octoconfig)
21
+ # options = RegressionCheck.config(octoconfig)
22
+ # nodes.each { |node| stuff }
23
+ # end
23
24
 
24
- # config file loading
25
- def self.config(octoconfig)
26
- private_class_method :method
27
- OctocatalogDiff::API::V1.config(filename: octoconfig)
25
+ # config file loading
26
+ def self.config(octoconfig)
27
+ private_class_method :method
28
+ OctocatalogDiff::API::V1.config(filename: octoconfig)
29
+ end
28
30
  end
31
+ rescue LoadError
32
+ warn 'puppet-check: octocatalog-diff is not installed, and therefore the regression checks will be skipped'
33
+ $VERBOSE = false
29
34
  end
@@ -17,8 +17,8 @@ class RubyParser
17
17
 
18
18
  files.each do |file|
19
19
  # check ruby syntax
20
- # prevents ruby code from actually executing
21
- catch(:good) { instance_eval("BEGIN {throw :good}; #{File.read(file)}", file) }
20
+ # prevents ruby code from actually executing the input ruby file
21
+ catch(:good) { instance_eval("BEGIN {throw :good}; #{File.read(file)} # BEGIN {throw :good}; ruby_file_content", file) }
22
22
  rescue ScriptError, StandardError => err
23
23
  PuppetCheck.files[:errors][file] = err.to_s.gsub("#{file}:", '').split("\n")
24
24
  else
@@ -80,8 +80,8 @@ class RubyParser
80
80
 
81
81
  files.each do |file|
82
82
  # check librarian puppet syntax
83
- # prevents ruby code from actually executing
84
- catch(:good) { instance_eval("BEGIN {throw :good}; #{File.read(file)}", file) }
83
+ # prevents ruby code from actually executing the input ruby file
84
+ catch(:good) { instance_eval("BEGIN {throw :good}; #{File.read(file)} # BEGIN {throw :good}; ruby_file_content", file) }
85
85
  rescue SyntaxError, LoadError, ArgumentError => err
86
86
  PuppetCheck.files[:errors][file] = err.to_s.gsub("#{file}:", '').split("\n")
87
87
  # check librarian puppet style
data/lib/puppet_check.rb CHANGED
@@ -36,15 +36,12 @@ class PuppetCheck
36
36
  if parsed_files[:errors].empty? && (!settings[:fail_on_warning] || parsed_files[:warnings].empty?)
37
37
  begin
38
38
  require_relative 'puppet-check/regression_check'
39
- # if octocatalog-diff is not installed then return immediately
40
- rescue LoadError
41
- warn 'octocatalog-diff is not installed, and therefore the regressions check will be skipped'
42
- return 0
43
- end
44
39
 
45
- # perform smoke checks if there were no errors and the user desires
46
- begin
40
+ # perform smoke checks if there were no errors and the user desires
47
41
  catalog = RegressionCheck.smoke(settings[:octonodes], settings[:octoconfig]) if settings[:smoke]
42
+ # if octocatalog-diff is not installed then continue immediately
43
+ rescue NameError
44
+ puts 'puppet-check: immediately continuing to results'
48
45
  # smoke check failure? output message and return 2
49
46
  rescue OctocatalogDiff::Errors::CatalogError => err
50
47
  puts 'There was a smoke check error:'
@@ -61,6 +58,7 @@ class PuppetCheck
61
58
  # puts catalog.error_message unless catalog.valid?
62
59
  # 2
63
60
  # end
61
+
64
62
  # code to output differences in catalog?
65
63
  # everything passed? return 0
66
64
  0
@@ -143,7 +141,7 @@ class PuppetCheck
143
141
  eyamls, files = files.partition { |file| File.extname(file) =~ /\.eya?ml$/ }
144
142
  DataParser.eyaml(eyamls, public, private) unless eyamls.empty?
145
143
  # check misc ruby
146
- librarians, files = files.partition { |file| File.basename(file) =~ /(?:Puppet|Module|Rake|Gem)file$/ }
144
+ librarians, files = files.partition { |file| File.basename(file) =~ /(?:Puppet|Module|Rake|Gem|Vagrant)file|.gemspec$/ }
147
145
  RubyParser.librarian(librarians, style, rubocop_args) unless librarians.empty?
148
146
  # ignore everything else
149
147
  files.each { |file| self.class.files[:ignored].push(file.to_s) }
@@ -0,0 +1,23 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = 'puppet-check'
3
+ spec.version = '2.3.1'
4
+ spec.authors = ['Matt Schuchard']
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
+ spec.summary = 'A streamlined comprehensive set of checks for your entire Puppet code and data'
7
+ spec.homepage = 'https://www.github.com/mschuchard/puppet-check'
8
+ spec.license = 'MIT'
9
+
10
+ spec.files = Dir['bin/**/*', 'lib/**/*', 'spec/**/*', 'CHANGELOG.md', 'LICENSE.md', 'README.md', 'puppet-check.gemspec']
11
+ spec.executables = spec.files.grep(%r{^bin/}) { |file| File.basename(file) }
12
+ spec.require_paths = Dir['lib']
13
+
14
+ spec.required_ruby_version = '>= 2.7.0'
15
+ spec.add_dependency 'puppet', '>= 5.5', '< 9'
16
+ spec.add_dependency 'puppet-lint', '~> 4.0'
17
+ spec.add_dependency 'reek', '~> 6.0'
18
+ spec.add_dependency 'rubocop', '~> 1.0'
19
+ spec.add_dependency 'rubocop-performance', '~> 1.0'
20
+ # spec.add_development_dependency 'octocatalog-diff', '~> 2.0'
21
+ spec.add_development_dependency 'rake', '~> 13.0'
22
+ spec.add_development_dependency 'rspec', '~> 3.0'
23
+ end
@@ -3,14 +3,16 @@ require_relative '../../lib/puppet-check/cli'
3
3
 
4
4
  describe PuppetCheck::CLI do
5
5
  context '.run' do
6
- it 'raises an error if no paths were specified' do
7
- expect { PuppetCheck::CLI.run(%w[-s -f]) }.to raise_error(RuntimeError, 'puppet-check: no file paths specified; try using --help')
6
+ it 'targets the current working directory if no paths were specified' do
7
+ expect { PuppetCheck::CLI.run(%w[--fail-on-warnings]) }.not_to raise_exception
8
+ expect(PuppetCheck.files[:clean].length).to eql(30)
9
+ expect(PuppetCheck.files[:ignored].length).to eql(7)
8
10
  end
9
11
  end
10
12
 
11
13
  context '.parse' do
12
14
  it 'raises an error if an invalid option was specified' do
13
- expect { PuppetCheck::CLI.parse(%w[-s -f -asdf foo]) }.to raise_error(OptionParser::InvalidOption)
15
+ expect { PuppetCheck::CLI.parse(%w[-s -asdf foo]) }.to raise_error(OptionParser::InvalidOption)
14
16
  end
15
17
 
16
18
  it 'allows fail on warnings, style, smoke, and regression checks to be enabled' do
@@ -15,7 +15,7 @@ describe DataParser do
15
15
  it 'puts a bad syntax yaml file in the error files hash' do
16
16
  DataParser.yaml(["#{fixtures_dir}hieradata/syntax.yaml"])
17
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(%r{^block sequence entries are not allowed})
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
@@ -23,7 +23,7 @@ describe DataParser do
23
23
  DataParser.yaml(["#{fixtures_dir}hieradata/style.yaml"])
24
24
  expect(PuppetCheck.files[:errors]).to eql({})
25
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(%r{^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})
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
@@ -47,7 +47,7 @@ describe DataParser do
47
47
  it 'puts a bad syntax eyaml file in the error files hash' do
48
48
  DataParser.eyaml(["#{fixtures_dir}hieradata/syntax.eyaml"], "#{fixtures_dir}keys/public_key.pkcs7.pem", "#{fixtures_dir}keys/private_key.pkcs7.pem")
49
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(%r{^block sequence entries are not allowed})
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
@@ -55,7 +55,7 @@ describe DataParser do
55
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
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(%r{^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})
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
@@ -70,14 +70,14 @@ describe DataParser do
70
70
  it 'puts a bad syntax json file in the error files hash' do
71
71
  DataParser.json(["#{fixtures_dir}hieradata/syntax.json"])
72
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(%r{^.*unexpected token})
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
78
  DataParser.json(["#{fixtures_dir}metadata_syntax/metadata.json"])
79
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(%r{^Required field.*\nField 'requirements'.*\nDuplicate dependencies.*\nDeprecated field.*\nSummary exceeds})
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
@@ -85,7 +85,7 @@ describe DataParser do
85
85
  DataParser.json(["#{fixtures_dir}metadata_style/metadata.json"])
86
86
  expect(PuppetCheck.files[:errors]).to eql({})
87
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(%r{^'pe' is missing an upper bound.\n.*operatingsystem_support.*\nLicense identifier})
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
@@ -99,7 +99,7 @@ describe DataParser do
99
99
  DataParser.json(["#{fixtures_dir}task_metadata/task_bad.json"])
100
100
  expect(PuppetCheck.files[:errors]).to eql({})
101
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(%r{^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})
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
@@ -16,9 +16,9 @@ describe PuppetParser do
16
16
  PuppetParser.manifest(["#{fixtures_dir}manifests/syntax.pp"], false, [])
17
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]["#{fixtures_dir}manifests/syntax.pp"].join("\n")).to match(%r{^Language validation logged 2 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]["#{fixtures_dir}hieradata/syntax.yaml"].join("\n")).to match(%r{^This Variable has no effect.*\nIllegal variable name})
21
+ expect(PuppetCheck.files[:errors]["#{fixtures_dir}hieradata/syntax.yaml"].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([])
@@ -28,7 +28,7 @@ describe PuppetParser do
28
28
  it 'puts a bad syntax at eof Puppet manifest in the error files hash' do
29
29
  PuppetParser.manifest(["#{fixtures_dir}manifests/eof_syntax.pp"], false, [])
30
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(%r{^Syntax error at end of input})
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
@@ -36,7 +36,7 @@ describe PuppetParser do
36
36
  it 'puts a bad syntax Puppet plan in the error files hash' do
37
37
  PuppetParser.manifest(["#{fixtures_dir}plans/syntax.pp"], false, [])
38
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(%r{^Syntax error at '\)'})
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
@@ -44,14 +44,14 @@ describe PuppetParser do
44
44
  PuppetParser.manifest(["#{fixtures_dir}manifests/style_parser.pp"], true, [])
45
45
  expect(PuppetCheck.files[:errors]).to eql({})
46
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(%r{^Unrecognized escape sequence.*\nUnrecognized escape sequence.*\n.*double quoted string containing})
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
51
  PuppetParser.manifest(["#{fixtures_dir}manifests/style_lint.pp"], true, [])
52
52
  expect(PuppetCheck.files[:errors]).to eql({})
53
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(%r{(?:indentation of|double quoted string containing).*\n.*(?:indentation of|double quoted string containing)})
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
@@ -64,7 +64,7 @@ describe PuppetParser do
64
64
  PuppetParser.manifest(["#{fixtures_dir}plans/style.pp"], true, [])
65
65
  expect(PuppetCheck.files[:errors]).to eql({})
66
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(%r{variable not enclosed in {}})
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
@@ -88,7 +88,7 @@ describe PuppetParser do
88
88
  it 'puts a bad syntax Puppet template in the error files hash' do
89
89
  PuppetParser.template(["#{fixtures_dir}templates/syntax.epp"])
90
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(%r{^This Name has no effect})
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
@@ -1,35 +1,41 @@
1
1
  require_relative '../spec_helper'
2
- require_relative '../../lib/puppet-check/regression_check'
2
+ begin
3
+ require_relative '../../lib/puppet-check/regression_check'
3
4
 
4
- # once a good config is loaded, bad configs would have no effect so failures are tested first; config is also tested before compilation so that the good config can be loaded at the end and used for compilation and regression tests
5
- describe RegressionCheck do
6
- context '.config' do
7
- # json gem got messed up for the EOL Ruby versions
8
- it 'raise an appropriate error if the file is malformed' do
9
- expect { RegressionCheck.config("#{fixtures_dir}metadata.json") }.to raise_error(OctocatalogDiff::Errors::ConfigurationFileContentError, 'Configuration must define OctocatalogDiff::Config!')
10
- end
11
- it 'loads in a good octocatalog-diff config file' do
12
- expect { RegressionCheck.config("#{octocatalog_diff_dir}octocatalog_diff.cfg.rb") }.not_to raise_exception
13
- end
14
- it 'loads in the settings from the file correctly' do
5
+ # once a good config is loaded, bad configs would have no effect so failures are tested first; config is also tested before compilation so that the good config can be loaded at the end and used for compilation and regression tests
6
+ describe RegressionCheck do
7
+ context '.config' do
8
+ # json gem is messed up for the EOL Ruby versions
9
+ it 'raise an appropriate error if the file is malformed' do
10
+ expect { RegressionCheck.config("#{fixtures_dir}metadata.json") }.to raise_error(OctocatalogDiff::Errors::ConfigurationFileContentError, 'Configuration must define OctocatalogDiff::Config!')
11
+ end
12
+ it 'loads in a good octocatalog-diff config file' do
13
+ expect { RegressionCheck.config("#{octocatalog_diff_dir}octocatalog_diff.cfg.rb") }.not_to raise_exception
14
+ end
15
+ it 'loads in the settings from the file correctly' do
16
+ # TODO
17
+ end
15
18
  end
16
- end
17
19
 
18
- context '.smoke' do
19
- # octocatalog-diff is returning a blank error for these tests
20
- unless ENV['CIRCLECI'] == 'true' || ENV['GITHUB_ACTIONS'] == 'true'
21
- it 'returns a pass for a successful catalog compilation' do
22
- expect { RegressionCheck.smoke(['good.example.com'], "#{octocatalog_diff_dir}octocatalog_diff.cfg.rb") }.not_to raise_exception
20
+ context '.smoke' do
21
+ # octocatalog-diff is returning a blank error for these tests
22
+ unless ENV['CIRCLECI'] == 'true' || ENV['GITHUB_ACTIONS'] == 'true'
23
+ it 'returns a pass for a successful catalog compilation' do
24
+ expect { RegressionCheck.smoke(['good.example.com'], "#{octocatalog_diff_dir}octocatalog_diff.cfg.rb") }.not_to raise_exception
25
+ end
26
+ it 'returns a failure for a catalog with an error' do
27
+ expect { RegressionCheck.smoke(['does_not_exist.example.com'], "#{octocatalog_diff_dir}octocatalog_diff.cfg.rb") }.to raise_error(OctocatalogDiff::Errors::CatalogError)
28
+ end
23
29
  end
24
- it 'returns a failure for a catalog with an error' do
25
- expect { RegressionCheck.smoke(['does_not_exist.example.com'], "#{octocatalog_diff_dir}octocatalog_diff.cfg.rb") }.to raise_error(OctocatalogDiff::Errors::CatalogError)
30
+ it 'returns a failure for a good and bad catalog' do
31
+ # RegressionCheck.smoke(['good.example.com', 'syntax_error.example.com'], "#{fixtures_dir}octocatalog_diff.cfg.rb")
26
32
  end
27
33
  end
28
- it 'returns a failure for a good and bad catalog' do
29
- # RegressionCheck.smoke(['good.example.com', 'syntax_error.example.com'], "#{fixtures_dir}octocatalog_diff.cfg.rb")
30
- end
31
- end
32
34
 
33
- context '.regression' do
35
+ context '.regression' do
36
+ # TODO
37
+ end
34
38
  end
39
+ rescue NameError
40
+ puts 'puppet-check+rspec: octocatalog-diff is not installed, and its unit tests will be skipped'
35
41
  end
@@ -15,7 +15,7 @@ describe RubyParser do
15
15
  it 'puts a bad syntax ruby file in the error files hash' do
16
16
  RubyParser.ruby(["#{fixtures_dir}lib/syntax.rb"], false, [])
17
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(%r{^.*syntax error})
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
@@ -23,7 +23,7 @@ describe RubyParser do
23
23
  RubyParser.ruby(["#{fixtures_dir}lib/style.rb"], true, [])
24
24
  expect(PuppetCheck.files[:errors]).to eql({})
25
25
  expect(PuppetCheck.files[:warnings].keys).to eql(["#{fixtures_dir}lib/style.rb"])
26
- expect(PuppetCheck.files[:warnings]["#{fixtures_dir}lib/style.rb"].join("\n")).to match(%r{Useless assignment.*\n.*Use the new.*\n.*Do not introduce.*\n.*Prefer single.*\n.*Remove unnecessary empty.*\n.*Source code comment is empty.*\n.*is a writable attribute.*\n.*Issue has no descriptive comment})
26
+ 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.*\n.*is a writable attribute.*\n.*Issue has no descriptive comment/)
27
27
  expect(PuppetCheck.files[:clean]).to eql([])
28
28
  end
29
29
  it 'puts a bad style ruby file in the clean files array when rubocop_args ignores its warnings' do
@@ -45,9 +45,9 @@ describe RubyParser do
45
45
  RubyParser.template(["#{fixtures_dir}templates/syntax.erb"])
46
46
  expect(PuppetCheck.files[:errors].keys).to eql(["#{fixtures_dir}templates/syntax.erb"])
47
47
  if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7')
48
- expect(PuppetCheck.files[:errors]["#{fixtures_dir}templates/syntax.erb"].join("\n")).to match(%r{1: syntax error, unexpected.*\n.*ruby})
48
+ expect(PuppetCheck.files[:errors]["#{fixtures_dir}templates/syntax.erb"].join("\n")).to match(/1: syntax error, unexpected.*\n.*ruby/)
49
49
  else
50
- expect(PuppetCheck.files[:errors]["#{fixtures_dir}templates/syntax.erb"].join("\n")).to match(%r{syntax error, unexpected tIDENTIFIER})
50
+ expect(PuppetCheck.files[:errors]["#{fixtures_dir}templates/syntax.erb"].join("\n")).to match(/syntax error, unexpected tIDENTIFIER/)
51
51
  end
52
52
  expect(PuppetCheck.files[:warnings]).to eql({})
53
53
  expect(PuppetCheck.files[:clean]).to eql([])
@@ -56,7 +56,7 @@ describe RubyParser do
56
56
  RubyParser.template(["#{fixtures_dir}templates/style.erb"])
57
57
  expect(PuppetCheck.files[:errors]).to eql({})
58
58
  expect(PuppetCheck.files[:warnings].keys).to eql(["#{fixtures_dir}templates/style.erb"])
59
- expect(PuppetCheck.files[:warnings]["#{fixtures_dir}templates/style.erb"].join("\n")).to match(%r{already initialized constant.*\n.*previous definition of})
59
+ expect(PuppetCheck.files[:warnings]["#{fixtures_dir}templates/style.erb"].join("\n")).to match(/already initialized constant.*\n.*previous definition of/)
60
60
  expect(PuppetCheck.files[:clean]).to eql([])
61
61
  end
62
62
  it 'puts a ruby template file with ignored errors in the clean files array' do
@@ -77,7 +77,7 @@ describe RubyParser do
77
77
  it 'puts a bad syntax librarian Puppet file in the error files hash' do
78
78
  RubyParser.librarian(["#{fixtures_dir}librarian_syntax/Puppetfile"], false, [])
79
79
  expect(PuppetCheck.files[:errors].keys).to eql(["#{fixtures_dir}librarian_syntax/Puppetfile"])
80
- expect(PuppetCheck.files[:errors]["#{fixtures_dir}librarian_syntax/Puppetfile"].join("\n")).to match(%r{^.*syntax error})
80
+ expect(PuppetCheck.files[:errors]["#{fixtures_dir}librarian_syntax/Puppetfile"].join("\n")).to match(/^.*syntax error/)
81
81
  expect(PuppetCheck.files[:warnings]).to eql({})
82
82
  expect(PuppetCheck.files[:clean]).to eql([])
83
83
  end
@@ -85,7 +85,7 @@ describe RubyParser do
85
85
  RubyParser.librarian(["#{fixtures_dir}librarian_style/Puppetfile"], true, [])
86
86
  expect(PuppetCheck.files[:errors]).to eql({})
87
87
  expect(PuppetCheck.files[:warnings].keys).to eql(["#{fixtures_dir}librarian_style/Puppetfile"])
88
- expect(PuppetCheck.files[:warnings]["#{fixtures_dir}librarian_style/Puppetfile"].join("\n")).to match(%r{Align the arguments.*\n.*Use the new})
88
+ expect(PuppetCheck.files[:warnings]["#{fixtures_dir}librarian_style/Puppetfile"].join("\n")).to match(/Align the arguments.*\n.*Use the new/)
89
89
  expect(PuppetCheck.files[:clean]).to eql([])
90
90
  end
91
91
  it 'puts a bad style librarian Puppet file in the clean files array when rubocop_args ignores its warnings' do
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.3.0
4
+ version: 2.3.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: 2024-05-12 00:00:00.000000000 Z
11
+ date: 2025-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puppet
@@ -86,20 +86,6 @@ dependencies:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
88
  version: '1.0'
89
- - !ruby/object:Gem::Dependency
90
- name: octocatalog-diff
91
- requirement: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - "~>"
94
- - !ruby/object:Gem::Version
95
- version: '1.0'
96
- type: :development
97
- prerelease: false
98
- version_requirements: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - "~>"
101
- - !ruby/object:Gem::Version
102
- version: '1.0'
103
89
  - !ruby/object:Gem::Dependency
104
90
  name: rake
105
91
  requirement: !ruby/object:Gem::Requirement
@@ -151,6 +137,7 @@ files:
151
137
  - lib/puppet-check/tasks.rb
152
138
  - lib/puppet-check/utils.rb
153
139
  - lib/puppet_check.rb
140
+ - puppet-check.gemspec
154
141
  - spec/fixtures/foobarbaz
155
142
  - spec/fixtures/hieradata/good.eyaml
156
143
  - spec/fixtures/hieradata/good.json
@@ -227,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
227
214
  - !ruby/object:Gem::Version
228
215
  version: '0'
229
216
  requirements: []
230
- rubygems_version: 3.3.5
217
+ rubygems_version: 3.4.20
231
218
  signing_key:
232
219
  specification_version: 4
233
220
  summary: A streamlined comprehensive set of checks for your entire Puppet code and