Hello community,
here is the log from the commit of package rubygem-puppet-syntax for
openSUSE:Factory checked in at 2016-01-28 17:23:11
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-puppet-syntax (Old)
and /work/SRC/openSUSE:Factory/.rubygem-puppet-syntax.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-puppet-syntax"
Changes:
--------
---
/work/SRC/openSUSE:Factory/rubygem-puppet-syntax/rubygem-puppet-syntax.changes
2015-05-16 07:14:45.000000000 +0200
+++
/work/SRC/openSUSE:Factory/.rubygem-puppet-syntax.new/rubygem-puppet-syntax.changes
2016-01-28 17:23:55.000000000 +0100
@@ -1,0 +2,11 @@
+Fri Jan 22 17:46:06 UTC 2016 - [email protected]
+
+- Version bump 2.1.0
+ * Support Puppet 4. Many thanks to @DavidS
+ * Support validation of EPP templates. Thanks to @trlinkin
+ * Test improvements and refactoring, including Travis CI tests against
Puppet 4. Thanks to @trlinkin
+ * Don't error when a tag metaparameter is present. Thank you @dhardy92
+ * Report the filename of invalid hiera data files. Thanks @danzilio
+- run spec-cleaner
+
+-------------------------------------------------------------------
Old:
----
puppet-syntax-2.0.0.gem
New:
----
puppet-syntax-2.1.0.gem
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ rubygem-puppet-syntax.spec ++++++
--- /var/tmp/diff_new_pack.vmxVW4/_old 2016-01-28 17:23:56.000000000 +0100
+++ /var/tmp/diff_new_pack.vmxVW4/_new 2016-01-28 17:23:56.000000000 +0100
@@ -1,7 +1,7 @@
#
# spec file for package rubygem-puppet-syntax
#
-# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -15,20 +15,21 @@
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
-Name: rubygem-puppet-syntax
-Version: 2.0.0
-Release: 0
+
%define mod_name puppet-syntax
%define mod_full_name %{mod_name}-%{version}
-BuildRoot: %{_tmppath}/%{name}-%{version}-build
-BuildRequires: ruby-macros >= 5
-BuildRequires: %{ruby}
-BuildRequires: %{rubygem gem2rpm}
-Url: https://github.com/gds-operations/puppet-syntax
-Source: http://rubygems.org/gems/%{mod_full_name}.gem
+Name: rubygem-puppet-syntax
+Version: 2.1.0
+Release: 0
Summary: Syntax checks for Puppet manifests, templates, and Hiera YAML
License: MIT
Group: Development/Languages/Ruby
+Url: https://github.com/gds-operations/puppet-syntax
+Source: http://rubygems.org/gems/%{mod_full_name}.gem
+BuildRequires: %{rubygem gem2rpm}
+BuildRequires: %{ruby}
+BuildRequires: ruby-macros >= 5
+BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
Syntax checks for Puppet manifests and templates.
++++++ puppet-syntax-2.0.0.gem -> puppet-syntax-2.1.0.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/.travis.yml new/.travis.yml
--- old/.travis.yml 1970-01-01 01:00:00.000000000 +0100
+++ new/.travis.yml 1970-01-01 01:00:00.000000000 +0100
@@ -1,15 +1,27 @@
---
language: ruby
+# Workaround https://github.com/bundler/bundler/issues/3558
+before_install: gem install bundler
script: bundle exec rake
rvm:
- 1.9.3
+ - 2.1.6
env:
- PUPPET_VERSION="~> 3.0.0"
- PUPPET_VERSION="~> 3.1.0"
- PUPPET_VERSION="~> 3.2.0"
- PUPPET_VERSION="~> 3.4.0"
- PUPPET_VERSION="~> 3.7.3"
+ - PUPPET_VERSION="~> 4.2.0"
+ - PUPPET_VERSION="~> 4.3.0"
- PUPPET_VERSION=">= 0"
matrix:
+ exclude:
+ - rvm: 2.1.6
+ env: PUPPET_VERSION="~> 3.2.0"
+ - rvm: 2.1.6
+ env: PUPPET_VERSION="~> 3.1.0"
+ - rvm: 2.1.6
+ env: PUPPET_VERSION="~> 3.0.0"
allow_failures:
- env: PUPPET_VERSION=">= 0"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/CHANGELOG new/CHANGELOG
--- old/CHANGELOG 1970-01-01 01:00:00.000000000 +0100
+++ new/CHANGELOG 1970-01-01 01:00:00.000000000 +0100
@@ -1,3 +1,10 @@
+2016-01-18 Release 2.1.0
+- Support Puppet 4. Many thanks to @DavidS
+- Support validation of EPP templates. Thanks to @trlinkin
+- Test improvements and refactoring, including Travis CI tests against Puppet
4. Thanks to @trlinkin
+- Don't error when a tag metaparameter is present. Thank you @dhardy92
+- Report the filename of invalid hiera data files. Thanks @danzilio
+
2015-02-25 Release 2.0.0
- Removed support for Puppet version 2.7.x
- New option, fail_on_deprecation_notices, which defaults to true (compatible
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/puppet-syntax/hiera.rb
new/lib/puppet-syntax/hiera.rb
--- old/lib/puppet-syntax/hiera.rb 1970-01-01 01:00:00.000000000 +0100
+++ new/lib/puppet-syntax/hiera.rb 1970-01-01 01:00:00.000000000 +0100
@@ -11,7 +11,7 @@
begin
YAML.load_file(hiera_file)
rescue Exception => error
- errors << error
+ errors << "ERROR: Failed to parse #{hiera_file}: #{error}"
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/puppet-syntax/manifests.rb
new/lib/puppet-syntax/manifests.rb
--- old/lib/puppet-syntax/manifests.rb 1970-01-01 01:00:00.000000000 +0100
+++ new/lib/puppet-syntax/manifests.rb 1970-01-01 01:00:00.000000000 +0100
@@ -36,6 +36,11 @@
e =~ /^You cannot collect( exported resources)? without storeconfigs
being set/
}
+ # tag parameter in class raise warnings notice in output that prevent
from succeed
+ output.reject! { |e|
+ e =~ /^tag is a metaparam; this value will inherit to all contained
resources in the /
+ }
+
deprecations = output.select { |e|
e =~ /^Deprecation notice:|is deprecated/
}
@@ -48,7 +53,7 @@
private
def validate_manifest(file)
- Puppet[:parser] = 'future' if PuppetSyntax.future_parser
+ Puppet[:parser] = 'future' if PuppetSyntax.future_parser and
Puppet::PUPPETVERSION.to_i < 4
Puppet::Face[:parser, :current].validate(file)
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/puppet-syntax/tasks/puppet-syntax.rb
new/lib/puppet-syntax/tasks/puppet-syntax.rb
--- old/lib/puppet-syntax/tasks/puppet-syntax.rb 1970-01-01
01:00:00.000000000 +0100
+++ new/lib/puppet-syntax/tasks/puppet-syntax.rb 1970-01-01
01:00:00.000000000 +0100
@@ -30,6 +30,12 @@
desc 'Syntax check Puppet manifests'
task :manifests do |t|
+ if Puppet::PUPPETVERSION.to_i >= 4 and PuppetSyntax.future_parser
+ info <<-EOS
+[INFO] Puppet 4 has been detected and `future_parser` has been set to
+'true'. The `future_parser setting will be ignored.
+ EOS
+ end
$stderr.puts "---> #{t.name}"
files = FileList["**/*.pp"]
files.reject! { |f| File.directory?(f) }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/puppet-syntax/templates.rb
new/lib/puppet-syntax/templates.rb
--- old/lib/puppet-syntax/templates.rb 1970-01-01 01:00:00.000000000 +0100
+++ new/lib/puppet-syntax/templates.rb 1970-01-01 01:00:00.000000000 +0100
@@ -1,4 +1,5 @@
require 'erb'
+require 'puppet'
require 'stringio'
module PuppetSyntax
@@ -10,19 +11,11 @@
$stderr = warnings = StringIO.new()
errors = []
- filelist.each do |erb_file|
- begin
- erb = ERB.new(File.read(erb_file), nil, '-')
- erb.filename = erb_file
- erb.result
- rescue NameError
- # This is normal because we don't have the variables that would
- # ordinarily be bound by the parent Puppet manifest.
- rescue TypeError
- # This is normal because we don't have the variables that would
- # ordinarily be bound by the parent Puppet manifest.
- rescue SyntaxError => error
- errors << error
+ filelist.each do |file|
+ if File.extname(file) == '.epp' or PuppetSyntax.epp_only
+ errors.concat validate_epp(file)
+ else
+ errors.concat validate_erb(file)
end
end
@@ -32,5 +25,42 @@
errors
end
+
+ def validate_epp(filename)
+ if Puppet::PUPPETVERSION.to_i < 4
+ raise "Cannot validate EPP without Puppet 4"
+ end
+
+ require 'puppet/pops'
+ errors = []
+ begin
+ parser =
Puppet::Pops::Parser::EvaluatingParser::EvaluatingEppParser.new()
+ parser.parse_file(filename)
+ rescue => detail
+ errors << detail
+ end
+
+ errors
+ end
+
+ def validate_erb(filename)
+ errors = []
+
+ begin
+ erb = ERB.new(File.read(filename), nil, '-')
+ erb.filename = filename
+ erb.result
+ rescue NameError => error
+ # This is normal because we don't have the variables that would
+ # ordinarily be bound by the parent Puppet manifest.
+ rescue TypeError
+ # This is normal because we don't have the variables that would
+ # ordinarily be bound by the parent Puppet manifest.
+ rescue SyntaxError => error
+ errors << error
+ end
+
+ errors
+ end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/puppet-syntax/version.rb
new/lib/puppet-syntax/version.rb
--- old/lib/puppet-syntax/version.rb 1970-01-01 01:00:00.000000000 +0100
+++ new/lib/puppet-syntax/version.rb 1970-01-01 01:00:00.000000000 +0100
@@ -1,3 +1,3 @@
module PuppetSyntax
- VERSION = "2.0.0"
+ VERSION = "2.1.0"
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/puppet-syntax.rb new/lib/puppet-syntax.rb
--- old/lib/puppet-syntax.rb 1970-01-01 01:00:00.000000000 +0100
+++ new/lib/puppet-syntax.rb 1970-01-01 01:00:00.000000000 +0100
@@ -10,6 +10,6 @@
@fail_on_deprecation_notices = true
class << self
- attr_accessor :exclude_paths, :future_parser, :hieradata_paths,
:fail_on_deprecation_notices
+ attr_accessor :exclude_paths, :future_parser, :hieradata_paths,
:fail_on_deprecation_notices, :epp_only
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata 1970-01-01 01:00:00.000000000 +0100
+++ new/metadata 1970-01-01 01:00:00.000000000 +0100
@@ -1,7 +1,7 @@
--- !ruby/object:Gem::Specification
name: puppet-syntax
version: !ruby/object:Gem::Version
- version: 2.0.0
+ version: 2.1.0
prerelease:
platform: ruby
authors:
@@ -9,7 +9,7 @@
autorequire:
bindir: bin
cert_chain: []
-date: 2015-02-26 00:00:00.000000000 Z
+date: 2016-01-18 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: rake
@@ -90,9 +90,14 @@
- spec/fixtures/test_module/manifests/future_syntax.pp
- spec/fixtures/test_module/manifests/pass.pp
- spec/fixtures/test_module/manifests/pass_storeconfigs.pp
+- spec/fixtures/test_module/manifests/tag_notice.pp
+- spec/fixtures/test_module/templates/fail_error.epp
- spec/fixtures/test_module/templates/fail_error.erb
+- spec/fixtures/test_module/templates/fail_error_also.epp
- spec/fixtures/test_module/templates/fail_warning.erb
+- spec/fixtures/test_module/templates/pass.epp
- spec/fixtures/test_module/templates/pass.erb
+- spec/fixtures/test_module/templates/pass_also.epp
- spec/fixtures/test_module/templates/pass_unbound_var.erb
- spec/fixtures/test_module/templates/typeerror_shouldwin.erb
- spec/puppet-syntax/hiera_spec.rb
@@ -116,7 +121,7 @@
version: '0'
segments:
- 0
- hash: 2080509366784508245
+ hash: 1512611786751491860
required_rubygems_version: !ruby/object:Gem::Requirement
none: false
requirements:
@@ -125,7 +130,7 @@
version: '0'
segments:
- 0
- hash: 2080509366784508245
+ hash: 1512611786751491860
requirements: []
rubyforge_project:
rubygems_version: 1.8.23.2
@@ -142,9 +147,14 @@
- spec/fixtures/test_module/manifests/future_syntax.pp
- spec/fixtures/test_module/manifests/pass.pp
- spec/fixtures/test_module/manifests/pass_storeconfigs.pp
+- spec/fixtures/test_module/manifests/tag_notice.pp
+- spec/fixtures/test_module/templates/fail_error.epp
- spec/fixtures/test_module/templates/fail_error.erb
+- spec/fixtures/test_module/templates/fail_error_also.epp
- spec/fixtures/test_module/templates/fail_warning.erb
+- spec/fixtures/test_module/templates/pass.epp
- spec/fixtures/test_module/templates/pass.erb
+- spec/fixtures/test_module/templates/pass_also.epp
- spec/fixtures/test_module/templates/pass_unbound_var.erb
- spec/fixtures/test_module/templates/typeerror_shouldwin.erb
- spec/puppet-syntax/hiera_spec.rb
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/fixtures/test_module/manifests/tag_notice.pp
new/spec/fixtures/test_module/manifests/tag_notice.pp
--- old/spec/fixtures/test_module/manifests/tag_notice.pp 1970-01-01
01:00:00.000000000 +0100
+++ new/spec/fixtures/test_module/manifests/tag_notice.pp 1970-01-01
01:00:00.000000000 +0100
@@ -0,0 +1,5 @@
+class tag_parameter_test ($tag=undef){
+ notify { 'tag_should pass':
+ message => 'with flying colours',
+ }
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/fixtures/test_module/templates/fail_error.epp
new/spec/fixtures/test_module/templates/fail_error.epp
--- old/spec/fixtures/test_module/templates/fail_error.epp 1970-01-01
01:00:00.000000000 +0100
+++ new/spec/fixtures/test_module/templates/fail_error.epp 1970-01-01
01:00:00.000000000 +0100
@@ -0,0 +1,3 @@
+This is plain text
+<% This is not valid EPP %>
+This is also plain text
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/spec/fixtures/test_module/templates/fail_error_also.epp
new/spec/fixtures/test_module/templates/fail_error_also.epp
--- old/spec/fixtures/test_module/templates/fail_error_also.epp 1970-01-01
01:00:00.000000000 +0100
+++ new/spec/fixtures/test_module/templates/fail_error_also.epp 1970-01-01
01:00:00.000000000 +0100
@@ -0,0 +1,3 @@
+This is plain text
+<% } %>
+This is also plain text
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/fixtures/test_module/templates/pass.epp
new/spec/fixtures/test_module/templates/pass.epp
--- old/spec/fixtures/test_module/templates/pass.epp 1970-01-01
01:00:00.000000000 +0100
+++ new/spec/fixtures/test_module/templates/pass.epp 1970-01-01
01:00:00.000000000 +0100
@@ -0,0 +1,3 @@
+<%# VALID COMMENT %>
+<% $valid = 'valid' -%>
+This is a <%= $valid %> template.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/fixtures/test_module/templates/pass_also.epp
new/spec/fixtures/test_module/templates/pass_also.epp
--- old/spec/fixtures/test_module/templates/pass_also.epp 1970-01-01
01:00:00.000000000 +0100
+++ new/spec/fixtures/test_module/templates/pass_also.epp 1970-01-01
01:00:00.000000000 +0100
@@ -0,0 +1,3 @@
+<%# VALID COMMENT %>
+<% $valid = 'valid' -%>
+This is a <%= $valid %> template.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/puppet-syntax/hiera_spec.rb
new/spec/puppet-syntax/hiera_spec.rb
--- old/spec/puppet-syntax/hiera_spec.rb 1970-01-01 01:00:00.000000000
+0100
+++ new/spec/puppet-syntax/hiera_spec.rb 1970-01-01 01:00:00.000000000
+0100
@@ -14,14 +14,9 @@
end
it "should return an error from invalid YAML" do
- case RUBY_VERSION
- when /1.8/
- files = fixture_hiera('hiera_bad_18.yaml')
- expected = /syntax error on line 3, col -1: `'/
- else
- files = fixture_hiera('hiera_bad.yaml')
- expected = /scanning a directive at line 1 column 1/
- end
+ hiera_yaml = RUBY_VERSION =~ /1.8/ ? 'hiera_bad_18.yaml' : 'hiera_bad.yaml'
+ files = fixture_hiera(hiera_yaml)
+ expected = /ERROR: Failed to parse #{files[0]}:/
res = subject.check(files)
expect(res.size).to be == 1
expect(res.first).to match(expected)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/puppet-syntax/manifests_spec.rb
new/spec/puppet-syntax/manifests_spec.rb
--- old/spec/puppet-syntax/manifests_spec.rb 1970-01-01 01:00:00.000000000
+0100
+++ new/spec/puppet-syntax/manifests_spec.rb 1970-01-01 01:00:00.000000000
+0100
@@ -16,13 +16,27 @@
expect(has_errors).to eq(false)
end
+ it 'should return nothing from a valid file with a class using tag
parameter' do
+ files = fixture_manifests('tag_notice.pp')
+ output, has_errors = subject.check(files)
+
+ expect(output).to eq([])
+ expect(has_errors).to eq(false)
+ end
+
it 'should return an error from an invalid file' do
files = fixture_manifests('fail_error.pp')
output, has_errors = subject.check(files)
- expect(output.size).to eq(1)
- expect(output[0]).to match(/Syntax error at .*:3$/)
- expect(has_errors).to eq(true)
+ if Puppet::PUPPETVERSION.to_i >= 4
+ expect(output.size).to eq(3)
+ expect(output[2]).to match(/Found 2 errors. Giving up/)
+ expect(has_errors).to eq(true)
+ else
+ expect(output.size).to eq(1)
+ expect(output[0]).to match(/Syntax error at .*:3$/)
+ expect(has_errors).to eq(true)
+ end
end
it 'should return a warning from an invalid file' do
@@ -30,9 +44,10 @@
output, has_errors = subject.check(files)
expect(output.size).to eq(2)
- expect(output[0]).to match(/Unrecognised escape sequence '\\\[' .* at line
3$/)
- expect(output[1]).to match(/Unrecognised escape sequence '\\\]' .* at line
3$/)
expect(has_errors).to eq(true)
+
+ expect(output[0]).to match(/Unrecogni(s|z)ed escape sequence '\\\['/)
+ expect(output[1]).to match(/Unrecogni(s|z)ed escape sequence '\\\]'/)
end
it 'should ignore warnings about storeconfigs' do
@@ -56,18 +71,37 @@
files = fixture_manifests(['fail_error.pp', 'fail_warning.pp'])
output, has_errors = subject.check(files)
- expect(output.size).to eq(3)
- expect(output[0]).to match(/Syntax error at '\}' .*:3$/)
- expect(output[1]).to match(/Unrecognised escape sequence '\\\[' .* at line
3$/)
- expect(output[2]).to match(/Unrecognised escape sequence '\\\]' .* at line
3$/)
expect(has_errors).to eq(true)
+ if Puppet::PUPPETVERSION.to_i >= 4
+ expect(output.size).to eq(5)
+ expect(output[0]).to match(/This Name has no effect. A Host Class
Definition can not end with a value-producing expression without other effect
at \S*\/fail_error.pp:2:32$/)
+ expect(output[1]).to match(/This Name has no effect. A value(-producing
expression without other effect may only be placed last in a block\/sequence|
was produced and then forgotten.*) at \S*\/fail_error.pp:2:3$/)
+ expect(output[2]).to match('Found 2 errors. Giving up')
+ expect(output[3]).to match(/Unrecogni(s|z)ed escape sequence '\\\['/)
+ expect(output[4]).to match(/Unrecogni(s|z)ed escape sequence '\\\]'/)
+ else
+ expect(output.size).to eq(3)
+ expect(output[0]).to match(/Syntax error at '\}' .*:3$/)
+ expect(output[1]).to match(/Unrecogni(s|z)ed escape sequence '\\\['/)
+ expect(output[2]).to match(/Unrecogni(s|z)ed escape sequence '\\\]'/)
+ end
end
describe 'deprecation notices' do
- # These tests should fail in Puppet 4, but we need to wait for the release
- # before we'll know exactly how to test it.
- if Puppet::Util::Package.versioncmp(Puppet.version, '3.7') >= 0
- context 'on puppet >= 3.7' do
+ case Puppet.version.to_f
+ when 4.0..4.99
+ context 'on puppet 4.0.0 and above' do
+ it 'should instead be failures' do
+ files = fixture_manifests('deprecation_notice.pp')
+ output, has_errors = subject.check(files)
+
+ expect(has_errors).to eq(true)
+ expect(output.size).to eq(1)
+ expect(output[0]).to match (/Node inheritance is not supported in
Puppet >= 4.0.0/)
+ end
+ end
+ when 3.7, 3.8
+ context 'on puppet 3.7 and 3.8' do
it 'should return deprecation notices as warnings' do
files = fixture_manifests('deprecation_notice.pp')
output, has_errors = subject.check(files)
@@ -78,7 +112,7 @@
expect(output[1]).to match(/Deprecation notice:/)
end
end
- elsif Puppet::Util::Package.versioncmp(Puppet.version, '3.5') >= 0
+ when 3.5, 3.6
context 'on puppet 3.5 and 3.6' do
it 'should return deprecation notices as warnings' do
files = fixture_manifests('deprecation_notice.pp')
@@ -89,8 +123,8 @@
expect(output[0]).to match(/The use of 'import' is deprecated/)
end
end
- elsif Puppet::Util::Package.versioncmp(Puppet.version, '3.5') < 0
- context 'on puppet < 3.5' do
+ when 3.0..3.4
+ context 'on puppet 3.0 to 3.4' do
it 'should not print deprecation notices' do
files = fixture_manifests('deprecation_notice.pp')
output, has_errors = subject.check(files)
@@ -104,15 +138,27 @@
describe 'future_parser' do
context 'future_parser = false (default)' do
- it 'should fail without setting future option to true on future
manifest' do
- expect(PuppetSyntax.future_parser).to eq(false)
+ if Puppet::Util::Package.versioncmp(Puppet.version, '4.0') < 0
+ it 'should fail without setting future option to true on future
manifest on Puppet < 4.0.0' do
+ expect(PuppetSyntax.future_parser).to eq(false)
- files = fixture_manifests(['future_syntax.pp'])
- output, has_errors = subject.check(files)
+ files = fixture_manifests(['future_syntax.pp'])
+ output, has_errors = subject.check(files)
- expect(output.size).to eq(1)
- expect(output[0]).to match(/Syntax error at '='; expected '\}' .*:2$/)
- expect(has_errors).to eq(true)
+ expect(output.size).to eq(1)
+ expect(output[0]).to match(/Syntax error at '='; expected '\}'
.*:2$/)
+ expect(has_errors).to eq(true)
+ end
+ else
+ it 'should succeed on Puppet >= 4.0.0' do
+ expect(PuppetSyntax.future_parser).to eq(false)
+
+ files = fixture_manifests(['future_syntax.pp'])
+ output, has_errors = subject.check(files)
+
+ expect(output.size).to eq(0)
+ expect(has_errors).to eq(false)
+ end
end
end
@@ -121,8 +167,8 @@
PuppetSyntax.future_parser = true
}
- if Puppet::Util::Package.versioncmp(Puppet.version, '3.2') >= 0
- context 'Puppet >= 3.2' do
+ if Puppet::Util::Package.versioncmp(Puppet.version, '3.2') >= 0 and
Puppet::PUPPETVERSION.to_i < 4
+ context 'Puppet >= 3.2 < 4' do
it 'should pass with future option set to true on future manifest' do
files = fixture_manifests(['future_syntax.pp'])
output, has_errors = subject.check(files)
@@ -131,7 +177,7 @@
expect(has_errors).to eq(false)
end
end
- context 'Puppet >= 3.7' do
+ context 'Puppet >= 3.7 < 4' do
# Certain elements of the future parser weren't added until 3.7
if Puppet::Util::Package.versioncmp(Puppet.version, '3.7') >= 0
it 'should fail on what were deprecation notices in the non-future
parser' do
@@ -144,7 +190,7 @@
end
end
end
- else
+ elsif Puppet::Util::Package.versioncmp(Puppet.version, '3.2') < 0
context 'Puppet < 3.2' do
it 'should return an error that the parser option is not supported'
do
files = fixture_manifests(['future_syntax.pp'])
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/puppet-syntax/tasks/puppet-syntax_spec.rb
new/spec/puppet-syntax/tasks/puppet-syntax_spec.rb
--- old/spec/puppet-syntax/tasks/puppet-syntax_spec.rb 1970-01-01
01:00:00.000000000 +0100
+++ new/spec/puppet-syntax/tasks/puppet-syntax_spec.rb 1970-01-01
01:00:00.000000000 +0100
@@ -1,4 +1,5 @@
require 'spec_helper'
+require 'puppet-syntax/tasks/puppet-syntax'
describe 'PuppetSyntax rake tasks' do
it 'should generate FileList of manifests relative to Rakefile' do
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/puppet-syntax/templates_spec.rb
new/spec/puppet-syntax/templates_spec.rb
--- old/spec/puppet-syntax/templates_spec.rb 1970-01-01 01:00:00.000000000
+0100
+++ new/spec/puppet-syntax/templates_spec.rb 1970-01-01 01:00:00.000000000
+0100
@@ -59,4 +59,72 @@
expect(res).to match([])
end
+
+ if Puppet::PUPPETVERSION.to_i < 4
+ context 'on Puppet < 4.0.0' do
+ it 'should throw an exception when parsing EPP files' do
+ file = fixture_templates('pass.epp')
+ expect{ subject.check(file) }.to raise_error(/Cannot validate EPP
without Puppet 4/)
+ end
+
+ context "when the 'epp_only' options is set" do
+ before(:each) {
+ PuppetSyntax.epp_only = true
+ }
+
+ it 'should throw an exception for any file' do
+ file = fixture_templates('pass.erb')
+ expect{ subject.check(file) }.to raise_error(/Cannot validate EPP
without Puppet 4/)
+ end
+ end
+ end
+ end
+
+ if Puppet::PUPPETVERSION.to_i >= 4
+ context 'on Puppet >= 4.0.0' do
+ it 'should return nothing from a valid file' do
+ files = fixture_templates('pass.epp')
+ res = subject.check(files)
+
+ expect(res).to match([])
+ end
+
+ it 'should catch SyntaxError' do
+ files = fixture_templates('fail_error.epp')
+ res = subject.check(files)
+
+ expect(res.size).to eq(1)
+ expect(res[0]).to match(/This Type-Name has no effect/)
+ end
+
+ it 'should read more than one valid file' do
+ files = fixture_templates(['pass.epp', 'pass_also.epp'])
+ res = subject.check(files)
+
+ expect(res).to match([])
+ end
+
+ it 'should continue after finding an error in the first file' do
+ files = fixture_templates(['fail_error.epp', 'fail_error_also.epp'])
+ res = subject.check(files)
+
+ expect(res.size).to eq(2)
+ expect(res[0]).to match(/This Type-Name has no effect/)
+ expect(res[1]).to match(/Syntax error at '}' at
\S*\/fail_error_also.epp:2:4/)
+ end
+
+ context "when the 'epp_only' options is set" do
+ before(:each) {
+ PuppetSyntax.epp_only = true
+ }
+
+ it 'should process an ERB as EPP and find an error' do
+ files = fixture_templates('pass.erb')
+ res = subject.check(files)
+
+ expect(res.size).to eq(1)
+ end
+ end
+ end
+ end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/puppet-syntax_spec.rb
new/spec/puppet-syntax_spec.rb
--- old/spec/puppet-syntax_spec.rb 1970-01-01 01:00:00.000000000 +0100
+++ new/spec/puppet-syntax_spec.rb 1970-01-01 01:00:00.000000000 +0100
@@ -29,4 +29,9 @@
expect(PuppetSyntax.fail_on_deprecation_notices).to eq(false)
end
+ it 'should support forcing EPP only templates' do
+ PuppetSyntax.epp_only = true
+ expect(PuppetSyntax.epp_only).to eq(true)
+ end
+
end