onceover 3.17.2 → 3.19.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +2 -0
  3. data/.github/workflows/tests.yaml +40 -0
  4. data/.rubocop.yml +20 -2
  5. data/Gemfile +0 -13
  6. data/README.md +201 -110
  7. data/Rakefile +8 -5
  8. data/factsets/CentOS-8.3.2011-64.json +485 -0
  9. data/factsets/Debian-10.4-64.json +476 -0
  10. data/factsets/Debian-8.11-64.json +480 -0
  11. data/factsets/Debian-9.12-64.json +476 -0
  12. data/factsets/Ubuntu-20.04-64.json +504 -0
  13. data/factsets/Windows_Server-2008r2-64.json +184 -183
  14. data/factsets/Windows_Server-2012r2-64.json +165 -164
  15. data/factsets/windows-10-64.json +104 -103
  16. data/features/cache.feature +1 -1
  17. data/features/step_definitions/cache.rb +4 -4
  18. data/features/step_definitions/common.rb +38 -10
  19. data/features/step_definitions/init.rb +2 -2
  20. data/features/windows.feature +5 -0
  21. data/features/zzz_run.feature +22 -3
  22. data/lib/onceover/controlrepo.rb +10 -4
  23. data/lib/onceover/deploy.rb +3 -1
  24. data/lib/onceover/group.rb +3 -1
  25. data/lib/onceover/rspec/formatters.rb +6 -1
  26. data/lib/onceover/runner.rb +7 -6
  27. data/lib/onceover/test.rb +3 -2
  28. data/lib/onceover/testconfig.rb +28 -5
  29. data/onceover.gemspec +5 -2
  30. data/spec/fixtures/controlrepos/basic/manifests_alternate/site.pp +2 -0
  31. data/spec/fixtures/controlrepos/caching/Puppetfile +17 -17
  32. data/spec/fixtures/controlrepos/caching/manifests/site.pp +1 -0
  33. data/spec/fixtures/controlrepos/custom_puppetfile/Puppetfile.custom +3 -0
  34. data/spec/fixtures/controlrepos/custom_puppetfile/environment.conf +7 -0
  35. data/spec/fixtures/controlrepos/windows/Puppetfile +6 -1
  36. data/spec/fixtures/controlrepos/windows/site-modules/role/manifests/choco.pp +9 -0
  37. data/templates/test_spec.rb.erb +1 -1
  38. metadata +75 -18
  39. data/.travis.yml +0 -19
  40. data/appveyor.yml +0 -38
@@ -60,6 +60,7 @@ class Onceover
60
60
  @@all
61
61
  end
62
62
 
63
+ # rubocop:disable Lint/DuplicateBranch
63
64
  def self.valid_members?(members)
64
65
  # Check that they are all the same type
65
66
  # Also catch any errors to assume it's invalid
@@ -71,9 +72,10 @@ class Onceover
71
72
  else
72
73
  return false
73
74
  end
74
- rescue StandardErroor
75
+ rescue StandardError
75
76
  return false
76
77
  end
77
78
  end
79
+ # rubocop:enable Lint/DuplicateBranch
78
80
  end
79
81
  end
@@ -12,7 +12,9 @@ class OnceoverFormatter
12
12
  )
13
13
 
14
14
  COMPILATION_ERROR = %r{error during compilation: (?<error>.*)}
15
+ # rubocop:disable Lint/MixedRegexpCaptureTypes
15
16
  ERROR_WITH_LOCATION = %r{(?<error>.*?)\s(at )?(\((file: (?<file>.*?), )?line: (?<line>\d+)(, column: (?<column>\d+))?\))(; )?}
17
+ # rubocop:enable Lint/MixedRegexpCaptureTypes
16
18
  ERROR_WITHOUT_LOCATION = %r{(?<error>.*?)\son node}
17
19
 
18
20
  def initialize output
@@ -72,6 +74,8 @@ class OnceoverFormatter
72
74
  @output << "\n"
73
75
  end
74
76
 
77
+ # rubocop:disable Style/CombinableLoops
78
+ #
75
79
  # This method takes a notification and formats it into a hash that can be
76
80
  # printed easily
77
81
  def extract_failures notification
@@ -90,6 +94,7 @@ class OnceoverFormatter
90
94
 
91
95
  grouped
92
96
  end
97
+ # rubocop:enable Style/CombinableLoops
93
98
 
94
99
  # Extaracts data out of RSpec failres
