Skip to content

Commit 0624c3f

Browse files
committed
Merge pull request #589 from puppetlabs/modulesync-update
Multiple updates to stdlib and its testsuite
2 parents c5486ab + 5639828 commit 0624c3f

File tree

10 files changed

+103
-152
lines changed

10 files changed

+103
-152
lines changed

.sync.yml

-9
This file was deleted.

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sudo: false
44
language: ruby
55
cache: bundler
66
bundler_args: --without system_tests
7-
script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--color --format documentation'"
7+
script: "bundle exec rake validate lint spec"
88
matrix:
99
fast_finish: true
1010
include:

Gemfile

+25-47
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,39 @@
1-
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
1+
#This file is generated by ModuleSync, do not edit.
22

3-
def location_for(place, fake_version = nil)
3+
source ENV['GEM_SOURCE'] || "https://rubygems.org"
4+
5+
def location_for(place, version = nil)
46
if place =~ /^(git[:@][^#]*)#(.*)/
5-
[fake_version, { :git => $1, :branch => $2, :require => false }].compact
7+
[version, { :git => $1, :branch => $2, :require => false}].compact
68
elsif place =~ /^file:\/\/(.*)/
7-
['>= 0', { :path => File.expand_path($1), :require => false }]
9+
['>= 0', { :path => File.expand_path($1), :require => false}]
810
else
9-
[place, { :require => false }]
11+
[place, version, { :require => false}].compact
1012
end
1113
end
1214

1315
group :development, :unit_tests do
14-
# rspec must be v2 for ruby 1.8.7
15-
if RUBY_VERSION >= '1.8.7' and RUBY_VERSION < '1.9'
16-
gem 'rspec', '~> 2.0'
17-
else
18-
gem 'rspec', '~> 3.1.0', :require => false
19-
end
20-
21-
gem 'rake', '~> 10.1.0', :require => false
22-
gem 'rspec-puppet', '~> 2.2', :require => false
23-
gem 'mocha', :require => false
24-
# keep for its rake task for now
25-
gem 'puppetlabs_spec_helper', :require => false
26-
gem 'puppet-lint', :require => false
27-
gem 'metadata-json-lint', :require => false
28-
gem 'pry', :require => false
29-
gem 'simplecov', :require => false
16+
gem 'json', :require => false
17+
gem 'metadata-json-lint', :require => false
18+
gem 'puppet_facts', :require => false
19+
gem 'puppet-blacksmith', :require => false
20+
gem 'puppetlabs_spec_helper', :require => false
21+
gem 'rspec-puppet', '>= 2.3.2', :require => false
22+
gem 'simplecov', :require => false
3023
end
31-
32-
beaker_version = ENV['BEAKER_VERSION']
33-
beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION']
3424
group :system_tests do
35-
if beaker_version
36-
gem 'beaker', *location_for(beaker_version)
37-
end
38-
if beaker_rspec_version
39-
gem 'beaker-rspec', *location_for(beaker_rspec_version)
40-
else
41-
gem 'beaker-rspec', :require => false
42-
end
43-
gem 'serverspec', :require => false
44-
gem 'beaker-puppet_install_helper', :require => false
25+
gem 'beaker-rspec', *location_for(ENV['BEAKER_RSPEC_VERSION'] || '>= 3.4')
26+
gem 'beaker', *location_for(ENV['BEAKER_VERSION'])
27+
gem 'serverspec', :require => false
28+
gem 'beaker-puppet_install_helper', :require => false
29+
gem 'master_manipulator', :require => false
30+
gem 'beaker-hostgenerator', *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION'])
4531
end
4632

47-
facterversion = ENV['GEM_FACTER_VERSION'] || ENV['FACTER_GEM_VERSION']
48-
if facterversion
49-
gem 'facter', *location_for(facterversion)
50-
else
51-
gem 'facter', :require => false
52-
end
33+
gem 'facter', *location_for(ENV['FACTER_GEM_VERSION'])
34+
gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION'])
5335

54-
puppetversion = ENV['GEM_PUPPET_VERSION'] || ENV['PUPPET_GEM_VERSION']
55-
if puppetversion
56-
gem 'puppet', *location_for(puppetversion)
57-
else
58-
gem 'puppet', :require => false
59-
end
6036

61-
# vim:ft=ruby
37+
if File.exists? "#{__FILE__}.local"
38+
eval(File.read("#{__FILE__}.local"), binding)
39+
end

Rakefile

+38-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,42 @@
1-
require 'rubygems'
2-
# keep for compatibility for now
3-
require 'puppetlabs_spec_helper/rake_tasks'
1+
require 'puppet_blacksmith/rake_tasks'
42
require 'puppet-lint/tasks/puppet-lint'
3+
require 'puppetlabs_spec_helper/rake_tasks'
4+
5+
PuppetLint.configuration.fail_on_warnings = true
6+
PuppetLint.configuration.send('relative')
57
PuppetLint.configuration.send('disable_80chars')
8+
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
9+
PuppetLint.configuration.send('disable_documentation')
10+
PuppetLint.configuration.send('disable_single_quote_string_with_variables')
611
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
712

13+
desc 'Generate pooler nodesets'
14+
task :gen_nodeset do
15+
require 'beaker-hostgenerator'
16+
require 'securerandom'
17+
require 'fileutils'
18+
19+
agent_target = ENV['TEST_TARGET']
20+
if ! agent_target
21+
STDERR.puts 'TEST_TARGET environment variable is not set'
22+
STDERR.puts 'setting to default value of "redhat-64default."'
23+
agent_target = 'redhat-64default.'
24+
end
25+
26+
master_target = ENV['MASTER_TEST_TARGET']
27+
if ! master_target
28+
STDERR.puts 'MASTER_TEST_TARGET environment variable is not set'
29+
STDERR.puts 'setting to default value of "redhat7-64mdcl"'
30+
master_target = 'redhat7-64mdcl'
31+
end
32+
33+
targets = "#{master_target}-#{agent_target}"
34+
cli = BeakerHostGenerator::CLI.new([targets])
35+
nodeset_dir = "tmp/nodesets"
36+
nodeset = "#{nodeset_dir}/#{targets}-#{SecureRandom.uuid}.yaml"
37+
FileUtils.mkdir_p(nodeset_dir)
38+
File.open(nodeset, 'w') do |fh|
39+
fh.print(cli.execute)
40+
end
41+
puts nodeset
42+
end

lib/puppet/parser/functions/parseyaml.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ module Puppet::Parser::Functions
1616

1717
begin
1818
YAML::load(arguments[0]) || arguments[1]
19-
rescue StandardError => e
19+
# in ruby 1.9.3 Psych::SyntaxError is a RuntimeException
20+
# this still needs to catch that and work also on rubies that
21+
# do not have Psych available.
22+
rescue StandardError, Psych::SyntaxError => e
2023
if arguments[1]
2124
arguments[1]
2225
else

spec/functions/get_module_path_spec.rb

+1-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55
it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /Wrong number of arguments, expects one/) }
66
it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /Wrong number of arguments, expects one/) }
77
it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError, /Wrong number of arguments, expects one/) }
8-
if Puppet.version.to_f >= 4.0
9-
it { is_expected.to run.with_params('one').and_raise_error(Puppet::Environments::EnvironmentNotFound, /Could not find a directory environment/) }
10-
else
11-
it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /Could not find module/) }
12-
end
8+
it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /Could not find module/) }
139

