puppet-catalog-test 0.4.0 → 0.4.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
  SHA1:
3
- metadata.gz: 4f53f78fc8023e2f26117a42efe335a2a28d7001
4
- data.tar.gz: e7e7f8458131b14e1ce871a678d5c599a56e6edd
3
+ metadata.gz: 517c2bbbda18dac16199a792a47cccbcf0e92903
4
+ data.tar.gz: 9d3c28e74e25f164166a840ec97974d7962ab0f3
5
5
  SHA512:
6
- metadata.gz: bb3d70830479daf9a712bb61587bd31ff264e4931777ecbfa95341932d63622abcf0dc216e0564ba31ea88f78a10078f6c78b60d1d186f532ebf86b7bc2867a3
7
- data.tar.gz: 06c3830c8c6711c7602b80b069f4d866c1e9e8539635142d2b0754d40468733b18517a5043d2c32194c0d375af08bab3f1c804224cb050082619e09b389e89af
6
+ metadata.gz: 027de364b14c2cb16138a78e04ba2eb8c02ebcc032c6de1ea573a04827ca733f88dcc5ef63ba3d853f0c9745ba60f97c79514b3f9938ea84ee6498f0e3cc9a95
7
+ data.tar.gz: c97ce7f98c65ff6acab2166784f7b28307da94a64631c42c9c74504108270e57b8db14ab2f83dddec7d4360ba0e780582c5178932c0ceb23577774072d4d36fc
data/README.md CHANGED
@@ -27,6 +27,7 @@ USAGE: puppet-catalog-test [options]
27
27
  -e, --exclude-pattern PATTERN Exclude test cases that match pattern
28
28
  -s, --scenario FILE Scenario definition to use
29
29
  -f, --fact KEY=VALUE Add custom fact
30
+ -p, --parser (current|future) Change puppet parser (3.2+ only)
30
31
  -v, --verbose Verbose
31
32
  -x, --xml Use xml report
32
33
  -h, --help Show this message
@@ -124,6 +125,23 @@ namespace :catalog do
124
125
  end