95
100
  def extract_failure_data(fails)
@@ -309,4 +314,4 @@ class FailureCollector
309
314
  end
310
315
  }
311
316
  end
312
- end
317
+ end
@@ -1,4 +1,5 @@
1
1
  require 'backticks'
2
+ require 'io/console'
2
3
 
3
4
  class Onceover
4
5
  class Runner
@@ -24,8 +25,8 @@ class Onceover
24
25
  FileUtils.mkdir_p("#{@repo.tempdir}/spec/classes")
25
26
  FileUtils.mkdir_p("#{@repo.tempdir}/spec/acceptance/nodesets")
26
27
 
27
- # Copy our entire spec directory over
28
- FileUtils.cp_r("#{@repo.spec_dir}", "#{@repo.tempdir}")
28
+ # Copy specified spec files over
29
+ @config.copy_spec_files(@repo)
29
30
 
30
31
  # Create the Rakefile so that we can take advantage of the existing tasks
31
32
  @config.write_rakefile(@repo.tempdir, "spec/classes/**/*_spec.rb")
@@ -36,8 +37,6 @@ class Onceover
36
37
  # Create spec_helper_accpetance.rb
37
38
  @config.write_spec_helper_acceptance("#{@repo.tempdir}/spec", @repo)
38
39
 
39
- # TODO: Remove all tests that do not match set tags
40
-
41
40
  if @mode.include?(:spec)
42
41
  # Verify all of the spec tests
43
42
  @config.spec_tests.each { |test| @config.verify_spec_test(@repo, test) }
@@ -83,8 +82,10 @@ class Onceover
83
82
  ENV['RUBYOPT'] = ENV['RUBYOPT'].to_s + ' -W0'
84
83
  end
85
84
 
86
- #`bundle install --binstubs`
87
- #`bin/rake spec_standalone`
85
+ # NOTE: This is the way to provide options to rspec according to:
86
+ # https://github.com/puppetlabs/puppetlabs_spec_helper/blob/master/lib/puppetlabs_spec_helper/rake_tasks.rb#L51
87
+ ENV['CI_SPEC_OPTIONS'] = ENV['CI_SPEC_OPTIONS'].to_s + @config.filter_tags.map { |tag| " --tag #{tag}" }.join unless @config.filter_tags.nil?
88
+
88
89
  if @config.opts[:parallel]
89
90
  logger.debug "Running #{@command_prefix}rake parallel_spec from #{@repo.tempdir}"
90
91
  result = run_command(@command_prefix.strip.split, 'rake', 'parallel_spec')
@@ -25,10 +25,11 @@ class Onceover
25
25
  @classes = []
26
26
  @test_config = test_config
27
27
  @test_config.delete('classes') # remove classes from the config
28
- @tags = @test_config['tags']
29
28
 
30
29
  # Make sure that tags are an array
31
- @test_config['tags'] = [@test_config['tags']].flatten if @test_config['tags']
30
+ @test_config['tags'] ||= []
31
+ @test_config['tags'] = [@test_config['tags']].flatten
32
+ @tags = @test_config['tags']
32
33
 
33
34
  # Get the nodes we are working on
34
35
  if Onceover::Group.find(on_this)
@@ -50,6 +50,7 @@ class Onceover
50
50
  @before_conditions = config['before'] || []
51
51
  @after_conditions = config['after']
52
52
  @strict_variables = opts[:strict_variables] ? 'yes' : 'no'
53
+ @included_specs = [config['include_spec_files'] || ['**/*']].flatten
53
54
 
54
55
  # Set dynamic defaults for format
55
56
  if Array(opts[:format]) == [:defaults]
@@ -236,6 +237,19 @@ class Onceover
236
237
  )
237
238
  end
238
239
 
