voxpupuli-test 9.2.0 → 10.0.0

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: 71c6e08123426c8d07b50efe5c35be89b9f1416177be3bec4ae4609ec0d30b32
4
- data.tar.gz: f9c3b2f225a0702629f16ad8e8e9b5e54e9d83ac347cb6c79e7c0c07a9870268
3
+ metadata.gz: 02002dd2ba7b57301e64676e32c5572bee0f89f46a3d7c27b76905b02453dad6
4
+ data.tar.gz: 62cec2d5d5612c861d3201a85105c787ec4f6420343501650677c9a663be76f3
5
5
  SHA512:
6
- metadata.gz: 7c0797dc532f84a4889d5f281f34247ea471d32315930e4c517dbf33538d0963c2d424f3e2e07ebc591dd5f4dbd34f7180982756fb779c6b75d48de050c926a5
7
- data.tar.gz: 7ff8d8b75a3e8b76b512436d36639c87042553c0da85acf70da1cedc109daf12202cc339fd7f7e3e91b3be1448988caaed57c53238c551a53a8ab3c4c382e8f5
6
+ metadata.gz: f3c49ce2f32bbb670b926a621c575c1a3a3929fcdeff7cd02261ad0865b9e169042d5dc44c12bd486831ba6ae8e5cf6a019152d1fdccaadb02efa4f8bb5a5e2b
7
+ data.tar.gz: 71374a7b1c7ff4e99dc6f397eac88aa166ec29f3e035d5e998c92c003b74b242095f3240464a917aa3f20b811cc1eec2640de531587df527602c453e530c9e35
data/README.md CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  [![License](https://img.shields.io/github/license/voxpupuli/voxpupuli-test.svg)](https://github.com/voxpupuli/voxpupuli-test/blob/master/LICENSE)
4
4
  [![Test](https://github.com/voxpupuli/voxpupuli-test/actions/workflows/test.yml/badge.svg)](https://github.com/voxpupuli/voxpupuli-test/actions/workflows/test.yml)
5
- [![codecov](https://codecov.io/gh/voxpupuli/voxpupuli-test/branch/master/graph/badge.svg?token=Mypkl78hvK)](https://codecov.io/gh/voxpupuli/voxpupuli-test)
6
5
  [![Release](https://github.com/voxpupuli/voxpupuli-test/actions/workflows/release.yml/badge.svg)](https://github.com/voxpupuli/voxpupuli-test/actions/workflows/release.yml)
7
6
  [![RubyGem Version](https://img.shields.io/gem/v/voxpupuli-test.svg)](https://rubygems.org/gems/voxpupuli-test)
8
7
  [![RubyGem Downloads](https://img.shields.io/gem/dt/voxpupuli-test.svg)](https://rubygems.org/gems/voxpupuli-test)
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :check do
4
+ desc 'Fails if .pp files present in tests folder'
5
+ task :test_file do
6
+ ppfiles = Dir[File.join('tests', '**', '*.pp')]
7
+ unless ppfiles.empty?
8
+ puts ppfiles
9
+ raise '.pp files present in tests folder; Move them to an examples folder following the new convention'
10
+ end
11
+ end
12
+
13
+ desc 'Fails if any ._ files are present in directory'
14
+ task :dot_underscore do
15
+ dirs = Dir['._*']
16
+ unless dirs.empty?
17
+ puts dirs
18
+ raise '._ files are present in the directory'
19
+ end
20
+ end
21
+
22
+ desc 'Fails if directories contain the files specified in .gitignore'
23
+ task :git_ignore do
24
+ matched = `git ls-files --ignored --exclude-standard --cached`
25
+ raise 'git ls-files failed' unless $CHILD_STATUS.success?
26
+
27
+ unless matched == ''
28
+ puts matched
29
+ raise 'File specified in .gitignore has been committed'
30
+ end
31
+ end
32
+
33
+ desc 'Check for trailing whitespace'
34
+ task :trailing_whitespace do
35
+ errors = []
36
+
37
+ Dir.glob('**/*.md', File::FNM_DOTMATCH).sort.each do |filename|
38
+ next if filename =~ %r{^((modules|acceptance|\.?vendor|spec/fixtures|pkg)/|REFERENCE.md)}
39
+
40
+ File.foreach(filename).each_with_index do |line, index|
41
+ if line =~ /\s\n$/
42
+ errors << "#{filename} has trailing whitespace on line #{index + 1}"
43
+ end
44
+ end
45
+ end
46
+
47
+ if errors.any?
48
+ errors.each { |error| puts error }
49
+ exit 1
50
+ end
51
+ end
52
+ end
53
+
54
+ desc 'Run static pre release checks'
55
+ task check: ['check:test_file', 'check:dot_underscore', 'check:git_ignore', 'check:trailing_whitespace']
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'puppet-lint/tasks/puppet-lint'
4
+ # Must clear as it will not override the existing puppet-lint rake task since we require to import for
5
+ # the PuppetLint::RakeTask
6
+ Rake::Task[:lint].clear
7
+ # without this, puppet-lint always gives an exit code of 0
8
+ PuppetLint.configuration.fail_on_warnings = true
9
+ # Utilize PuppetLint global configuration so that these settings can be tweaked by
10
+ # spec_helper.rb in an individual module
11
+ PuppetLint.configuration.relative = true
12
+ PuppetLint.configuration.ignore_paths << '.vendor/**/*.pp'
13
+ PuppetLint.configuration.ignore_paths << 'bundle/**/*.pp'
14
+ PuppetLint.configuration.ignore_paths << 'pkg/**/*.pp'
15
+ PuppetLint.configuration.ignore_paths << 'spec/**/*.pp'
16
+ PuppetLint.configuration.ignore_paths << 'tests/**/*.pp'
17
+ PuppetLint.configuration.disable_140chars
18
+ PuppetLint.configuration.disable_documentation
19
+ PuppetLint.configuration.disable_single_quote_string_with_variables
20
+ PuppetLint::RakeTask.new(:lint)
21
+
22
+ desc 'Run puppet-lint and fix issues automatically'
23
+ PuppetLint::RakeTask.new(:lint_fix) do |config|
24
+ config.fix = true
25
+ end
26
+
27
+ PuppetLint.configuration.log_format = '%<path>s:%<line>s:%<check>s:%<KIND>s:%<message>s'
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'puppet-syntax/tasks/puppet-syntax'
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubocop/rake_task'
4
+ RuboCop::RakeTask.new(:rubocop) do |task|
5
+ # These make the rubocop experience maybe slightly less terrible
6
+ task.options = ['--debug', '--display-style-guide', '--extra-details']
7
+
8
+ # Use Rubocop's Github Actions formatter if possible
9
+ if ENV['GITHUB_ACTIONS'] == 'true'
10
+ task.formatters << 'github'
11
+ end
12
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'puppet_fixtures/tasks'
4
+ require 'parallel_tests'
5
+ require 'rspec/core/rake_task'
6
+
7
+ pattern = 'spec/{aliases,classes,defines,functions,hosts,integration,plans,tasks,type_aliases,types,unit}/**/*_spec.rb'
8
+
9
+ desc 'Run spec tests and clean the fixtures directory if successful'
10
+ task spec: :'fixtures:prep' do |_t, args|
11
+ Rake::Task['spec:standalone'].invoke(*args.extras)
12
+ Rake::Task['fixtures:clean'].invoke
13
+ end
14
+
15
+ desc 'Run spec tests in parallel and clean the fixtures directory if successful'
16
+ task parallel_spec: :'fixtures:prep' do |_t, args|
17
+ Rake::Task['parallel_spec:standalone'].invoke(*args.extras)
18
+ Rake::Task['fixtures:clean'].invoke
19
+ end
20
+
21
+ desc 'Parallel spec tests'
22
+ task 'parallel_spec:standalone' do |_t, args|
23
+ file_list = Rake::FileList[pattern].to_a
24
+ if file_list.empty?
25
+ warn 'No files for parallel_spec to run against'
26
+ else
27
+ ci_opts = ENV['CI_SPEC_OPTIONS'].to_s.strip.split
28
+ args = ['--type', 'rspec', '--', '--format', 'progress'] + ci_opts + ['--'] + file_list
29
+
30
+ ParallelTests::CLI.new.run(args)
31
+ end
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new('spec:standalone') do |t, _args|
35
+ t.rspec_opts = []
36
+ unless ENV['CI_SPEC_OPTIONS'].nil?
37
+ t.rspec_opts << ENV['CI_SPEC_OPTIONS']
38
+ end
39
+ t.pattern = pattern
40
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'metadata-json-lint/rake_task'
4
+ require 'puppet-strings/tasks'
5
+
6
+ namespace :validate do
7
+ desc 'Validate all .rb files'
8
+ task :ruby do
9
+ Dir['lib/**/*.rb'].each do |lib_file|
10
+ sh ['ruby', '-c', lib_file]
11
+ end
12
+ end
13
+
14
+ desc 'validate REFERENCE.md if it exists'
15
+ task :strings do
16
+ if File.exist?('REFERENCE.md')
17
+ Rake::Task['strings:validate:reference'].invoke
18
+ end
19
+ end
20
+ end
21
+
22
+ # `syntax` will validate pp, hiera, erb, epp files
23
+ desc 'Check syntax of Ruby files and call :syntax and :metadata_lint'
24
+ task validate: ['validate:ruby', 'syntax', 'metadata_lint', 'validate:strings']
@@ -1,36 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'puppetlabs_spec_helper/rake_tasks'
3
+ # load and configure puppet-lint
4
+ require_relative 'rake/puppetlint'
4
5
 
5
- PuppetLint.configuration.log_format = '%<path>s:%<line>s:%<check>s:%<KIND>s:%<message>s'
6
- # without this, puppet-lint always gives an exit code of 0
7
- PuppetLint.configuration.fail_on_warnings = true
6
+ # load and configure puppet-syntax
7
+ require_relative 'rake/puppetsyntax'
8
8
 
9
- desc 'Run tests'
10
- task test: [:release_checks]
9
+ # define various helper tasks
10
+ require_relative 'rake/check'
11
11
 
12
- task default: [:release_checks]
12
+ # define the various spec tasks
13
+ require_relative 'rake/spec'
13
14
 
14
- namespace :check do
15
- desc 'Check for trailing whitespace'
16
- task :trailing_whitespace do
17
- errors = []
15
+ # static code analysis
16
+ require_relative 'rake/validate'
17
+ require_relative 'rake/rubocop'
18
18
 
19
- Dir.glob('**/*.md', File::FNM_DOTMATCH).sort.each do |filename|
20
- next if filename =~ %r{^((modules|acceptance|\.?vendor|spec/fixtures|pkg)/|REFERENCE.md)}
19
+ desc 'Runs all necessary checks on a module'
20
+ task test: %i[lint validate parallel_spec check]
21
21
 
22
- File.foreach(filename).each_with_index do |line, index|
23
- if line =~ /\s\n$/
24
- errors << "#{filename} has trailing whitespace on line #{index + 1}"
25
- end
26
- end
27
- end
28
-
29
- if errors.any?
30
- errors.each { |error| puts error }
31
- exit 1
32
- end
33
- end
34
- end
35
-
36
- Rake::Task[:check].enhance ['check:trailing_whitespace']
22
+ task default: [:test]
@@ -1,9 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'voxpupuli/test/facts'
4
- require 'puppetlabs_spec_helper/module_spec_helper'
4
+ require 'rspec-puppet'
5
+
6
+ spec_path = File.expand_path(File.join(Dir.pwd, 'spec'))
7
+ module_path = File.join(spec_path, 'fixtures', 'modules')
8
+
9
+ # Add all spec lib dirs to LOAD_PATH
10
+ Dir.glob(File.join(module_path, '*', 'spec', 'lib')).each do |d|
11
+ $LOAD_PATH << d if FileTest.directory?(d) && !$LOAD_PATH.include?(d)
12
+ end
5
13
 
6
14
  RSpec.configure do |config|
15
+ if ENV['GITHUB_ACTIONS'] == 'true'
16
+ config.formatter = 'RSpec::Github::Formatter'
17
+ end
18
+
19
+ config.environmentpath = spec_path
20
+
21
+ config.module_path = module_path
22
+ config.strict_variables = true
23
+
7
24
  # This completely disables Facter and uses a stubbed implementation. This is
8
25
  # fine since we use use rspec-puppet-facts to set all facts. It gives
9
26
  # complete isolation from the host system. It only works with Puppet 6.25+
@@ -13,6 +30,14 @@ RSpec.configure do |config|
13
30
  # In the next major release we will flip this to true
14
31
  config.facterdb_string_keys = false
15
32
 
33
+ config.before :each do
34
+ if config.mock_framework.framework_name == :rspec
35
+ allow(Puppet.features).to receive(:root?).and_return(true)
36
+ else
37
+ Puppet.features.stubs(:root?).returns(true)
38
+ end
39
+ end
40
+
16
41
  config.after(:suite) do
17
42
  RSpec::Puppet::Coverage.report!
18
43
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: voxpupuli-test
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.2.0
4
+ version: 10.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vox Pupuli
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-08 00:00:00.000000000 Z
11
+ date: 2025-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -62,30 +62,42 @@ dependencies:
62
62
  name: parallel_tests
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - "~>"
65
+ - - ">="
66
66
  - !ruby/object:Gem::Version
67
67
  version: '4.2'
68
+ - - "<"
69
+ - !ruby/object:Gem::Version
70
+ version: '6'
68
71
  type: :runtime
69
72
  prerelease: false
70
73
  version_requirements: !ruby/object:Gem::Requirement
71
74
  requirements:
72
- - - "~>"
75
+ - - ">="
73
76
  - !ruby/object:Gem::Version
74
77
  version: '4.2'
78
+ - - "<"
79
+ - !ruby/object:Gem::Version
80
+ version: '6'
75
81
  - !ruby/object:Gem::Dependency
76
- name: puppetlabs_spec_helper
82
+ name: puppet_fixtures
77
83
  requirement: !ruby/object:Gem::Requirement
78
84
  requirements:
79
85
  - - "~>"
80
86
  - !ruby/object:Gem::Version
81
- version: '8.0'
87
+ version: '0.1'
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: 0.1.1
82
91
  type: :runtime
83
92
  prerelease: false
84
93
  version_requirements: !ruby/object:Gem::Requirement
85
94
  requirements:
86
95
  - - "~>"
87
96
  - !ruby/object:Gem::Version
88
- version: '8.0'
97
+ version: '0.1'
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: 0.1.1
89
101
  - !ruby/object:Gem::Dependency
90
102
  name: puppet-strings
91
103
  requirement: !ruby/object:Gem::Requirement
@@ -100,6 +112,40 @@ dependencies:
100
112
  - - "~>"
101
113
  - !ruby/object:Gem::Version
102
114
  version: '4.0'
115
+ - !ruby/object:Gem::Dependency
116
+ name: puppet-syntax
117
+ requirement: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - "~>"
120
+ - !ruby/object:Gem::Version
121
+ version: '5.0'
122
+ type: :runtime
123
+ prerelease: false
124
+ version_requirements: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - "~>"
127
+ - !ruby/object:Gem::Version
128
+ version: '5.0'
129
+ - !ruby/object:Gem::Dependency
130
+ name: rspec-github
131
+ requirement: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '2.0'
136
+ - - "<"
137
+ - !ruby/object:Gem::Version
138
+ version: '4'
139
+ type: :runtime
140
+ prerelease: false
141
+ version_requirements: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '2.0'
146
+ - - "<"
147
+ - !ruby/object:Gem::Version
148
+ version: '4'
103
149
  - !ruby/object:Gem::Dependency
104
150
  name: rspec-puppet
105
151
  requirement: !ruby/object:Gem::Requirement
@@ -129,19 +175,19 @@ dependencies:
129
175
  - !ruby/object:Gem::Version
130
176
  version: '5.0'
131
177
  - !ruby/object:Gem::Dependency
132
- name: rspec-puppet-utils
178
+ name: syslog
133
179
  requirement: !ruby/object:Gem::Requirement
134
180
  requirements:
135
181
  - - "~>"
136
182
  - !ruby/object:Gem::Version
137
- version: '3.4'
183
+ version: 0.3.0
138
184
  type: :runtime
139
185
  prerelease: false
140
186
  version_requirements: !ruby/object:Gem::Requirement
141
187
  requirements:
142
188
  - - "~>"
143
189
  - !ruby/object:Gem::Version
144
- version: '3.4'
190
+ version: 0.3.0
145
191
  - !ruby/object:Gem::Dependency
146
192
  name: rubocop
147
193
  requirement: !ruby/object:Gem::Requirement
@@ -224,13 +270,19 @@ files:
224
270
  - README.md
225
271
  - lib/voxpupuli/test/facts.rb
226
272
  - lib/voxpupuli/test/rake.rb
273
+ - lib/voxpupuli/test/rake/check.rb
274
+ - lib/voxpupuli/test/rake/puppetlint.rb
275
+ - lib/voxpupuli/test/rake/puppetsyntax.rb
276
+ - lib/voxpupuli/test/rake/rubocop.rb
277
+ - lib/voxpupuli/test/rake/spec.rb
278
+ - lib/voxpupuli/test/rake/validate.rb
227
279
  - lib/voxpupuli/test/spec_helper.rb
228
280
  - rubocop.yml
229
281
  homepage: http://github.com/voxpupuli/voxpupuli-test
230
282
  licenses:
231
283
  - Apache-2.0
232
284
  metadata: {}
233
- post_install_message:
285
+ post_install_message:
234
286
  rdoc_options: []
235
287
  require_paths:
236
288
  - lib
@@ -246,7 +298,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
246
298
  version: '0'
247
299
  requirements: []
248
300
  rubygems_version: 3.3.27
249
- signing_key:
301
+ signing_key:
250
302
  specification_version: 4
251
303
  summary: Helpers for testing Vox Pupuli modules
252
304
  test_files: []