1410
class StubModule
1511
attr_reader :path

spec/puppetlabs_spec_helper_clone.rb

-34
This file was deleted.

spec/spec.opts

-6
This file was deleted.

spec/spec_helper.rb

+5-46
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,8 @@
1-
#! /usr/bin/env ruby -S rspec
2-
dir = File.expand_path(File.dirname(__FILE__))
3-
$LOAD_PATH.unshift File.join(dir, 'lib')
4-
5-
# So everyone else doesn't have to include this base constant.
6-
module PuppetSpec
7-
FIXTURE_DIR = File.join(dir = File.expand_path(File.dirname(__FILE__)), "fixtures") unless defined?(FIXTURE_DIR)
8-
end
9-
10-
require 'puppet'
11-
require 'rspec-puppet'
1+
#This file is generated by ModuleSync, do not edit.
122
require 'puppetlabs_spec_helper/module_spec_helper'
13-
require 'monkey_patches/alias_should_to_must'
14-
require 'mocha/api'
15-
#require 'puppetlabs_spec_helper/module_spec_helper'
16-
require 'puppetlabs_spec_helper_clone'
17-
18-
# hack to enable all the expect syntax (like allow_any_instance_of) in rspec-puppet examples
19-
RSpec::Mocks::Syntax.enable_expect(RSpec::Puppet::ManifestMatchers)
20-
21-
RSpec.configure do |config|
22-
config.module_path = File.join(File.dirname(File.expand_path(__FILE__)), 'fixtures', 'modules')
23-
config.manifest_dir = File.join(File.dirname(File.expand_path(__FILE__)), 'fixtures', 'manifests')
24-
config.environmentpath = spec_path = File.expand_path(File.join(Dir.pwd, 'spec'))
25-
26-
config.add_setting :puppet_future
27-
#config.puppet_future = (ENV['FUTURE_PARSER'] == 'yes' or Puppet.version.to_f >= 4.0)
28-
config.puppet_future = Puppet.version.to_f >= 4.0
29-
30-
config.before :each do
31-
# Ensure that we don't accidentally cache facts and environment between
32-
# test cases. This requires each example group to explicitly load the
33-
# facts being exercised with something like
34-
# Facter.collection.loader.load(:ipaddress)
35-
Facter.clear
36-
Facter.clear_messages
37-
38-
RSpec::Mocks.setup
39-
end
40-
41-
config.after :each do
42-
RSpec::Mocks.verify
43-
RSpec::Mocks.teardown
44-
end
45-
end
463

47-
# Helper class to test handling of arguments which are derived from string
48-
class AlsoString < String
4+
# put local configuration and setup into spec_helper_local
5+
begin
6+
require 'spec_helper_local'
7+
rescue LoadError
498
end

spec/spec_helper_local.rb

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
# hack to enable all the expect syntax (like allow_any_instance_of) in rspec-puppet examples
3+
RSpec::Mocks::Syntax.enable_expect(RSpec::Puppet::ManifestMatchers)
4+
5+
RSpec.configure do |config|
6+
# supply tests with a possibility to test for the future parser
7+
config.add_setting :puppet_future
8+
config.puppet_future = Puppet.version.to_f >= 4.0
9+
10+
config.before :each do
11+
# Ensure that we don't accidentally cache facts and environment between
12+
# test cases. This requires each example group to explicitly load the
13+
# facts being exercised with something like
14+
# Facter.collection.loader.load(:ipaddress)
15+
Facter.clear
16+
Facter.clear_messages
17+
18+
RSpec::Mocks.setup
19+
end
20+
21+
config.after :each do
22+
RSpec::Mocks.verify
23+
RSpec::Mocks.teardown
24+
end
25+
end
26+
27+
# Helper class to test handling of arguments which are derived from string
28+
class AlsoString < String
29+
end

0 commit comments

Comments
 (0)