240
+ def copy_spec_files(repo)
241
+ source_files = @included_specs.map { |glob| Dir.glob "#{repo.spec_dir}/#{glob}" }.flatten.uniq
242
+ source_files.each do |source_file|
243
+ target_file = File.join(repo.tempdir, 'spec', source_file.sub(/^#{repo.spec_dir}/, ''))
244
+ if File.directory?(source_file)
245
+ FileUtils.cp_r source_file, target_file unless File.exists? target_file
246
+ else
247
+ FileUtils.mkdir_p File.dirname target_file
248
+ FileUtils.cp source_file, target_file
249
+ end
250
+ end
251
+ end
252
+
239
253
  def create_fixtures_symlinks(repo)
240
254
  logger.debug "Creating fixtures symlinks"
241
255
  FileUtils.rm_rf("#{repo.tempdir}/spec/fixtures/modules")
@@ -275,16 +289,25 @@ class Onceover
275
289
  # Remove tests that do not have matching tags
276
290
  tests.keep_if do |test|
277
291
  filter_list.any? do |filter|
278
- if test.send(method)
279
- test.send(method).include?(filter)
280
- else
281
- false
282
- end
292
+ filter_test test, method, filter
283
293
  end
284
294
  end
285
295
  end
286
296
  end
287
297
  tests
288
298
  end
299
+
300
+ def filter_test(test, method, filter)
301
+ if test.send(method)
302
+ if method == 'tags' && filter.start_with?('~')
303
+ filter = filter.sub(/^~/, '')
304
+ ! test.send(method).include?(filter)
305
+ else
306
+ test.send(method).include?(filter)
307
+ end
308
+ else
309
+ false
310
+ end
311
+ end
289
312
  end
290
313
  end
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "onceover"
7
- s.version = "3.17.2"
7
+ s.version = "3.19.1"
8
8
  s.authors = ["Dylan Ratcliffe"]
9
9
  s.email = ["dylan.ratcliffe@puppet.com"]
10
10
  s.homepage = "https://github.com/dylanratcliffe/onceover"
@@ -22,7 +22,6 @@ Gem::Specification.new do |s|
22
22
  s.add_runtime_dependency 'colored', '~> 1.2'
23
23
  s.add_runtime_dependency 'cri', '>= 2.6'
24
24
  s.add_runtime_dependency 'deep_merge', '>= 1.0.0'
25
- s.add_runtime_dependency 'facter', '< 4.0.0'
26
25
  s.add_runtime_dependency 'git'
27
26
  s.add_runtime_dependency 'logging', '>= 2.0.0'
28
27
  s.add_runtime_dependency 'multi_json', '~> 1.10'
@@ -37,4 +36,8 @@ Gem::Specification.new do |s|
37
36
  s.add_runtime_dependency 'terminal-table', '>= 1.8.0'
38
37
  s.add_runtime_dependency 'versionomy', '>= 0.5.0'
39
38
 
39
+ s.add_development_dependency 'cucumber', '~> 4.1'
40
+ s.add_development_dependency 'pry', '~> 0.13.1'
41
+ s.add_development_dependency 'rubocop', '~> 1.6', '>= 1.6.1'
42
+ s.add_development_dependency 'rubygems-tasks', '~> 0.2.5'
40
43
  end
@@ -0,0 +1,2 @@
1
+ # This will fail all compilations so that we can quickly tell if it's being used
2
+ fail('Using alternate site.pp')
@@ -1,17 +1,17 @@
1
- forge "http://forge.puppetlabs.com"
2
- #
3
- # I want to download some modules to check if r10k feature in Onceover works correctly.
4
- #
5
-
6
- # Versions should be updated to be the latest at the time you start
7
- mod "puppetlabs/stdlib", '4.11.0'
8
-
9
- # Modules from Git
10
- # Examples: https://github.com/puppetlabs/r10k/blob/master/doc/puppetfile.mkd#examples
11
- mod 'apache',
12
- :git => 'https://github.com/puppetlabs/puppetlabs-apache',
13
- :commit => '83401079053dca11d61945bd9beef9ecf7576cbf'
14
-
15
- #mod 'apache',
16
- # :git => 'https://github.com/puppetlabs/puppetlabs-apache',
17
- # :branch => 'docs_experiment'
1
+ forge "http://forge.puppetlabs.com"
2
+ #
3
+ # I want to download some modules to check if r10k feature in Onceover works correctly.
4
+ #
5
+
6
+ # Versions should be updated to be the latest at the time you start
7
+ mod "puppetlabs/stdlib", '4.11.0'
8
+
9
+ # Modules from Git
10
+ # Examples: https://github.com/puppetlabs/r10k/blob/master/doc/puppetfile.mkd#examples
11
+ mod 'apache',
12
+ :git => 'https://github.com/puppetlabs/puppetlabs-apache',
13
+ :commit => '83401079053dca11d61945bd9beef9ecf7576cbf'
14
+
15
+ #mod 'apache',
16
+ # :git => 'https://github.com/puppetlabs/puppetlabs-apache',
17
+ # :branch => 'docs_experiment'
@@ -29,4 +29,5 @@ node default {
29
29
  # This is where you can declare classes for all nodes.
30
30
  # Example:
31
31
  # class { 'my_class': }
32
+ fail('This was using the manifest setting from environment.conf')
32
33
  }
@@ -0,0 +1,3 @@
1
+ forge "http://forge.puppetlabs.com"
2
+
3
+ mod "puppet/extlib"
@@ -0,0 +1,7 @@
1
+ modulepath = site:modules:$basemodulepath
2
+
3
+ # Comments!
4
+
5
+ value_with_equals = 'foo=bar'
6
+
7
+ config_version = 'scripts/config_version.sh $environmentpath $environment'
@@ -1,3 +1,8 @@
1
1
  forge "http://forge.puppetlabs.com"
2
2
 
3
- mod 'puppetlabs-acl', '3.1.1'
3
+ mod 'puppetlabs-acl', '3.2.1'
4
+ mod 'puppetlabs-chocolatey', '5.2.0'
5
+ mod 'puppetlabs-stdlib', '6.5.0'
6
+ mod 'puppetlabs-powershell', '4.1.0'
7
+ mod 'puppetlabs-pwshlib', '0.6.3'
8
+ mod 'puppetlabs-registry', '3.2.0'
@@ -0,0 +1,9 @@
1
+ # Choco
2
+ class role::choco {
3
+ include ::chocolatey
4
+
5
+ package { 'winzip':
6
+ ensure => 'present',
7
+ provider => 'chocolatey',
8
+ }
9
+ }
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  <% test.classes.each do |cls| -%>
4
- describe "<%= cls.name %>" do
4
+ describe "<%= cls.name %>"<%= test.tags.map { |tag| ",#{tag}: true "}.join %> do
5
5
 
6
6
  <% test.nodes.each do |node| -%>
7
7
  context "using fact set <%= node.name %>" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onceover
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.17.2
4
+ version: 3.19.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dylan Ratcliffe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-08 00:00:00.000000000 Z
11
+ date: 2021-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backticks
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.0.0
69
- - !ruby/object:Gem::Dependency
70
- name: facter
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "<"
74
- - !ruby/object:Gem::Version
75
- version: 4.0.0
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "<"
81
- - !ruby/object:Gem::Version
82
- version: 4.0.0
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: git
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -262,6 +248,68 @@ dependencies:
262
248
  - - ">="
263
249
  - !ruby/object:Gem::Version
264
250
  version: 0.5.0
251
+ - !ruby/object:Gem::Dependency
252
+ name: cucumber
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - "~>"
256
+ - !ruby/object:Gem::Version
257
+ version: '4.1'
258
+ type: :development
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - "~>"
263
+ - !ruby/object:Gem::Version
264
+ version: '4.1'
265
+ - !ruby/object:Gem::Dependency
266
+ name: pry
267
+ requirement: !ruby/object:Gem::Requirement
268
+ requirements:
269
+ - - "~>"
270
+ - !ruby/object:Gem::Version
271
+ version: 0.13.1
272
+ type: :development
273
+ prerelease: false
274
+ version_requirements: !ruby/object:Gem::Requirement
275
+ requirements:
276
+ - - "~>"
277
+ - !ruby/object:Gem::Version
278
+ version: 0.13.1
279
+ - !ruby/object:Gem::Dependency
280
+ name: rubocop
281
+ requirement: !ruby/object:Gem::Requirement
282
+ requirements:
283
+ - - "~>"
284
+ - !ruby/object:Gem::Version
285
+ version: '1.6'
286
+ - - ">="
287
+ - !ruby/object:Gem::Version
288
+ version: 1.6.1
289
+ type: :development
290
+ prerelease: false
291
+ version_requirements: !ruby/object:Gem::Requirement
292
+ requirements:
293
+ - - "~>"
294
+ - !ruby/object:Gem::Version
295
+ version: '1.6'
296
+ - - ">="
297
+ - !ruby/object:Gem::Version
298
+ version: 1.6.1
299
+ - !ruby/object:Gem::Dependency
300
+ name: rubygems-tasks
301
+ requirement: !ruby/object:Gem::Requirement
302
+ requirements:
303
+ - - "~>"
304
+ - !ruby/object:Gem::Version
305
+ version: 0.2.5
306
+ type: :development
307
+ prerelease: false
308
+ version_requirements: !ruby/object:Gem::Requirement
309
+ requirements:
310
+ - - "~>"
311
+ - !ruby/object:Gem::Version
312
+ version: 0.2.5
265
313
  description: Automatically generates tests for your Puppet code
266
314
  email:
267
315
  - dylan.ratcliffe@puppet.com
@@ -270,14 +318,14 @@ executables:
270
318
  extensions: []
271
319
  extra_rdoc_files: []
272
320
  files:
321
+ - ".gitattributes"
322
+ - ".github/workflows/tests.yaml"
273
323
  - ".gitignore"
274
324
  - ".gitmodules"
275
325
  - ".rubocop.yml"
276
- - ".travis.yml"
277
326
  - Gemfile
278
327
  - README.md
279
328
  - Rakefile
280
- - appveyor.yml
281
329
  - bin/onceover
282
330
  - factsets/AIX-6.1-powerpc.json
283
331
  - factsets/AIX-7.1-powerpc.json
@@ -287,10 +335,14 @@ files:
287
335
  - factsets/CentOS-6.6-32.json
288
336
  - factsets/CentOS-6.6-64.json
289
337
  - factsets/CentOS-7.0-64.json
338
+ - factsets/CentOS-8.3.2011-64.json
339
+ - factsets/Debian-10.4-64.json
290
340
  - factsets/Debian-6.0.10-32.json
291
341
  - factsets/Debian-6.0.10-64.json
292
342
  - factsets/Debian-7.8-32.json
293
343
  - factsets/Debian-7.8-64.json
344
+ - factsets/Debian-8.11-64.json
345
+ - factsets/Debian-9.12-64.json
294
346
  - factsets/RHEL-6.7.json
295
347
  - factsets/RHEL-7.4.json
296
348
  - factsets/SLES-11.3-64.json
@@ -300,6 +352,7 @@ files:
300
352
  - factsets/Ubuntu-14.04-32.json
301
353
  - factsets/Ubuntu-14.04-64.json
302
354
  - factsets/Ubuntu-18.04-64.json
355
+ - factsets/Ubuntu-20.04-64.json
303
356
  - factsets/Windows_Server-2008r2-64.json
304
357
  - factsets/Windows_Server-2012r2-64.json
305
358
  - factsets/solaris-10_u9-sparc-64.json
@@ -347,6 +400,7 @@ files:
347
400
  - spec/fixtures/controlrepos/basic/hieradata/common.yaml
348
401
  - spec/fixtures/controlrepos/basic/hieradata/nodes/example-node.yaml
349
402
  - spec/fixtures/controlrepos/basic/manifests/site.pp
403
+ - spec/fixtures/controlrepos/basic/manifests_alternate/site.pp
350
404
  - spec/fixtures/controlrepos/basic/site/profile/manifests/base.pp
351
405
  - spec/fixtures/controlrepos/basic/site/profile/manifests/example.pp
352
406
  - spec/fixtures/controlrepos/basic/site/role/manifests/database_server.pp
@@ -374,6 +428,8 @@ files:
374
428
  - spec/fixtures/controlrepos/caching/spec/r10k.yaml
375
429
  - spec/fixtures/controlrepos/control_branch/Puppetfile
376
430
  - spec/fixtures/controlrepos/control_branch/environment.conf
431
+ - spec/fixtures/controlrepos/custom_puppetfile/Puppetfile.custom
432
+ - spec/fixtures/controlrepos/custom_puppetfile/environment.conf
377
433
  - spec/fixtures/controlrepos/factsets/environment.conf
378
434
  - spec/fixtures/controlrepos/factsets/site/profile/manifests/base.pp
379
435
  - spec/fixtures/controlrepos/factsets/site/role/manifests/example.pp
@@ -394,6 +450,7 @@ files:
394
450
  - spec/fixtures/controlrepos/windows/Puppetfile
395
451
  - spec/fixtures/controlrepos/windows/environment.conf
396
452
  - spec/fixtures/controlrepos/windows/site-modules/role/manifests/acl.pp
453
+ - spec/fixtures/controlrepos/windows/site-modules/role/manifests/choco.pp
397
454
  - spec/fixtures/controlrepos/windows/site-modules/role/manifests/groups.pp
398
455
  - spec/fixtures/controlrepos/windows/site-modules/role/manifests/users.pp
399
456
  - spec/fixtures/controlrepos/windows/site/role/manifests/groups.pp