puppet-check 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +16 -13
- data/lib/puppet-check/cli.rb +2 -2
- data/lib/puppet-check/data_parser.rb +2 -3
- data/lib/puppet-check/output_results.rb +4 -4
- data/lib/puppet-check/puppet_parser.rb +10 -9
- data/lib/puppet-check/ruby_parser.rb +11 -6
- data/lib/puppet-check/tasks.rb +1 -1
- data/lib/{puppet-check.rb → puppet_check.rb} +1 -1
- data/spec/octocatalog-diff/{octocatalog-diff.cfg.rb → octocatalog_diff.cfg.rb} +6 -6
- data/spec/puppet-check/data_parser_spec.rb +41 -43
- data/spec/puppet-check/output_results_spec.rb +9 -9
- data/spec/puppet-check/puppet_parser_spec.rb +9 -12
- data/spec/puppet-check/regression_check_spec.rb +7 -9
- data/spec/puppet-check/rspec_puppet_support_spec.rb +9 -5
- data/spec/puppet-check/ruby_parser_spec.rb +12 -12
- data/spec/puppet-check/tasks_spec.rb +3 -3
- data/spec/{puppet-check_spec.rb → puppet_check_spec.rb} +1 -1
- data/spec/spec_helper.rb +7 -2
- data/spec/system/system_spec.rb +2 -2
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f43468b01f25dba9ea6e997c982c632fb884d6cb8ec8faa31a670ac523a8ee8
|
4
|
+
data.tar.gz: 5baeb571e293b32c6120448d45c036523b96ffc0a325ba02c6f47e70323c1f3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0ff327a57b78229800e56dae894b863ff0217d9ae8f368d7ff9db048160b29c0b1365144fb4db596c3951fafa4b5569d0c5ad741e7d0b3fa1a3491ed64fed50
|
7
|
+
data.tar.gz: 7b15f95dc0876eb1d8a6b9fa5295c45858fc7eef02ba6a2924c68ad29dadf6fa179c62ed32eae167923f39172eb9b1464910f48e7072dfaf8e9d98328dd6739e
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
### 2.1.0 (Roadmap)
|
2
|
+
- Minimum supported version of Puppet bumped to 5.0.
|
3
|
+
- Minimum Ruby version bumped to 2.4.
|
4
|
+
- Official support for Puppet 7, Rubocop 1, and Reek 6.
|
5
|
+
- Fix Puppet message string transform conditionals.
|
6
|
+
|
1
7
|
### 2.0.1
|
2
8
|
- Check for existence of executables for dependency module retrieval.
|
3
9
|
- Beta support for Puppet 7, Rubocop 1, and Reek 6.
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Puppet Check
|
2
|
-
[![Build Status](https://travis-ci.
|
2
|
+
[![Build Status](https://travis-ci.com/mschuchard/puppet-check.svg?branch=master)](https://travis-ci.com/mschuchard/puppet-check)
|
3
3
|
[![CircleCI](https://circleci.com/gh/mschuchard/puppet-check.svg?style=svg)](https://circleci.com/gh/mschuchard/puppet-check)
|
4
4
|
|
5
5
|
- [Description](#description)
|
@@ -125,8 +125,11 @@ The following files have unrecognized formats and therefore were not processed:
|
|
125
125
|
### What About Puppet Development Kit?
|
126
126
|
The fairly recent release of the Puppet Development Kit (PDK) will hopefully eventually bring about the capability to test and validate your Puppet code and data in a streamlined, efficient, comprehensive, and accurate fashion comparable to Puppet Check. Unfortunately, the PDK has not yet achieved feature or efficiency parity with Puppet Check. The goal is for the PDK to one day replace Puppet Check and for Puppet Check to enter maintenance mode, but for now Puppet Check is still needed to lead Puppet testing.
|
127
127
|
|
128
|
+
### What About PDK now?
|
129
|
+
As of version 2.4.0 of the PDK, the PDK has essentially more or less achieved feature parity with Puppet Check. Although the PDK is not as efficient (including especially that Puppet Check executes significantly faster), it is still supported by Puppetlabs. Therefore, if you need an efficient and comprehensive Puppet validation solution, then you can still utilize Puppet Check, but the PDK is a recommended alternative for the future.
|
130
|
+
|
128
131
|
## Usage
|
129
|
-
Please see the [Gemspec](puppet-check.gemspec) for dependency information. All other dependencies should be fine with various versions. Puppet Check can be used with a CLI, Rake tasks, or API, from your system, rbenv, rvm, Docker, or Vagrant. Please note all interfaces (API by default, but can be modified) will ignore any directories named `fixtures
|
132
|
+
Please see the [Gemspec](puppet-check.gemspec) for dependency information. All other dependencies should be fine with various versions. Puppet Check can be used with a CLI, Rake tasks, or API, from your system, rbenv, rvm, Docker, or Vagrant. Please note all interfaces (API by default, but can be modified) will ignore any directories named `fixtures`, or specified paths with that directory during file checks and spec tests.
|
130
133
|
|
131
134
|
### CLI
|
132
135
|
```
|
@@ -278,15 +281,15 @@ task.pattern = Dir.glob('**/{classes,defines,facter,functions,hosts,puppet,unit,
|
|
278
281
|
|
279
282
|
### Docker
|
280
283
|
|
281
|
-
You can also use Puppet Check inside of Docker for quick, portable, and disposable testing. Below is an example Dockerfile for this purpose:
|
284
|
+
You can also use Puppet Check inside of Docker for quick, portable, and disposable testing. Below is an example `Dockerfile` for this purpose:
|
282
285
|
|
283
286
|
```dockerfile
|
284
|
-
# a reliable and small container
|
285
|
-
FROM ubuntu:
|
287
|
+
# a reliable and small container; today should maybe use ruby:slim instead
|
288
|
+
FROM ubuntu:20.04
|
286
289
|
# you need ruby and any other extra dependencies that come from packages; in this example we install git to use it for downloading external module dependencies
|
287
290
|
RUN apt-get update && apt-get install ruby git -y
|
288
|
-
# you need puppet-check and any other extra dependencies that come from gems; in this example we install
|
289
|
-
RUN gem install --no-document puppet-check
|
291
|
+
# you need puppet-check and any other extra dependencies that come from gems; in this example we install rspec-puppet and rake for extra testing
|
292
|
+
RUN gem install --no-document puppet-check rspec-puppet rake
|
290
293
|
# this is needed for the ruby json parser to not flip out on fresh os installs for some reason (change encoding value as necessary)
|
291
294
|
ENV LANG en_US.UTF-8
|
292
295
|
# create the directory for your module, directory environment, etc. and change directory into it
|
@@ -297,26 +300,26 @@ COPY / .
|
|
297
300
|
ENTRYPOINT ["rake", "puppetcheck"]
|
298
301
|
```
|
299
302
|
|
300
|
-
You can also build your own general container for testing various Puppet situations by removing the last three lines. You can then test each module, directory environment, etc. on top of that container by merely adding and modifying the final three lines to a Dockerfile that uses the container you built from the first four lines. This is recommended usage due to being very efficient and stable.
|
303
|
+
You can also build your own general container image for testing various Puppet situations by removing the last three lines. You can then test each module, directory environment, etc. on top of that container by merely adding and modifying the final three lines to a `Dockerfile` that uses the container you built from the first four lines. This is recommended usage due to being very efficient and stable.
|
301
304
|
|
302
305
|
As an alternative to copying Puppet code and data into the image for testing, it is also recommended to bind volume mount the container to the directory with your Puppet code and data.
|
303
306
|
|
304
307
|
### Vagrant
|
305
308
|
|
306
|
-
As an alternative to Docker, you can also use Vagrant for quick and disposable testing, but it is not as portable as Docker for these testing purposes. Below is an example Vagrantfile for this purpose.
|
309
|
+
As an alternative to Docker, you can also use Vagrant for quick and disposable testing, but it is not as portable as Docker for these testing purposes. Below is an example `Vagrantfile` for this purpose.
|
307
310
|
|
308
311
|
```ruby
|
309
312
|
Vagrant.configure(2) do |config|
|
310
313
|
# a reliable and small box at the moment
|
311
|
-
config.vm.box = 'fedora/
|
314
|
+
config.vm.box = 'fedora/35-cloud-base'
|
312
315
|
|
313
316
|
config.vm.provision 'shell', inline: <<-SHELL
|
314
317
|
# cd to '/vagrant'
|
315
318
|
cd /vagrant
|
316
319
|
# you need ruby and any other extra dependencies that come from packages; in this example we install git to use it for downloading external module dependencies
|
317
320
|
sudo dnf install ruby rubygems git -y
|
318
|
-
# you need puppet-check and any other extra dependencies that come from gems; in this example we install
|
319
|
-
sudo gem install --no-document puppet-check
|
321
|
+
# you need puppet-check and any other extra dependencies that come from gems; in this example we install rspec-puppet and rake for extra testing
|
322
|
+
sudo gem install --no-document puppet-check rspec-puppet rake
|
320
323
|
# this is needed for the ruby json parser to not flip out on fresh os installs for some reason (change encoding value as necessary)
|
321
324
|
export LANG='en_US.UTF-8'
|
322
325
|
# execute your tests; in this example we are executing the full suite of tests
|
@@ -330,7 +333,7 @@ To overcome the lack of convenient portability, you could try spinning up the Va
|
|
330
333
|
### Exit Codes
|
331
334
|
- 0: PuppetCheck exited with no internal exceptions or errors in your code and data.
|
332
335
|
- 1: PuppetCheck exited with an internal exception (takes preference over other non-zero exit codes) or failed spec test(s).
|
333
|
-
- 2: PuppetCheck exited with one or more errors in your code and data. Alternatively, PuppetCheck exited with one or more warnings in your code and data and you specified to fail on warnings.
|
336
|
+
- 2: PuppetCheck exited with one or more errors in your code and data. Alternatively, PuppetCheck exited with one or more warnings in your code and data, and you specified to fail on warnings.
|
334
337
|
|
335
338
|
### Optional Dependencies
|
336
339
|
- **rake** (gem): install this if you want to use Puppet Check with `rake` tasks in addition to the CLI.
|
data/lib/puppet-check/cli.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'optparse'
|
2
|
-
require_relative '../
|
2
|
+
require_relative '../puppet_check'
|
3
3
|
|
4
4
|
# the command line interface for PuppetCheck
|
5
5
|
class PuppetCheck::CLI
|
@@ -27,7 +27,7 @@ class PuppetCheck::CLI
|
|
27
27
|
|
28
28
|
# base options
|
29
29
|
opts.on('--version', 'Display the current version.') do
|
30
|
-
puts 'puppet-check 2.
|
30
|
+
puts 'puppet-check 2.1.0'
|
31
31
|
exit 0
|
32
32
|
end
|
33
33
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative '../
|
1
|
+
require_relative '../puppet_check'
|
2
2
|
|
3
3
|
# executes diagnostics on data files
|
4
4
|
class DataParser
|
@@ -205,8 +205,7 @@ class DataParser
|
|
205
205
|
warnings = []
|
206
206
|
|
207
207
|
# disregard nil/undef value data check if default values (common)
|
208
|
-
unless
|
209
|
-
# unless /^common/.match?(file) TODO: use when ruby >= 2.4
|
208
|
+
unless /^common/.match?(file)
|
210
209
|
data.each do |key, value|
|
211
210
|
# check for nil values in the data (nil keys are fine)
|
212
211
|
if (value.is_a?(Hash) && value.values.any?(&:nil?)) || value.nil?
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative '../
|
1
|
+
require_relative '../puppet_check'
|
2
2
|
|
3
3
|
# class to handle outputting diagnostic results in desired format
|
4
4
|
class OutputResults
|
@@ -22,7 +22,7 @@ class OutputResults
|
|
22
22
|
end
|
23
23
|
|
24
24
|
# output the results as yaml or json
|
25
|
-
def self.markup(
|
25
|
+
def self.markup(format)
|
26
26
|
# generate output hash
|
27
27
|
hash = {}
|
28
28
|
hash['errors'] = PuppetCheck.settings[:error_files] unless PuppetCheck.settings[:error_files].empty?
|
@@ -31,7 +31,7 @@ class OutputResults
|
|
31
31
|
hash['ignored'] = PuppetCheck.settings[:ignored_files] unless PuppetCheck.settings[:ignored_files].empty?
|
32
32
|
|
33
33
|
# convert hash to markup language
|
34
|
-
case
|
34
|
+
case format
|
35
35
|
when 'yaml'
|
36
36
|
require 'yaml'
|
37
37
|
puts Psych.dump(hash, indentation: 2)
|
@@ -39,7 +39,7 @@ class OutputResults
|
|
39
39
|
require 'json'
|
40
40
|
puts JSON.pretty_generate(hash)
|
41
41
|
else
|
42
|
-
raise "puppet-check: Unsupported output format '#{
|
42
|
+
raise "puppet-check: Unsupported output format '#{format}' was specified."
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'puppet'
|
2
|
-
require_relative '../
|
2
|
+
require_relative '../puppet_check'
|
3
3
|
|
4
4
|
# executes diagnostics on puppet files
|
5
5
|
class PuppetParser
|
@@ -28,14 +28,15 @@ class PuppetParser
|
|
28
28
|
# this is the actual error that we need to rescue Puppet::Face from
|
29
29
|
rescue SystemExit
|
30
30
|
# puppet 5.4-6.4 has a new validator output format and eof errors have fake dir env info
|
31
|
-
if Gem::Version.new(Puppet::PUPPETVERSION) >= Gem::Version.new('5.4') && Gem::Version.new(Puppet::PUPPETVERSION) < Gem::Version.new('6.5')
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
31
|
+
message = if Gem::Version.new(Puppet::PUPPETVERSION) >= Gem::Version.new('5.4') && Gem::Version.new(Puppet::PUPPETVERSION) < Gem::Version.new('6.5')
|
32
|
+
errors.map(&:to_s).join("\n").gsub(/file: #{File.absolute_path(file)}(, |\))/, '').gsub(/Could not parse.*: /, '')
|
33
|
+
# puppet 5.0-5.2 can only do one error per line and outputs fake dir env info
|
34
|
+
elsif Gem::Version.new(Puppet::PUPPETVERSION) >= Gem::Version.new('5.0') && Gem::Version.new(Puppet::PUPPETVERSION) < Gem::Version.new('5.3')
|
35
|
+
errors.map(&:to_s).join("\n").gsub("#{File.absolute_path(file)}:", '').gsub(/Could not parse.*: /, '')
|
36
|
+
# puppet < 5 and 5.3 parser output style
|
37
|
+
else
|
38
|
+
errors.map(&:to_s).join("\n").gsub("#{File.absolute_path(file)}:", '')
|
39
|
+
end
|
39
40
|
end
|
40
41
|
# output message
|
41
42
|
next PuppetCheck.settings[:error_files].push("#{file}:\n#{message}") unless message.empty?
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative '../
|
1
|
+
require_relative '../puppet_check'
|
2
2
|
require_relative 'utils'
|
3
3
|
|
4
4
|
# executes diagnostics on ruby files
|
@@ -43,8 +43,14 @@ class RubyParser
|
|
43
43
|
# check ruby template syntax
|
44
44
|
begin
|
45
45
|
# need to eventually have this associated with a different binding during each iteration
|
46
|
-
|
47
|
-
|
46
|
+
# older usage throws extra warning and mixes with valid warnings confusingly
|
47
|
+
warnings = if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6')
|
48
|
+
Utils.capture_stderr { ERB.new(File.read(file), trim_mode: '-').result }
|
49
|
+
# ERB.new(File.read(file), trim_mode: '-').result(RubyParser.new.bind)
|
50
|
+
# and for extra fun it is incompatible with non-new ruby
|
51
|
+
else
|
52
|
+
Utils.capture_stderr { ERB.new(File.read(file), nil, '-').result }
|
53
|
+
end
|
48
54
|
rescue NameError, TypeError
|
49
55
|
# empty out warnings since it would contain an error if this pass triggers
|
50
56
|
warnings = ''
|
@@ -62,10 +68,9 @@ class RubyParser
|
|
62
68
|
# efficient var assignment prior to iterator
|
63
69
|
if style
|
64
70
|
require 'rubocop'
|
65
|
-
|
66
|
-
filename_cop = RuboCop::Version::STRING.to_f >= 0.5 ? 'Naming/FileName' : 'Style/FileName'
|
71
|
+
|
67
72
|
# 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]}
|
73
|
+
rc_args.include?('--except') ? rc_args[rc_args.index('--except') + 1] = "#{rc_args[rc_args.index('--except') + 1]},Naming/FileName" : rc_args.concat(['--except', 'Naming/FileName'])
|
69
74
|
end
|
70
75
|
|
71
76
|
files.each do |file|
|
data/lib/puppet-check/tasks.rb
CHANGED
@@ -3,7 +3,7 @@ begin
|
|
3
3
|
rescue LoadError
|
4
4
|
raise 'Rake is not installed and you are attempting to execute Rake tasks with Puppet Check. Please install Rake before continuing.'
|
5
5
|
end
|
6
|
-
require_relative '../
|
6
|
+
require_relative '../puppet_check'
|
7
7
|
|
8
8
|
# the rake interface for PuppetCheck
|
9
9
|
class PuppetCheck::Tasks < ::Rake::TaskLib
|
@@ -28,7 +28,7 @@ class PuppetCheck
|
|
28
28
|
execute_parsers(files, settings)
|
29
29
|
|
30
30
|
# output the diagnostic results
|
31
|
-
settings[:output_format] == 'text' ? OutputResults.text : OutputResults.markup(settings)
|
31
|
+
settings[:output_format] == 'text' ? OutputResults.text : OutputResults.markup(settings[:output_format])
|
32
32
|
|
33
33
|
# progress to regression checks if no errors in file checks
|
34
34
|
if self.class.settings[:error_files].empty? && (!settings[:fail_on_warning] || self.class.settings[:warning_files].empty?)
|
@@ -4,13 +4,13 @@ module OctocatalogDiff
|
|
4
4
|
class Config
|
5
5
|
def self.config
|
6
6
|
settings = {}
|
7
|
-
octocatalog_diff_dir = File.dirname(__FILE__)
|
7
|
+
octocatalog_diff_dir = "#{File.dirname(__FILE__)}/"
|
8
8
|
|
9
|
-
settings[:hiera_config] = octocatalog_diff_dir
|
10
|
-
settings[:hiera_path] = octocatalog_diff_dir
|
11
|
-
settings[:fact_file] = octocatalog_diff_dir
|
12
|
-
settings[:puppet_binary] = if
|
13
|
-
octocatalog_diff_dir
|
9
|
+
settings[:hiera_config] = "#{octocatalog_diff_dir}hiera.yaml"
|
10
|
+
settings[:hiera_path] = "#{octocatalog_diff_dir}hieradata"
|
11
|
+
settings[:fact_file] = "#{octocatalog_diff_dir}facts.yaml"
|
12
|
+
settings[:puppet_binary] = if ENV['TRAVIS'] == 'true'
|
13
|
+
"#{octocatalog_diff_dir}../../bin/puppet"
|
14
14
|
else
|
15
15
|
'/usr/local/bin/puppet'
|
16
16
|
end
|
@@ -10,106 +10,104 @@ describe DataParser do
|
|
10
10
|
|
11
11
|
context '.yaml' do
|
12
12
|
it 'puts a bad syntax yaml file in the error files array' do
|
13
|
-
DataParser.yaml([fixtures_dir
|
13
|
+
DataParser.yaml(["#{fixtures_dir}hieradata/syntax.yaml"])
|
14
14
|
expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}hieradata/syntax.yaml:\nblock sequence entries are not allowed})
|
15
15
|
expect(PuppetCheck.settings[:warning_files]).to eql([])
|
16
16
|
expect(PuppetCheck.settings[:clean_files]).to eql([])
|
17
17
|
end
|
18
18
|
it 'puts a good yaml file with potential hiera issues in the warning files array' do
|
19
|
-
DataParser.yaml([fixtures_dir
|
19
|
+
DataParser.yaml(["#{fixtures_dir}hieradata/style.yaml"])
|
20
20
|
expect(PuppetCheck.settings[:error_files]).to eql([])
|
21
21
|
expect(PuppetCheck.settings[:warning_files][0]).to match(%r{^#{fixtures_dir}hieradata/style.yaml:\nValue\(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})
|
22
22
|
expect(PuppetCheck.settings[:clean_files]).to eql([])
|
23
23
|
end
|
24
24
|
it 'puts a good yaml file in the clean files array' do
|
25
|
-
DataParser.yaml([fixtures_dir
|
25
|
+
DataParser.yaml(["#{fixtures_dir}hieradata/good.yaml"])
|
26
26
|
expect(PuppetCheck.settings[:error_files]).to eql([])
|
27
27
|
expect(PuppetCheck.settings[:warning_files]).to eql([])
|
28
28
|
expect(PuppetCheck.settings[:clean_files]).to eql(["#{fixtures_dir}hieradata/good.yaml"])
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
32
|
+
context '.eyaml' do
|
33
|
+
before(:each) do
|
34
|
+
PuppetCheck.settings[:ignored_files] = []
|
35
|
+
end
|
37
36
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
end
|
37
|
+
it 'returns a warning if a public key was not specified' do
|
38
|
+
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
|
39
|
+
end
|
40
|
+
it 'returns a warning if a private key was not specified' do
|
41
|
+
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
|
42
|
+
end
|
43
|
+
it 'returns a warning if the public key or private key are not existing files' do
|
44
|
+
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
|
+
end
|
46
|
+
it 'puts a bad syntax eyaml file in the error files array' do
|
47
|
+
# DataParser.eyaml(["#{fixtures_dir}hieradata/syntax.eyaml'], fixtures_dir + 'keys/public_key.pkcs7.pem', fixtures_dir + 'keys/private_key.pkcs7.pem")
|
48
|
+
# expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}hieradata/syntax.eyaml:\nblock sequence entries are not allowed})
|
49
|
+
expect(PuppetCheck.settings[:warning_files]).to eql([])
|
50
|
+
expect(PuppetCheck.settings[:clean_files]).to eql([])
|
51
|
+
end
|
52
|
+
it 'puts a good eyaml file with potential hiera issues in the warning files array' do
|
53
|
+
# DataParser.eyaml(["#{fixtures_dir}hieradata/style.eyaml'], fixtures_dir + 'keys/public_key.pkcs7.pem', fixtures_dir + 'keys/private_key.pkcs7.pem")
|
54
|
+
expect(PuppetCheck.settings[:error_files]).to eql([])
|
55
|
+
# 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})
|
56
|
+
expect(PuppetCheck.settings[:clean_files]).to eql([])
|
57
|
+
end
|
58
|
+
it 'puts a good eyaml file in the clean files array' do
|
59
|
+
# DataParser.eyaml(["#{fixtures_dir}hieradata/good.eyaml'], fixtures_dir + 'keys/public_key.pkcs7.pem', fixtures_dir + 'keys/private_key.pkcs7.pem")
|
60
|
+
expect(PuppetCheck.settings[:error_files]).to eql([])
|
61
|
+
expect(PuppetCheck.settings[:warning_files]).to eql([])
|
62
|
+
# expect(PuppetCheck.settings[:clean_files]).to eql(["#{fixtures_dir}hieradata/good.eyaml"])
|
65
63
|
end
|
66
64
|
end
|
67
65
|
|
68
66
|
context '.json' do
|
69
67
|
it 'puts a bad syntax json file in the error files array' do
|
70
|
-
DataParser.json([fixtures_dir
|
68
|
+
DataParser.json(["#{fixtures_dir}hieradata/syntax.json"])
|
71
69
|
expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}hieradata/syntax.json:\n.*unexpected token})
|
72
70
|
expect(PuppetCheck.settings[:warning_files]).to eql([])
|
73
71
|
expect(PuppetCheck.settings[:clean_files]).to eql([])
|
74
72
|
end
|
75
73
|
it 'puts a bad metadata json file in the error files array' do
|
76
|
-
DataParser.json([fixtures_dir
|
74
|
+
DataParser.json(["#{fixtures_dir}metadata_syntax/metadata.json"])
|
77
75
|
expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}metadata_syntax/metadata.json:\nRequired field.*\nField 'requirements'.*\nDuplicate dependencies.*\nDeprecated field.*\nSummary exceeds})
|
78
76
|
expect(PuppetCheck.settings[:warning_files]).to eql([])
|
79
77
|
expect(PuppetCheck.settings[:clean_files]).to eql([])
|
80
78
|
end
|
81
79
|
it 'puts a bad style metadata json file in the warning files array' do
|
82
|
-
DataParser.json([fixtures_dir
|
80
|
+
DataParser.json(["#{fixtures_dir}metadata_style/metadata.json"])
|
83
81
|
expect(PuppetCheck.settings[:error_files]).to eql([])
|
84
82
|
expect(PuppetCheck.settings[:warning_files][0]).to match(%r{^#{fixtures_dir}metadata_style/metadata.json:\n'pe' is missing an upper bound.\n.*operatingsystem_support.*\nLicense identifier})
|
85
83
|
expect(PuppetCheck.settings[:clean_files]).to eql([])
|
86
84
|
end
|
87
85
|
it 'puts another bad style metadata json file in the warning files array' do
|
88
|
-
DataParser.json([fixtures_dir
|
86
|
+
DataParser.json(["#{fixtures_dir}metadata_style_two/metadata.json"])
|
89
87
|
expect(PuppetCheck.settings[:error_files]).to eql([])
|
90
88
|
expect(PuppetCheck.settings[:warning_files][0]).to match(%r{^#{fixtures_dir}metadata_style_two/metadata.json:\n'puppetlabs/one' has non-semantic versioning.*\n'puppetlabs/two' is missing an upper bound\.\n.*operatingsystem.*\n.*operatingsystemrelease})
|
91
89
|
expect(PuppetCheck.settings[:clean_files]).to eql([])
|
92
90
|
end
|
93
91
|
it 'puts a bad task metadata json file in the warning files array' do
|
94
|
-
DataParser.json([fixtures_dir
|
92
|
+
DataParser.json(["#{fixtures_dir}task_metadata/task_bad.json"])
|
95
93
|
expect(PuppetCheck.settings[:error_files]).to eql([])
|
96
94
|
expect(PuppetCheck.settings[:warning_files][0]).to match(%r{^#{fixtures_dir}task_metadata/task_bad.json:\ndescription 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})
|
97
95
|
expect(PuppetCheck.settings[:clean_files]).to eql([])
|
98
96
|
end
|
99
97
|
it 'puts a good json file in the clean files array' do
|
100
|
-
DataParser.json([fixtures_dir
|
98
|
+
DataParser.json(["#{fixtures_dir}hieradata/good.json"])
|
101
99
|
expect(PuppetCheck.settings[:error_files]).to eql([])
|
102
100
|
expect(PuppetCheck.settings[:warning_files]).to eql([])
|
103
101
|
expect(PuppetCheck.settings[:clean_files]).to eql(["#{fixtures_dir}hieradata/good.json"])
|
104
102
|
end
|
105
103
|
it 'puts a good metadata json file in the clean files array' do
|
106
|
-
DataParser.json([fixtures_dir
|
104
|
+
DataParser.json(["#{fixtures_dir}metadata_good/metadata.json"])
|
107
105
|
expect(PuppetCheck.settings[:error_files]).to eql([])
|
108
106
|
expect(PuppetCheck.settings[:warning_files]).to eql([])
|
109
107
|
expect(PuppetCheck.settings[:clean_files]).to eql(["#{fixtures_dir}metadata_good/metadata.json"])
|
110
108
|
end
|
111
109
|
it 'puts a good task metadata json file in the clean files array' do
|
112
|
-
DataParser.json([fixtures_dir
|
110
|
+
DataParser.json(["#{fixtures_dir}task_metadata/task_good.json"])
|
113
111
|
expect(PuppetCheck.settings[:error_files]).to eql([])
|
114
112
|
expect(PuppetCheck.settings[:warning_files]).to eql([])
|
115
113
|
expect(PuppetCheck.settings[:clean_files]).to eql(["#{fixtures_dir}task_metadata/task_good.json"])
|
@@ -38,38 +38,38 @@ describe OutputResults do
|
|
38
38
|
|
39
39
|
it 'outputs files with errors as yaml' do
|
40
40
|
PuppetCheck.settings[:error_files] = ['foo: i had an error']
|
41
|
-
expect { OutputResults.markup(
|
41
|
+
expect { OutputResults.markup('yaml') }.to output("---\nerrors:\n- 'foo: i had an error'\n").to_stdout
|
42
42
|
end
|
43
43
|
it 'outputs files with warnings as yaml' do
|
44
44
|
PuppetCheck.settings[:warning_files] = ['foo: i had a warning']
|
45
|
-
expect { OutputResults.markup(
|
45
|
+
expect { OutputResults.markup('yaml') }.to output("---\nwarnings:\n- 'foo: i had a warning'\n").to_stdout
|
46
46
|
end
|
47
47
|
it 'outputs files with no errors or warnings as yaml' do
|
48
48
|
PuppetCheck.settings[:clean_files] = ['foo: i was totally good to go']
|
49
|
-
expect { OutputResults.markup(
|
49
|
+
expect { OutputResults.markup('yaml') }.to output("---\nclean:\n- 'foo: i was totally good to go'\n").to_stdout
|
50
50
|
end
|
51
51
|
it 'outputs files that were not processed as yaml' do
|
52
52
|
PuppetCheck.settings[:ignored_files] = ['foo: who knows what i am']
|
53
|
-
expect { OutputResults.markup(
|
53
|
+
expect { OutputResults.markup('yaml') }.to output("---\nignored:\n- 'foo: who knows what i am'\n").to_stdout
|
54
54
|
end
|
55
55
|
it 'outputs files with errors as json' do
|
56
56
|
PuppetCheck.settings[:error_files] = ['foo: i had an error']
|
57
|
-
expect { OutputResults.markup(
|
57
|
+
expect { OutputResults.markup('json') }.to output("{\n \"errors\": [\n \"foo: i had an error\"\n ]\n}\n").to_stdout
|
58
58
|
end
|
59
59
|
it 'outputs files with warnings as json' do
|
60
60
|
PuppetCheck.settings[:warning_files] = ['foo: i had a warning']
|
61
|
-
expect { OutputResults.markup(
|
61
|
+
expect { OutputResults.markup('json') }.to output("{\n \"warnings\": [\n \"foo: i had a warning\"\n ]\n}\n").to_stdout
|
62
62
|
end
|
63
63
|
it 'outputs files with no errors or warnings as json' do
|
64
64
|
PuppetCheck.settings[:clean_files] = ['foo: i was totally good to go']
|
65
|
-
expect { OutputResults.markup(
|
65
|
+
expect { OutputResults.markup('json') }.to output("{\n \"clean\": [\n \"foo: i was totally good to go\"\n ]\n}\n").to_stdout
|
66
66
|
end
|
67
67
|
it 'outputs files that were not processed as json' do
|
68
68
|
PuppetCheck.settings[:ignored_files] = ['foo: who knows what i am']
|
69
|
-
expect { OutputResults.markup(
|
69
|
+
expect { OutputResults.markup('json') }.to output("{\n \"ignored\": [\n \"foo: who knows what i am\"\n ]\n}\n").to_stdout
|
70
70
|
end
|
71
71
|
it 'raises an error for an unsupported output format' do
|
72
|
-
expect { OutputResults.markup(
|
72
|
+
expect { OutputResults.markup('awesomesauce') }.to raise_error(RuntimeError, 'puppet-check: Unsupported output format \'awesomesauce\' was specified.')
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
@@ -10,12 +10,9 @@ describe PuppetParser do
|
|
10
10
|
|
11
11
|
context '.manifest' do
|
12
12
|
it 'puts a bad syntax Puppet manifest in the error files array' do
|
13
|
-
PuppetParser.manifest([fixtures_dir
|
13
|
+
PuppetParser.manifest(["#{fixtures_dir}manifests/syntax.pp"], false, [])
|
14
14
|
if Gem::Version.new(Puppet::PUPPETVERSION) >= Gem::Version.new('6.5.0')
|
15
15
|
expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}manifests/syntax.pp:\nLanguage validation logged 2 errors})
|
16
|
-
# dealing with annoying warning in puppet 5 and 6
|
17
|
-
elsif Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.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.*\nIllegal variable name})
|
19
16
|
else
|
20
17
|
expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}manifests/syntax.pp:\nThis Variable has no effect.*\nIllegal variable name})
|
21
18
|
end
|
@@ -25,50 +22,50 @@ describe PuppetParser do
|
|
25
22
|
# puppet 5 api has output issues for this fixture
|
26
23
|
unless Gem::Version.new(Puppet::PUPPETVERSION) < Gem::Version.new('6.0.0')
|
27
24
|
it 'puts a bad syntax at eof Puppet manifest in the error files array' do
|
28
|
-
PuppetParser.manifest([fixtures_dir
|
25
|
+
PuppetParser.manifest(["#{fixtures_dir}manifests/eof_syntax.pp"], false, [])
|
29
26
|
expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}manifests/eof_syntax.pp:\nSyntax error at end of input})
|
30
27
|
expect(PuppetCheck.settings[:warning_files]).to eql([])
|
31
28
|
expect(PuppetCheck.settings[:clean_files]).to eql([])
|
32
29
|
end
|
33
30
|
end
|
34
31
|
it 'puts a bad parser and lint style Puppet manifest in the warning files array' do
|
35
|
-
PuppetParser.manifest([fixtures_dir
|
32
|
+
PuppetParser.manifest(["#{fixtures_dir}manifests/style_parser.pp"], true, [])
|
36
33
|
expect(PuppetCheck.settings[:error_files]).to eql([])
|
37
34
|
expect(PuppetCheck.settings[:warning_files][0]).to match(%r{^#{fixtures_dir}manifests/style_parser.pp:\nUnrecognized escape sequence.*\nUnrecognized escape sequence.*\n.*double quoted string containing})
|
38
35
|
expect(PuppetCheck.settings[:clean_files]).to eql([])
|
39
36
|
end
|
40
37
|
it 'puts a bad lint style Puppet manifest in the warning files array' do
|
41
|
-
PuppetParser.manifest([fixtures_dir
|
38
|
+
PuppetParser.manifest(["#{fixtures_dir}manifests/style_lint.pp"], true, [])
|
42
39
|
expect(PuppetCheck.settings[:error_files]).to eql([])
|
43
40
|
expect(PuppetCheck.settings[:warning_files][0]).to match(%r{^#{fixtures_dir}manifests/style_lint.pp:\n.*(?:indentation of|double quoted string containing).*\n.*(?:indentation of|double quoted string containing)})
|
44
41
|
expect(PuppetCheck.settings[:clean_files]).to eql([])
|
45
42
|
end
|
46
43
|
it 'puts a bad style Puppet manifest in the clean files array when puppetlint_args ignores its warnings' do
|
47
|
-
PuppetParser.manifest([fixtures_dir
|
44
|
+
PuppetParser.manifest(["#{fixtures_dir}manifests/style_lint.pp"], true, ['--no-double_quoted_strings-check', '--no-arrow_alignment-check'])
|
48
45
|
expect(PuppetCheck.settings[:error_files]).to eql([])
|
49
46
|
expect(PuppetCheck.settings[:warning_files]).to eql([])
|
50
47
|
expect(PuppetCheck.settings[:clean_files]).to eql(["#{fixtures_dir}manifests/style_lint.pp"])
|
51
48
|
end
|
52
49
|
it 'puts a good Puppet manifest in the clean files array' do
|
53
|
-
PuppetParser.manifest([fixtures_dir
|
50
|
+
PuppetParser.manifest(["#{fixtures_dir}manifests/good.pp"], true, [])
|
54
51
|
expect(PuppetCheck.settings[:error_files]).to eql([])
|
55
52
|
expect(PuppetCheck.settings[:warning_files]).to eql([])
|
56
53
|
expect(PuppetCheck.settings[:clean_files]).to eql(["#{fixtures_dir}manifests/good.pp"])
|
57
54
|
end
|
58
55
|
it 'throws a well specified error for an invalid PuppetLint argument' do
|
59
|
-
expect { PuppetParser.manifest([fixtures_dir
|
56
|
+
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')
|
60
57
|
end
|
61
58
|
end
|
62
59
|
|
63
60
|
context '.template' do
|
64
61
|
it 'puts a bad syntax Puppet template in the error files array' do
|
65
|
-
PuppetParser.template([fixtures_dir
|
62
|
+
PuppetParser.template(["#{fixtures_dir}templates/syntax.epp"])
|
66
63
|
expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}templates/syntax.epp:\nThis Name has no effect})
|
67
64
|
expect(PuppetCheck.settings[:warning_files]).to eql([])
|
68
65
|
expect(PuppetCheck.settings[:clean_files]).to eql([])
|
69
66
|
end
|
70
67
|
it 'puts a good Puppet template in the clean files array' do
|
71
|
-
PuppetParser.template([fixtures_dir
|
68
|
+
PuppetParser.template(["#{fixtures_dir}templates/good.epp"])
|
72
69
|
expect(PuppetCheck.settings[:error_files]).to eql([])
|
73
70
|
expect(PuppetCheck.settings[:warning_files]).to eql([])
|
74
71
|
expect(PuppetCheck.settings[:clean_files]).to eql(["#{fixtures_dir}templates/good.epp"])
|
@@ -5,13 +5,11 @@ require_relative '../../lib/puppet-check/regression_check'
|
|
5
5
|
describe RegressionCheck do
|
6
6
|
context '.config' do
|
7
7
|
# json gem got messed up for the EOL Ruby versions
|
8
|
-
if
|
9
|
-
|
10
|
-
expect { RegressionCheck.config(fixtures_dir + 'metadata.json') }.to raise_error(OctocatalogDiff::Errors::ConfigurationFileContentError, 'Configuration must define OctocatalogDiff::Config!')
|
11
|
-
end
|
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!')
|
12
10
|
end
|
13
11
|
it 'loads in a good octocatalog-diff config file' do
|
14
|
-
expect { RegressionCheck.config(octocatalog_diff_dir
|
12
|
+
expect { RegressionCheck.config("#{octocatalog_diff_dir}octocatalog_diff.cfg.rb") }.not_to raise_exception
|
15
13
|
end
|
16
14
|
it 'loads in the settings from the file correctly' do
|
17
15
|
end
|
@@ -19,16 +17,16 @@ describe RegressionCheck do
|
|
19
17
|
|
20
18
|
context '.smoke' do
|
21
19
|
# octocatalog-diff is returning a blank error for these tests
|
22
|
-
unless
|
20
|
+
unless ENV['TRAVIS'] == 'true' || ENV['CIRCLECI'] == 'true'
|
23
21
|
it 'returns a pass for a successful catalog compilation' do
|
24
|
-
expect { RegressionCheck.smoke(['good.example.com'], "#{octocatalog_diff_dir}
|
22
|
+
expect { RegressionCheck.smoke(['good.example.com'], "#{octocatalog_diff_dir}octocatalog_diff.cfg.rb") }.not_to raise_exception
|
25
23
|
end
|
26
24
|
it 'returns a failure for a catalog with an error' do
|
27
|
-
expect { RegressionCheck.smoke(['does_not_exist.example.com'], "#{octocatalog_diff_dir}
|
25
|
+
expect { RegressionCheck.smoke(['does_not_exist.example.com'], "#{octocatalog_diff_dir}octocatalog_diff.cfg.rb") }.to raise_error(OctocatalogDiff::Errors::CatalogError)
|
28
26
|
end
|
29
27
|
end
|
30
28
|
it 'returns a failure for a good and bad catalog' do
|
31
|
-
# RegressionCheck.smoke(['good.example.com', 'syntax_error.example.com'], "#{fixtures_dir}
|
29
|
+
# RegressionCheck.smoke(['good.example.com', 'syntax_error.example.com'], "#{fixtures_dir}octocatalog_diff.cfg.rb")
|
32
30
|
end
|
33
31
|
end
|
34
32
|
|
@@ -1,12 +1,12 @@
|
|
1
|
-
require_relative '../spec_helper
|
1
|
+
require_relative '../spec_helper'
|
2
2
|
require_relative '../../lib/puppet-check/rspec_puppet_support'
|
3
3
|
require 'fileutils'
|
4
4
|
|
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
|
@@ -14,8 +14,12 @@ describe RSpecPuppetSupport do
|
|
14
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
|
+
# travis ci
|
18
|
+
if ENV['TRAVIS'] == 'true'
|
18
19
|
expect { rspec_puppet_setup }.to output("puppetlabs/gruntmaster has an unspecified, or specified but unsupported, download method.\n").to_stderr
|
20
|
+
# circle ci
|
21
|
+
elsif ENV['CIRCLECI'] == 'true'
|
22
|
+
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
|
19
23
|
else
|
20
24
|
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
|
21
25
|
end
|
@@ -28,7 +32,7 @@ describe RSpecPuppetSupport do
|
|
28
32
|
expect(File.file?('spec/spec_helper.rb')).to be true
|
29
33
|
|
30
34
|
# .dependency_setup
|
31
|
-
expect(File.directory?('spec/fixtures/modules/puppetlabs-lvm')).to be true
|
35
|
+
expect(File.directory?('spec/fixtures/modules/puppetlabs-lvm')).to be true unless ENV['CIRCLECI'] == 'true'
|
32
36
|
expect(File.directory?('spec/fixtures/modules/stdlib')).to be true
|
33
37
|
end
|
34
38
|
end
|
@@ -10,25 +10,25 @@ describe RubyParser do
|
|
10
10
|
|
11
11
|
context '.ruby' do
|
12
12
|
it 'puts a bad syntax ruby file in the error files array' do
|
13
|
-
RubyParser.ruby([fixtures_dir
|
13
|
+
RubyParser.ruby(["#{fixtures_dir}lib/syntax.rb"], false, [])
|
14
14
|
expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}lib/syntax.rb:\n.*syntax error})
|
15
15
|
expect(PuppetCheck.settings[:warning_files]).to eql([])
|
16
16
|
expect(PuppetCheck.settings[:clean_files]).to eql([])
|
17
17
|
end
|
18
18
|
it 'puts a bad style ruby file in the warning files array' do
|
19
|
-
RubyParser.ruby([fixtures_dir
|
19
|
+
RubyParser.ruby(["#{fixtures_dir}lib/style.rb"], true, [])
|
20
20
|
expect(PuppetCheck.settings[:error_files]).to eql([])
|
21
21
|
expect(PuppetCheck.settings[:warning_files][0]).to match(%r{^#{fixtures_dir}lib/style.rb:\n.*Useless assignment.*\n.*Use the new.*\n.*Do not introduce.*\n.*Prefer single.*\n.*Source code comment is empty.*\n.*is a writable attribute.*\n.*Issue has no descriptive comment})
|
22
22
|
expect(PuppetCheck.settings[:clean_files]).to eql([])
|
23
23
|
end
|
24
24
|
it 'puts a bad style ruby file in the clean files array when rubocop_args ignores its warnings' do
|
25
|
-
RubyParser.ruby([fixtures_dir
|
25
|
+
RubyParser.ruby(["#{fixtures_dir}lib/rubocop_style.rb"], true, ['--except', 'Lint/UselessAssignment,Style/HashSyntax,Style/GlobalVars,Style/StringLiterals'])
|
26
26
|
expect(PuppetCheck.settings[:error_files]).to eql([])
|
27
27
|
expect(PuppetCheck.settings[:warning_files]).to eql([])
|
28
28
|
expect(PuppetCheck.settings[:clean_files]).to eql(["#{fixtures_dir}lib/rubocop_style.rb"])
|
29
29
|
end
|
30
30
|
it 'puts a good ruby file in the clean files array' do
|
31
|
-
RubyParser.ruby([fixtures_dir
|
31
|
+
RubyParser.ruby(["#{fixtures_dir}lib/good.rb"], true, [])
|
32
32
|
expect(PuppetCheck.settings[:error_files]).to eql([])
|
33
33
|
expect(PuppetCheck.settings[:warning_files]).to eql([])
|
34
34
|
expect(PuppetCheck.settings[:clean_files]).to eql(["#{fixtures_dir}lib/good.rb"])
|
@@ -37,7 +37,7 @@ describe RubyParser do
|
|
37
37
|
|
38
38
|
context '.template' do
|
39
39
|
it 'puts a bad syntax ruby template file in the error files array' do
|
40
|
-
RubyParser.template([fixtures_dir
|
40
|
+
RubyParser.template(["#{fixtures_dir}templates/syntax.erb"])
|
41
41
|
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7')
|
42
42
|
expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}templates/syntax.erb:\n.*1: syntax error, unexpected.*\n.*ruby})
|
43
43
|
else
|
@@ -47,19 +47,19 @@ describe RubyParser do
|
|
47
47
|
expect(PuppetCheck.settings[:clean_files]).to eql([])
|
48
48
|
end
|
49
49
|
it 'puts a bad style ruby template file in the warning files array' do
|
50
|
-
RubyParser.template([fixtures_dir
|
50
|
+
RubyParser.template(["#{fixtures_dir}templates/style.erb"])
|
51
51
|
expect(PuppetCheck.settings[:error_files]).to eql([])
|
52
52
|
expect(PuppetCheck.settings[:warning_files][0]).to match(%r{^#{fixtures_dir}templates/style.erb:\n.*already initialized constant.*\n.*previous definition of})
|
53
53
|
expect(PuppetCheck.settings[:clean_files]).to eql([])
|
54
54
|
end
|
55
55
|
it 'puts a ruby template file with ignored errors in the clean files array' do
|
56
|
-
RubyParser.template([fixtures_dir
|
56
|
+
RubyParser.template(["#{fixtures_dir}templates/no_method_error.erb"])
|
57
57
|
expect(PuppetCheck.settings[:error_files]).to eql([])
|
58
58
|
expect(PuppetCheck.settings[:warning_files]).to eql([])
|
59
59
|
expect(PuppetCheck.settings[:clean_files]).to eql(["#{fixtures_dir}templates/no_method_error.erb"])
|
60
60
|
end
|
61
61
|
it 'puts a good ruby template file in the clean files array' do
|
62
|
-
RubyParser.template([fixtures_dir
|
62
|
+
RubyParser.template(["#{fixtures_dir}templates/good.erb"])
|
63
63
|
expect(PuppetCheck.settings[:error_files]).to eql([])
|
64
64
|
expect(PuppetCheck.settings[:warning_files]).to eql([])
|
65
65
|
expect(PuppetCheck.settings[:clean_files]).to eql(["#{fixtures_dir}templates/good.erb"])
|
@@ -68,25 +68,25 @@ describe RubyParser do
|
|
68
68
|
|
69
69
|
context '.librarian' do
|
70
70
|
it 'puts a bad syntax librarian Puppet file in the error files array' do
|
71
|
-
RubyParser.librarian([fixtures_dir
|
71
|
+
RubyParser.librarian(["#{fixtures_dir}librarian_syntax/Puppetfile"], false, [])
|
72
72
|
expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}librarian_syntax/Puppetfile:\n.*syntax error})
|
73
73
|
expect(PuppetCheck.settings[:warning_files]).to eql([])
|
74
74
|
expect(PuppetCheck.settings[:clean_files]).to eql([])
|
75
75
|
end
|
76
76
|
it 'puts a bad style librarian Puppet file in the warning files array' do
|
77
|
-
RubyParser.librarian([fixtures_dir
|
77
|
+
RubyParser.librarian(["#{fixtures_dir}librarian_style/Puppetfile"], true, [])
|
78
78
|
expect(PuppetCheck.settings[:error_files]).to eql([])
|
79
79
|
expect(PuppetCheck.settings[:warning_files][0]).to match(%r{^#{fixtures_dir}librarian_style/Puppetfile:\n.*Align the arguments.*\n.*Use the new})
|
80
80
|
expect(PuppetCheck.settings[:clean_files]).to eql([])
|
81
81
|
end
|
82
82
|
it 'puts a bad style librarian Puppet file in the clean files array when rubocop_args ignores its warnings' do
|
83
|
-
RubyParser.librarian([fixtures_dir
|
83
|
+
RubyParser.librarian(["#{fixtures_dir}librarian_style/Puppetfile"], true, ['--except', 'Layout/AlignArguments,Style/HashSyntax'])
|
84
84
|
expect(PuppetCheck.settings[:error_files]).to eql([])
|
85
85
|
expect(PuppetCheck.settings[:warning_files]).to eql([])
|
86
86
|
expect(PuppetCheck.settings[:clean_files]).to eql(["#{fixtures_dir}librarian_style/Puppetfile"])
|
87
87
|
end
|
88
88
|
it 'puts a good librarian Puppet file in the clean files array' do
|
89
|
-
RubyParser.librarian([fixtures_dir
|
89
|
+
RubyParser.librarian(["#{fixtures_dir}librarian_good/Puppetfile"], true, [])
|
90
90
|
expect(PuppetCheck.settings[:error_files]).to eql([])
|
91
91
|
expect(PuppetCheck.settings[:warning_files]).to eql([])
|
92
92
|
expect(PuppetCheck.settings[:clean_files]).to eql(["#{fixtures_dir}librarian_good/Puppetfile"])
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'rake/task'
|
2
|
-
require_relative '../spec_helper
|
2
|
+
require_relative '../spec_helper'
|
3
3
|
require_relative '../../lib/puppet-check/tasks'
|
4
4
|
|
5
5
|
describe PuppetCheck::Tasks do
|
6
6
|
after(:all) do
|
7
7
|
# cleanup rspec_puppet_setup
|
8
|
-
|
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
|
data/spec/spec_helper.rb
CHANGED
@@ -4,8 +4,13 @@ require 'rspec'
|
|
4
4
|
module Variables
|
5
5
|
extend RSpec::SharedContext
|
6
6
|
|
7
|
-
|
8
|
-
|
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
|
9
14
|
end
|
10
15
|
|
11
16
|
RSpec.configure do |config|
|
data/spec/system/system_spec.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'rake/task'
|
2
|
-
require_relative '../spec_helper
|
2
|
+
require_relative '../spec_helper'
|
3
3
|
require_relative '../../lib/puppet-check/cli'
|
4
4
|
require_relative '../../lib/puppet-check/tasks'
|
5
5
|
|
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
|
# see regression_check_spec
|
9
|
-
if
|
9
|
+
if ENV['TRAVIS'] == 'true' || ENV['CIRCLECI'] == 'true'
|
10
10
|
let(:cli) { PuppetCheck::CLI.run(%w[-s --puppet-lint no-hard_tabs-check,no-140chars-check --rubocop Metrics/LineLength,Style/Encoding .]) }
|
11
11
|
else
|
12
12
|
let(:cli) { PuppetCheck::CLI.run(%w[-s --puppet-lint no-hard_tabs-check,no-140chars-check --rubocop Metrics/LineLength,Style/Encoding --smoke -n good.example.com --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.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Schuchard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '5.0'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '8'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
29
|
+
version: '5.0'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '8'
|
@@ -153,7 +153,6 @@ files:
|
|
153
153
|
- LICENSE.md
|
154
154
|
- README.md
|
155
155
|
- bin/puppet-check
|
156
|
-
- lib/puppet-check.rb
|
157
156
|
- lib/puppet-check/cli.rb
|
158
157
|
- lib/puppet-check/data_parser.rb
|
159
158
|
- lib/puppet-check/output_results.rb
|
@@ -163,6 +162,7 @@ files:
|
|
163
162
|
- lib/puppet-check/ruby_parser.rb
|
164
163
|
- lib/puppet-check/tasks.rb
|
165
164
|
- lib/puppet-check/utils.rb
|
165
|
+
- lib/puppet_check.rb
|
166
166
|
- spec/fixtures/foobarbaz
|
167
167
|
- spec/fixtures/hieradata/good.eyaml
|
168
168
|
- spec/fixtures/hieradata/good.json
|
@@ -204,7 +204,7 @@ files:
|
|
204
204
|
- spec/octocatalog-diff/facts.yaml
|
205
205
|
- spec/octocatalog-diff/hiera.yaml
|
206
206
|
- spec/octocatalog-diff/manifests/site.pp
|
207
|
-
- spec/octocatalog-diff/
|
207
|
+
- spec/octocatalog-diff/octocatalog_diff.cfg.rb
|
208
208
|
- spec/puppet-check/cli_spec.rb
|
209
209
|
- spec/puppet-check/data_parser_spec.rb
|
210
210
|
- spec/puppet-check/output_results_spec.rb
|
@@ -214,7 +214,7 @@ files:
|
|
214
214
|
- spec/puppet-check/ruby_parser_spec.rb
|
215
215
|
- spec/puppet-check/tasks_spec.rb
|
216
216
|
- spec/puppet-check/utils_spec.rb
|
217
|
-
- spec/
|
217
|
+
- spec/puppet_check_spec.rb
|
218
218
|
- spec/spec_helper.rb
|
219
219
|
- spec/system/system_spec.rb
|
220
220
|
homepage: https://www.github.com/mschuchard/puppet-check
|
@@ -229,7 +229,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
229
229
|
requirements:
|
230
230
|
- - ">="
|
231
231
|
- !ruby/object:Gem::Version
|
232
|
-
version: 2.
|
232
|
+
version: 2.4.0
|
233
233
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
234
234
|
requirements:
|
235
235
|
- - ">="
|
@@ -283,7 +283,7 @@ test_files:
|
|
283
283
|
- spec/octocatalog-diff/facts.yaml
|
284
284
|
- spec/octocatalog-diff/hiera.yaml
|
285
285
|
- spec/octocatalog-diff/manifests/site.pp
|
286
|
-
- spec/octocatalog-diff/
|
286
|
+
- spec/octocatalog-diff/octocatalog_diff.cfg.rb
|
287
287
|
- spec/puppet-check/cli_spec.rb
|
288
288
|
- spec/puppet-check/data_parser_spec.rb
|
289
289
|
- spec/puppet-check/output_results_spec.rb
|
@@ -293,6 +293,6 @@ test_files:
|
|
293
293
|
- spec/puppet-check/ruby_parser_spec.rb
|
294
294
|
- spec/puppet-check/tasks_spec.rb
|
295
295
|
- spec/puppet-check/utils_spec.rb
|
296
|
-
- spec/
|
296
|
+
- spec/puppet_check_spec.rb
|
297
297
|
- spec/spec_helper.rb
|
298
298
|
- spec/system/system_spec.rb
|