X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Fstdlib%2Fspec%2Fspec_helper_acceptance.rb;fp=3rdparty%2Fmodules%2Fstdlib%2Fspec%2Fspec_helper_acceptance.rb;h=4d85e7dc8b163de98c89b6a6a8f0afd7787362ef;hb=6963202b4b62c2816655ac9532521b018fdf83bd;hp=3203ce9fbbd7f37e165df15d00709598fa3f64aa;hpb=a69999e580f8b3abd12446c2d6ad59e517651813;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/stdlib/spec/spec_helper_acceptance.rb b/3rdparty/modules/stdlib/spec/spec_helper_acceptance.rb index 3203ce9fb..4d85e7dc8 100755 --- a/3rdparty/modules/stdlib/spec/spec_helper_acceptance.rb +++ b/3rdparty/modules/stdlib/spec/spec_helper_acceptance.rb @@ -1,50 +1,55 @@ #! /usr/bin/env ruby -S rspec +require 'puppet' require 'beaker-rspec' +require 'beaker/puppet_install_helper' +require 'beaker/module_install_helper' -UNSUPPORTED_PLATFORMS = [] +run_puppet_install_helper +install_ca_certs unless ENV['PUPPET_INSTALL_TYPE'] =~ /pe/i +install_module_on(hosts) +install_module_dependencies_on(hosts) -unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no' - foss_opts = { - :default_action => 'gem_install', - :version => (ENV['PUPPET_VERSION'] ? ENV['PUPPET_VERSION'] : '3.7.2'), - } +RSpec.configure do |c| + # Readable test descriptions + c.formatter = :documentation + + # Configure all nodes in nodeset + c.before :suite do + end +end - if default.is_pe?; then install_pe; else install_puppet( foss_opts ); end +def get_puppet_version + (on default, puppet('--version')).output.chomp +end - hosts.each do |host| - if host['platform'] !~ /windows/i - if host.is_pe? - on host, 'mkdir -p /etc/puppetlabs/facter/facts.d' +RSpec.shared_context "with faked facts" do + let(:facts_d) do + puppet_version = get_puppet_version + if fact('osfamily') =~ /windows/i + if fact('kernelmajversion').to_f < 6.0 + 'C:/Documents and Settings/All Users/Application Data/PuppetLabs/facter/facts.d' else - on host, "/bin/touch #{host['puppetpath']}/hiera.yaml" - on host, "mkdir -p #{host['distmoduledir']}" - on host, 'mkdir -p /etc/facter/facts.d' + 'C:/ProgramData/PuppetLabs/facter/facts.d' end + elsif Puppet::Util::Package.versioncmp(puppet_version, '4.0.0') < 0 and fact('is_pe', '--puppet') == "true" + '/etc/puppetlabs/facter/facts.d' + else + '/etc/facter/facts.d' end end -end -RSpec.configure do |c| - # Project root - proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) - - # Readable test descriptions - c.formatter = :documentation - - # Configure all nodes in nodeset - c.before :suite do - if ENV['FUTURE_PARSER'] == 'true' - default[:default_apply_opts] ||= {} - default[:default_apply_opts].merge!({:parser => 'future'}) + before :each do + #No need to create on windows, PE creates by default + if fact('osfamily') !~ /windows/i + shell("mkdir -p '#{facts_d}'") end + end - copy_root_module_to(default, :source => proj_root, :module_name => 'stdlib') + after :each do + shell("rm -f '#{facts_d}/fqdn.txt'", :acceptable_exit_codes => [0,1]) end -end -def is_future_parser_enabled? - if default[:default_apply_opts] - return default[:default_apply_opts][:parser] == 'future' + def fake_fact(name, value) + shell("echo #{name}=#{value} > '#{facts_d}/#{name}.txt'") end - return false end