summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.sync.yml9
-rw-r--r--.travis.yml2
-rw-r--r--Gemfile72
-rw-r--r--Rakefile41
-rw-r--r--lib/puppet/parser/functions/parseyaml.rb5
-rwxr-xr-xspec/functions/get_module_path_spec.rb6
-rw-r--r--spec/puppetlabs_spec_helper_clone.rb34
-rw-r--r--spec/spec.opts6
-rwxr-xr-xspec/spec_helper.rb51
-rw-r--r--spec/spec_helper_local.rb29
10 files changed, 103 insertions, 152 deletions
diff --git a/.sync.yml b/.sync.yml
deleted file mode 100644
index 21e872e..0000000
--- a/.sync.yml
+++ /dev/null
@@ -1,9 +0,0 @@
----
-.travis.yml:
- script: "\"bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--color --format documentation'\""
-Rakefile:
- unmanaged: true
-Gemfile:
- unmanaged: true
-spec/spec_helper.rb:
- unmanaged: true
diff --git a/.travis.yml b/.travis.yml
index 1f22c6c..588fb5b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,7 +4,7 @@ sudo: false
language: ruby
cache: bundler
bundler_args: --without system_tests
-script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--color --format documentation'"
+script: "bundle exec rake validate lint spec"
matrix:
fast_finish: true
include:
diff --git a/Gemfile b/Gemfile
index 8221514..e490bc9 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,61 +1,39 @@
-source ENV['GEM_SOURCE'] || 'https://rubygems.org'
+#This file is generated by ModuleSync, do not edit.
-def location_for(place, fake_version = nil)
+source ENV['GEM_SOURCE'] || "https://rubygems.org"
+
+def location_for(place, version = nil)
if place =~ /^(git[:@][^#]*)#(.*)/
- [fake_version, { :git => $1, :branch => $2, :require => false }].compact
+ [version, { :git => $1, :branch => $2, :require => false}].compact
elsif place =~ /^file:\/\/(.*)/
- ['>= 0', { :path => File.expand_path($1), :require => false }]
+ ['>= 0', { :path => File.expand_path($1), :require => false}]
else
- [place, { :require => false }]
+ [place, version, { :require => false}].compact
end
end
group :development, :unit_tests do
- # rspec must be v2 for ruby 1.8.7
- if RUBY_VERSION >= '1.8.7' and RUBY_VERSION < '1.9'
- gem 'rspec', '~> 2.0'
- else
- gem 'rspec', '~> 3.1.0', :require => false
- end
-
- gem 'rake', '~> 10.1.0', :require => false
- gem 'rspec-puppet', '~> 2.2', :require => false
- gem 'mocha', :require => false
- # keep for its rake task for now
- gem 'puppetlabs_spec_helper', :require => false
- gem 'puppet-lint', :require => false
- gem 'metadata-json-lint', :require => false
- gem 'pry', :require => false
- gem 'simplecov', :require => false
+ gem 'json', :require => false
+ gem 'metadata-json-lint', :require => false
+ gem 'puppet_facts', :require => false
+ gem 'puppet-blacksmith', :require => false
+ gem 'puppetlabs_spec_helper', :require => false
+ gem 'rspec-puppet', '>= 2.3.2', :require => false
+ gem 'simplecov', :require => false
end
-
-beaker_version = ENV['BEAKER_VERSION']
-beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION']
group :system_tests do
- if beaker_version
- gem 'beaker', *location_for(beaker_version)
- end
- if beaker_rspec_version
- gem 'beaker-rspec', *location_for(beaker_rspec_version)
- else
- gem 'beaker-rspec', :require => false
- end
- gem 'serverspec', :require => false
- gem 'beaker-puppet_install_helper', :require => false
+ gem 'beaker-rspec', *location_for(ENV['BEAKER_RSPEC_VERSION'] || '>= 3.4')
+ gem 'beaker', *location_for(ENV['BEAKER_VERSION'])
+ gem 'serverspec', :require => false
+ gem 'beaker-puppet_install_helper', :require => false
+ gem 'master_manipulator', :require => false
+ gem 'beaker-hostgenerator', *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION'])
end
-facterversion = ENV['GEM_FACTER_VERSION'] || ENV['FACTER_GEM_VERSION']
-if facterversion
- gem 'facter', *location_for(facterversion)
-else
- gem 'facter', :require => false
-end
+gem 'facter', *location_for(ENV['FACTER_GEM_VERSION'])
+gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION'])
-puppetversion = ENV['GEM_PUPPET_VERSION'] || ENV['PUPPET_GEM_VERSION']
-if puppetversion
- gem 'puppet', *location_for(puppetversion)
-else
- gem 'puppet', :require => false
-end
-# vim:ft=ruby
+if File.exists? "#{__FILE__}.local"
+ eval(File.read("#{__FILE__}.local"), binding)
+end
diff --git a/Rakefile b/Rakefile
index e136b8e..7e9a13d 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,7 +1,42 @@
-require 'rubygems'
-# keep for compatibility for now
-require 'puppetlabs_spec_helper/rake_tasks'
+require 'puppet_blacksmith/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
+require 'puppetlabs_spec_helper/rake_tasks'
+
+PuppetLint.configuration.fail_on_warnings = true
+PuppetLint.configuration.send('relative')
PuppetLint.configuration.send('disable_80chars')
+PuppetLint.configuration.send('disable_class_inherits_from_params_class')
+PuppetLint.configuration.send('disable_documentation')
+PuppetLint.configuration.send('disable_single_quote_string_with_variables')
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
+desc 'Generate pooler nodesets'
+task :gen_nodeset do
+ require 'beaker-hostgenerator'
+ require 'securerandom'
+ require 'fileutils'
+
+ agent_target = ENV['TEST_TARGET']
+ if ! agent_target
+ STDERR.puts 'TEST_TARGET environment variable is not set'
+ STDERR.puts 'setting to default value of "redhat-64default."'
+ agent_target = 'redhat-64default.'
+ end
+
+ master_target = ENV['MASTER_TEST_TARGET']
+ if ! master_target
+ STDERR.puts 'MASTER_TEST_TARGET environment variable is not set'
+ STDERR.puts 'setting to default value of "redhat7-64mdcl"'
+ master_target = 'redhat7-64mdcl'
+ end
+
+ targets = "#{master_target}-#{agent_target}"
+ cli = BeakerHostGenerator::CLI.new([targets])
+ nodeset_dir = "tmp/nodesets"
+ nodeset = "#{nodeset_dir}/#{targets}-#{SecureRandom.uuid}.yaml"
+ FileUtils.mkdir_p(nodeset_dir)
+ File.open(nodeset, 'w') do |fh|
+ fh.print(cli.execute)
+ end
+ puts nodeset
+end
diff --git a/lib/puppet/parser/functions/parseyaml.rb b/lib/puppet/parser/functions/parseyaml.rb
index 9e84055..ba9d98a 100644
--- a/lib/puppet/parser/functions/parseyaml.rb
+++ b/lib/puppet/parser/functions/parseyaml.rb
@@ -16,7 +16,10 @@ be returned if the parsing of YAML string have failed.
begin
YAML::load(arguments[0]) || arguments[1]
- rescue StandardError => e
+ # in ruby 1.9.3 Psych::SyntaxError is a RuntimeException
+ # this still needs to catch that and work also on rubies that
+ # do not have Psych available.
+ rescue StandardError, Psych::SyntaxError => e
if arguments[1]
arguments[1]
else
diff --git a/spec/functions/get_module_path_spec.rb b/spec/functions/get_module_path_spec.rb
index b1f682f..a39e413 100755
--- a/spec/functions/get_module_path_spec.rb
+++ b/spec/functions/get_module_path_spec.rb
@@ -5,11 +5,7 @@ describe 'get_module_path' do
it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /Wrong number of arguments, expects one/) }
it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /Wrong number of arguments, expects one/) }
it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError, /Wrong number of arguments, expects one/) }
- if Puppet.version.to_f >= 4.0
- it { is_expected.to run.with_params('one').and_raise_error(Puppet::Environments::EnvironmentNotFound, /Could not find a directory environment/) }
- else
- it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /Could not find module/) }
- end
+ it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /Could not find module/) }
class StubModule
attr_reader :path
diff --git a/spec/puppetlabs_spec_helper_clone.rb b/spec/puppetlabs_spec_helper_clone.rb
deleted file mode 100644
index 6a94a3b..0000000
--- a/spec/puppetlabs_spec_helper_clone.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-#This file pulls in only the minimum necessary to let unmigrated specs still work
-
-# Define the main module namespace for use by the helper modules
-module PuppetlabsSpec
- # FIXTURE_DIR represents the standard locations of all fixture data. Normally
- # this represents <project>/spec/fixtures. This will be used by the fixtures
- # library to find relative fixture data.
- FIXTURE_DIR = File.join("spec", "fixtures") unless defined?(FIXTURE_DIR)
-end
-
-# Require all necessary helper libraries so they can be used later
-require 'puppetlabs_spec_helper/puppetlabs_spec/files'
-require 'puppetlabs_spec_helper/puppetlabs_spec/fixtures'
-#require 'puppetlabs_spec_helper/puppetlabs_spec/puppet_internals'
-require 'puppetlabs_spec_helper/puppetlabs_spec/matchers'
-
-RSpec.configure do |config|
- # Include PuppetlabsSpec helpers so they can be called at convenience
- config.extend PuppetlabsSpec::Files
- config.extend PuppetlabsSpec::Fixtures
- config.include PuppetlabsSpec::Fixtures
-
- config.parser = 'future' if ENV['FUTURE_PARSER'] == 'yes'
- config.strict_variables = true if ENV['STRICT_VARIABLES'] == 'yes'
- config.stringify_facts = false if ENV['STRINGIFY_FACTS'] == 'no'
- config.trusted_node_data = true if ENV['TRUSTED_NODE_DATA'] == 'yes'
- config.ordering = ENV['ORDERING'] if ENV['ORDERING']
-
- # This will cleanup any files that were created with tmpdir or tmpfile
- config.after :each do
- PuppetlabsSpec::Files.cleanup
- end
-end
-
diff --git a/spec/spec.opts b/spec/spec.opts
deleted file mode 100644
index 91cd642..0000000
--- a/spec/spec.opts
+++ /dev/null
@@ -1,6 +0,0 @@
---format
-s
---colour
---loadby
-mtime
---backtrace
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 416036b..22d5d68 100755
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,49 +1,8 @@
-#! /usr/bin/env ruby -S rspec
-dir = File.expand_path(File.dirname(__FILE__))
-$LOAD_PATH.unshift File.join(dir, 'lib')
-
-# So everyone else doesn't have to include this base constant.
-module PuppetSpec
- FIXTURE_DIR = File.join(dir = File.expand_path(File.dirname(__FILE__)), "fixtures") unless defined?(FIXTURE_DIR)
-end
-
-require 'puppet'
-require 'rspec-puppet'
+#This file is generated by ModuleSync, do not edit.
require 'puppetlabs_spec_helper/module_spec_helper'
-require 'monkey_patches/alias_should_to_must'
-require 'mocha/api'
-#require 'puppetlabs_spec_helper/module_spec_helper'
-require 'puppetlabs_spec_helper_clone'
-
-# hack to enable all the expect syntax (like allow_any_instance_of) in rspec-puppet examples
-RSpec::Mocks::Syntax.enable_expect(RSpec::Puppet::ManifestMatchers)
-
-RSpec.configure do |config|
- config.module_path = File.join(File.dirname(File.expand_path(__FILE__)), 'fixtures', 'modules')
- config.manifest_dir = File.join(File.dirname(File.expand_path(__FILE__)), 'fixtures', 'manifests')
- config.environmentpath = spec_path = File.expand_path(File.join(Dir.pwd, 'spec'))
-
- config.add_setting :puppet_future
- #config.puppet_future = (ENV['FUTURE_PARSER'] == 'yes' or Puppet.version.to_f >= 4.0)
- config.puppet_future = Puppet.version.to_f >= 4.0
-
- config.before :each do
- # Ensure that we don't accidentally cache facts and environment between
- # test cases. This requires each example group to explicitly load the
- # facts being exercised with something like
- # Facter.collection.loader.load(:ipaddress)
- Facter.clear
- Facter.clear_messages
-
- RSpec::Mocks.setup
- end
-
- config.after :each do
- RSpec::Mocks.verify
- RSpec::Mocks.teardown
- end
-end
-# Helper class to test handling of arguments which are derived from string
-class AlsoString < String
+# put local configuration and setup into spec_helper_local
+begin
+ require 'spec_helper_local'
+rescue LoadError
end
diff --git a/spec/spec_helper_local.rb b/spec/spec_helper_local.rb
new file mode 100644
index 0000000..023a862
--- /dev/null
+++ b/spec/spec_helper_local.rb
@@ -0,0 +1,29 @@
+
+# hack to enable all the expect syntax (like allow_any_instance_of) in rspec-puppet examples
+RSpec::Mocks::Syntax.enable_expect(RSpec::Puppet::ManifestMatchers)
+
+RSpec.configure do |config|
+ # supply tests with a possibility to test for the future parser
+ config.add_setting :puppet_future
+ config.puppet_future = Puppet.version.to_f >= 4.0
+
+ config.before :each do
+ # Ensure that we don't accidentally cache facts and environment between
+ # test cases. This requires each example group to explicitly load the
+ # facts being exercised with something like
+ # Facter.collection.loader.load(:ipaddress)
+ Facter.clear
+ Facter.clear_messages
+
+ RSpec::Mocks.setup
+ end
+
+ config.after :each do
+ RSpec::Mocks.verify
+ RSpec::Mocks.teardown
+ end
+end
+
+# Helper class to test handling of arguments which are derived from string
+class AlsoString < String
+end