125
126
  ```
126
127
 
128
+ ### Testing catalog with future parser
129
+ ```ruby
130
+ require 'puppet-catalog-test'
131
+
132
+ namespace :catalog do
133
+ PuppetCatalogTest::RakeTask.new(:scenarios) do |t|
134
+ t.module_paths = ["modules"]
135
+ t.manifest_path = File.join("scripts", "site.pp")
136
+
137
+ t.scenario_yaml = "scenarios.yml"
138
+ t.parser = "future"
139
+
140
+ t.include_pattern = ENV["include"]
141
+ t.exclude_pattern = ENV["exclude"]
142
+ end
143
+ ```
144
+
127
145
  ## Scenario testing
128
146
 
129
147
  Scenarios allow testing of more complex catalogs, e.g. having conditional branches depending on custom facts.
data/Rakefile CHANGED
@@ -1,5 +1,7 @@
1
1
  require "rake/testtask"
2
2
  require "bundler/gem_tasks"
3
+ require "puppet/version"
4
+ require "rubygems"
3
5
 
4
6
  desc "Clean workspace"
5
7
  task :clean do
@@ -20,6 +22,9 @@ task :test_integration do
20
22
 
21
23
  Dir["test/**/Rakefile"].each do |rf|
22
24
  supposed_to_fail = rf.include?("failing")
25
+ if rf.include?("future-parser")
26
+ supposed_to_fail = Gem::Version.new(Puppet.version) > Gem::Version.new('3.2.0')
27
+ end
23
28
  Dir.chdir rf.split("/")[0..-2].join("/")
24
29
 
25
30
  ["catalog:scenarios", "catalog:all"].each do |tc|
@@ -42,6 +42,10 @@ opt_parser = OptionParser.new do |opts|
42
42
  options[:custom_facts][k] = v
43
43
  end
44
44
 
45
+ opts.on("-p", "--parser (current|future)", "Change puppet parser (3.2+ only)") do |arg|
46
+ options[:parser] = arg
47
+ end
48
+
45
49
  opts.on("-v", "--verbose", "Verbose") do |arg|
46
50
  options[:verbose] = true
47
51
  end
@@ -68,6 +72,7 @@ pct = PuppetCatalogTest::TestRunner.new(
68
72
  :module_paths => options[:module_paths],
69
73
  :hiera_config => options[:hiera_config],
70
74
  :verbose => options[:verbose],
75
+ :parser => options[:parser],
71
76
  :xml => options[:xml])
72
77
 
73
78
  filter = PuppetCatalogTest::Filter.new
@@ -1,5 +1,5 @@
1
1
  module PuppetCatalogTest
2
- VERSION = "0.2.2"
2
+ VERSION = "0.4.1"
3
3
 
4
4
  DEFAULT_FILTER = /.*/
5
5
 
@@ -1,4 +1,5 @@
1
1
  require "puppet"
2
+ require "rubygems"
2
3
 
3
4
  module PuppetCatalogTest
4
5
  class Puppet3xAdapter < BasePuppetAdapter
@@ -6,9 +7,10 @@ module PuppetCatalogTest
6
7
  super(config)
7
8
 
8
9
  require 'puppet/test/test_helper'
10
+ parser = config[:parser]
9
11
 
10
- # works 3.7.x
11
- if version.start_with?("3.7.")
12
+ # initialize was added in 3.1.0
13
+ if Gem::Version.new(version) > Gem::Version.new('3.1.0')
12
14
  Puppet::Test::TestHelper.initialize
13
15
  end
14
16
 
@@ -19,6 +21,14 @@ module PuppetCatalogTest
19
21
  end
20
22
  end
21
23
 
24
+ # future parser was added in 3.2.0
25
+ if parser and Gem::Version.new(version) > Gem::Version.new('3.2.0')
26
+ parser_regex = /^(current|future)$/
27
+ raise ArgumentError, "[ERROR] parser (#{parser}) is not a valid parser, should be 'current' or 'future'" if !parser.match(parser_regex)
28
+ puts "[INFO] Using #{parser} puppet parser"
29
+ Puppet.settings[:parser] = parser
30
+ end
31
+
22
32
  Puppet.parse_config
23
33
  end
24
34
 
@@ -5,14 +5,15 @@ module PuppetCatalogTest
5
5
  class RakeTask < ::Rake::TaskLib
6
6
  include ::Rake::DSL if defined?(::Rake::DSL)
7
7
 
8
- attr_accessor :module_paths
9
- attr_accessor :manifest_path
10
8
  attr_accessor :config_dir
11
- attr_accessor :scenario_yaml
12
- attr_accessor :include_pattern
13
9
  attr_accessor :exclude_pattern
14
10
  attr_accessor :facts
11
+ attr_accessor :include_pattern
12
+ attr_accessor :manifest_path
13
+ attr_accessor :module_paths
14
+ attr_accessor :parser
15
15
  attr_accessor :reporter
16
+ attr_accessor :scenario_yaml
16
17
  attr_accessor :verbose
17
18
 
18
19
  def initialize(name, &task_block)
@@ -26,9 +27,10 @@ module PuppetCatalogTest
26
27
 
27
28
  def setup
28
29
  puppet_config = {
30
+ :config_dir => @config_dir,
29
31
  :manifest_path => @manifest_path,
30
32
  :module_paths => @module_paths,
31
- :config_dir => @config_dir,
33
+ :parser => @parser,
32
34
  :verbose => @verbose
33
35
  }
34
36
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'puppet-catalog-test'
3
- s.version = '0.4.0'
3
+ s.version = '0.4.1'
4
4
  s.homepage = 'https://github.com/invadersmustdie/puppet-catalog-test/'
5
5
  s.summary = 'Test all your puppet catalogs for compiler warnings and errors'
6
6
  s.description = 'Test all your puppet catalogs for compiler warnings and errors.'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-catalog-test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rene Lengwinat
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-27 00:00:00.000000000 Z
11
+ date: 2016-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puppet
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  version: '0'
96
96
  requirements: []
97
97
  rubyforge_project:
98
- rubygems_version: 2.4.5
98
+ rubygems_version: 2.5.1
99
99
  signing_key:
100
100
  specification_version: 4
101
101
  summary: Test all your puppet catalogs for compiler warnings and errors