Skip to content

Multiple updates to stdlib and its testsuite #589

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .sync.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
72 changes: 25 additions & 47 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -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
41 changes: 38 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -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
5 changes: 4 additions & 1 deletion lib/puppet/parser/functions/parseyaml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ module Puppet::Parser::Functions

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
Expand Down
6 changes: 1 addition & 5 deletions spec/functions/get_module_path_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
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
Expand Down
34 changes: 0 additions & 34 deletions spec/puppetlabs_spec_helper_clone.rb

This file was deleted.

6 changes: 0 additions & 6 deletions spec/spec.opts

This file was deleted.

51 changes: 5 additions & 46 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions spec/spec_helper_local.rb
Original file line number Diff line number Diff line change
@@ -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