[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35

Markus Roberts Markus at reality.com
Wed Jul 14 10:37:14 UTC 2010


The following commit has been merged in the upstream branch:
commit eefccf252527dc5b69af5959b0b0e2ddb5c91b74
Author: Markus Roberts <Markus at reality.com>
Date:   Fri Jul 9 18:05:08 2010 -0700

    Code smell: English names for special globals rather than line-noise
    
    * Replaced 36 occurances of [$][?] with $CHILD_STATUS
    
      3 Examples:
    
          The code:
              print "%s finished with exit code %s\n" % [host, $?.exitstatus]
          becomes:
              print "%s finished with exit code %s\n" % [host, $CHILD_STATUS.exitstatus]
          The code:
              $stderr.puts "Could not find host for PID %s with status %s" % [pid, $?.exitstatus]
          becomes:
              $stderr.puts "Could not find host for PID %s with status %s" % [pid, $CHILD_STATUS.exitstatus]
          The code:
              unless $? == 0
          becomes:
              unless $CHILD_STATUS == 0
    
    * Replaced 3 occurances of [$][$] with $PID
    
      3 Examples:
    
          The code:
              Process.kill(:HUP, $$) if restart_requested?
          becomes:
              Process.kill(:HUP, $PID) if restart_requested?
          The code:
              if pid == $$
          becomes:
              if pid == $PID
          The code:
              host[:name] = "!invalid.hostname.$$$"
          becomes:
              host[:name] = "!invalid.hostname.$PID$"
    
    * Replaced 7 occurances of [$]& with $MATCH
    
      3 Examples:
    
          The code:
              work.slice!(0, $&.length)
          becomes:
              work.slice!(0, $MATCH.length)
          The code:
              if $&
          becomes:
              if $MATCH
          The code:
              if $&
          becomes:
              if $MATCH
    
    * Replaced 28 occurances of [$]:(?!:) with $LOAD_PATH
    
      3 Examples:
    
          The code:
              sitelibdir = $:.find { |x| x =~ /site_ruby/ }
          becomes:
              sitelibdir = $LOAD_PATH.find { |x| x =~ /site_ruby/ }
          The code:
              $:.unshift "lib"
          becomes:
              $LOAD_PATH.unshift "lib"
          The code:
              $:.shift
          becomes:
              $LOAD_PATH.shift
    
    * Replaced 3 occurances of [$]! with $ERROR_INFO
    
      3 Examples:
    
          The code:
              $LOG.fatal("Problem reading #{filepath}: #{$!}")
          becomes:
              $LOG.fatal("Problem reading #{filepath}: #{$ERROR_INFO}")
          The code:
              $stderr.puts "Couldn't build man pages: " + $!
          becomes:
              $stderr.puts "Couldn't build man pages: " + $ERROR_INFO
          The code:
              $stderr.puts $!.message
          becomes:
              $stderr.puts $ERROR_INFO.message
    
    * Replaced 3 occurances of ^(.*)[$]" with \1$LOADED_FEATURES
    
      3 Examples:
    
          The code:
              unless $".index 'racc/parser.rb'
          becomes:
              unless $LOADED_FEATURES.index 'racc/parser.rb'
          The code:
              $".push 'racc/parser.rb'
          becomes:
              $LOADED_FEATURES.push 'racc/parser.rb'
          The code:
              $".should be_include("tmp/myfile.rb")
          becomes:
              $LOADED_FEATURES.should be_include("tmp/myfile.rb")

diff --git a/ext/regexp_nodes/regexp_nodes.rb b/ext/regexp_nodes/regexp_nodes.rb
index 377b130..92607ea 100644
--- a/ext/regexp_nodes/regexp_nodes.rb
+++ b/ext/regexp_nodes/regexp_nodes.rb
@@ -117,7 +117,7 @@ class ExternalNode
                 $LOG.debug("appending [#{pattern}] to patternlist for [#{filepath}]")
             }
         rescue Exception
-            $LOG.fatal("Problem reading #{filepath}: #{$!}")
+            $LOG.fatal("Problem reading #{filepath}: #{$ERROR_INFO}")
             exit(1)
         end
 
diff --git a/install.rb b/install.rb
index 18da2be..a95ef76 100755
--- a/install.rb
+++ b/install.rb
@@ -270,7 +270,7 @@ def prepare_installation
     else
         sitelibdir = Config::CONFIG["sitelibdir"]
         if sitelibdir.nil?
-            sitelibdir = $:.find { |x| x =~ /site_ruby/ }
+            sitelibdir = $LOAD_PATH.find { |x| x =~ /site_ruby/ }
             if sitelibdir.nil?
                 sitelibdir = File.join(libdir, "site_ruby")
             elsif sitelibdir !~ Regexp.quote(version)
@@ -369,7 +369,7 @@ def build_man(bins, sbins)
         end
 
 rescue SystemCallError
-    $stderr.puts "Couldn't build man pages: " + $!
+    $stderr.puts "Couldn't build man pages: " + $ERROR_INFO
     $stderr.puts "Continuing with install..."
     end
 end
@@ -377,7 +377,7 @@ end
 def run_tests(test_list)
     begin
         require 'test/unit/ui/console/testrunner'
-        $:.unshift "lib"
+        $LOAD_PATH.unshift "lib"
         test_list.each do |test|
             next if File.directory?(test)
             require test
@@ -389,7 +389,7 @@ def run_tests(test_list)
         tests.delete_if { |o| o == Test::Unit::TestCase }
 
         tests.each { |test| Test::Unit::UI::Console::TestRunner.run(test) }
-        $:.shift
+        $LOAD_PATH.shift
     rescue LoadError
         puts "Missing testrunner library; skipping tests"
     end
diff --git a/lib/puppet/application.rb b/lib/puppet/application.rb
index 3409d36..7e7a2a9 100644
--- a/lib/puppet/application.rb
+++ b/lib/puppet/application.rb
@@ -169,7 +169,7 @@ class Application
         def controlled_run(&block)
             return unless clear?
             result = block.call
-            Process.kill(:HUP, $$) if restart_requested?
+            Process.kill(:HUP, $PID) if restart_requested?
             result
         end
 
diff --git a/lib/puppet/application/describe.rb b/lib/puppet/application/describe.rb
index f9c5260..b9c05c0 100644
--- a/lib/puppet/application/describe.rb
+++ b/lib/puppet/application/describe.rb
@@ -19,7 +19,7 @@ class Formatter
         while work.length > textLen
             if work =~ patt
                 res << $1
-                work.slice!(0, $&.length)
+                work.slice!(0, $MATCH.length)
             else
                 res << work.slice!(0, textLen)
             end
diff --git a/lib/puppet/application/kick.rb b/lib/puppet/application/kick.rb
index 8c168b3..e6cbed6 100644
--- a/lib/puppet/application/kick.rb
+++ b/lib/puppet/application/kick.rb
@@ -77,12 +77,12 @@ class Puppet::Application::Kick < Puppet::Application
                         # Remove our host from the list of children, so the parallelization
                         # continues working.
                         @children.delete(pid)
-                        if $?.exitstatus != 0
+                        if $CHILD_STATUS.exitstatus != 0
                             failures << host
                         end
-                        print "%s finished with exit code %s\n" % [host, $?.exitstatus]
+                        print "%s finished with exit code %s\n" % [host, $CHILD_STATUS.exitstatus]
                     else
-                        $stderr.puts "Could not find host for PID %s with status %s" % [pid, $?.exitstatus]
+                        $stderr.puts "Could not find host for PID %s with status %s" % [pid, $CHILD_STATUS.exitstatus]
                     end
                 rescue Errno::ECHILD
                     # There are no children left, so just exit unless there are still
@@ -104,7 +104,7 @@ class Puppet::Application::Kick < Puppet::Application
     def run_for_host(host)
         if options[:ping]
             out = %x{ping -c 1 #{host}}
-            unless $? == 0
+            unless $CHILD_STATUS == 0
                 $stderr.print "Could not contact %s\n" % host
                 next
             end
diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb
index 9637a63..64baded 100644
--- a/lib/puppet/defaults.rb
+++ b/lib/puppet/defaults.rb
@@ -82,11 +82,11 @@ module Puppet
                 is in Ruby's search path",
             :call_on_define => true, # Call our hook with the default value, so we always get the libdir set.
             :hook => proc do |value|
-                if defined?(@oldlibdir) and $:.include?(@oldlibdir)
-                    $:.delete(@oldlibdir)
+                if defined?(@oldlibdir) and $LOAD_PATH.include?(@oldlibdir)
+                    $LOAD_PATH.delete(@oldlibdir)
                 end
                 @oldlibdir = value
-                $: << value
+                $LOAD_PATH << value
             end
         },
         :ignoreimport => [false, "A parameter that can be used in commit
diff --git a/lib/puppet/external/nagios/parser.rb b/lib/puppet/external/nagios/parser.rb
index deea9f3..4a1f4c9 100644
--- a/lib/puppet/external/nagios/parser.rb
+++ b/lib/puppet/external/nagios/parser.rb
@@ -7,8 +7,8 @@
 # parser.rb: generated by racc (runtime embedded)
 #
 ###### racc/parser.rb begin
-unless $".index 'racc/parser.rb'
-$".push 'racc/parser.rb'
+unless $LOADED_FEATURES.index 'racc/parser.rb'
+$LOADED_FEATURES.push 'racc/parser.rb'
 
 self.class.module_eval <<'..end racc/parser.rb modeval..id5256434e8a', 'racc/parser.rb', 1
 #
@@ -482,7 +482,7 @@ end
 # The lexer.  Very simple.
 def token
     @src.sub!(/\A\n/,'')
-    if $&
+    if $MATCH
         @line += 1
         return [ :RETURN, "\n" ]
         end
@@ -495,12 +495,12 @@ def token
 
         # remove comments from this line
         @src.sub!(/\A[ \t]*;.*\n/,"\n")
-        if $&
+        if $MATCH
             return [:INLINECOMMENT, ""]
         end
 
         @src.sub!(/\A#.*\n/,"\n")
-        if $&
+        if $MATCH
             return [:COMMENT, ""]
         end
 
diff --git a/lib/puppet/external/pson/pure/generator.rb b/lib/puppet/external/pson/pure/generator.rb
index 6656ed1..42981b9 100644
--- a/lib/puppet/external/pson/pure/generator.rb
+++ b/lib/puppet/external/pson/pure/generator.rb
@@ -43,7 +43,7 @@ module PSON
             string = string.dup
             string << '' # XXX workaround: avoid buffer sharing
             string.force_encoding(Encoding::ASCII_8BIT)
-            string.gsub!(/["\\\x0-\x1f]/) { MAP[$&] }
+            string.gsub!(/["\\\x0-\x1f]/) { MAP[$MATCH] }
             string.gsub!(/(
                 (?:
                     [\xc2-\xdf][\x80-\xbf]    |
@@ -63,7 +63,7 @@ module PSON
         end
     else
         def utf8_to_pson(string) # :nodoc:
-            string = string.gsub(/["\\\x0-\x1f]/) { MAP[$&] }
+            string = string.gsub(/["\\\x0-\x1f]/) { MAP[$MATCH] }
             string.gsub!(/(
                 (?:
                     [\xc2-\xdf][\x80-\xbf]    |
diff --git a/lib/puppet/external/pson/pure/parser.rb b/lib/puppet/external/pson/pure/parser.rb
index ef14d40..ef05637 100644
--- a/lib/puppet/external/pson/pure/parser.rb
+++ b/lib/puppet/external/pson/pure/parser.rb
@@ -132,7 +132,7 @@ module PSON
                 if scan(STRING)
                     return '' if self[1].empty?
                     string = self[1].gsub(%r{(?:\\[\\bfnrt"/]|(?:\\u(?:[A-Fa-f\d]{4}))+|\\[\x20-\xff])}n) do |c|
-                        if u = UNESCAPE_MAP[$&[1]]
+                        if u = UNESCAPE_MAP[$MATCH[1]]
                             u
                         else # \uXXXX
                             bytes = ''
diff --git a/lib/puppet/feature/rails.rb b/lib/puppet/feature/rails.rb
index a290072..f1997bd 100644
--- a/lib/puppet/feature/rails.rb
+++ b/lib/puppet/feature/rails.rb
@@ -14,9 +14,9 @@ Puppet.features.add(:rails) do
             count = 0
             Dir.entries("/usr/share/rails").each do |dir|
                 libdir = File.join("/usr/share/rails", dir, "lib")
-                if FileTest.exists?(libdir) and ! $:.include?(libdir)
+                if FileTest.exists?(libdir) and ! $LOAD_PATH.include?(libdir)
                     count += 1
-                    $: << libdir
+                    $LOAD_PATH << libdir
                 end
             end
 
diff --git a/lib/puppet/provider/package/darwinport.rb b/lib/puppet/provider/package/darwinport.rb
index 7829438..5cced62 100755
--- a/lib/puppet/provider/package/darwinport.rb
+++ b/lib/puppet/provider/package/darwinport.rb
@@ -67,7 +67,7 @@ Puppet::Type.type(:package).provide :darwinport, :parent => Puppet::Provider::Pa
     def latest
         info = port :search, "^#{@resource[:name]}$"
 
-        if $? != 0 or info =~ /^Error/
+        if $CHILD_STATUS != 0 or info =~ /^Error/
             return nil
         end
 
diff --git a/lib/puppet/provider/service/base.rb b/lib/puppet/provider/service/base.rb
index aa11f26..2e9ac77 100755
--- a/lib/puppet/provider/service/base.rb
+++ b/lib/puppet/provider/service/base.rb
@@ -64,7 +64,7 @@ Puppet::Type.type(:service).provide :base do
             ucommand(:status, false)
 
             # Expicitly calling exitstatus to facilitate testing
-            if $?.exitstatus == 0
+            if $CHILD_STATUS.exitstatus == 0
                 return :running
             else
                 return :stopped
diff --git a/lib/puppet/provider/service/debian.rb b/lib/puppet/provider/service/debian.rb
index 34e2cf8..1f95d66 100755
--- a/lib/puppet/provider/service/debian.rb
+++ b/lib/puppet/provider/service/debian.rb
@@ -34,7 +34,7 @@ Puppet::Type.type(:service).provide :debian, :parent => :init do
         # 104 is the exit status when you query start an enabled service.
         # 106 is the exit status when the policy layer supplies a fallback action
         # See x-man-page://invoke-rc.d
-        if [104, 106].include?($?.exitstatus)
+        if [104, 106].include?($CHILD_STATUS.exitstatus)
             return :true
         else
             return :false
diff --git a/lib/puppet/provider/service/smf.rb b/lib/puppet/provider/service/smf.rb
index 6858893..72f34ef 100755
--- a/lib/puppet/provider/service/smf.rb
+++ b/lib/puppet/provider/service/smf.rb
@@ -22,7 +22,7 @@ Puppet::Type.type(:service).provide :smf, :parent => :base do
         begin
             if resource[:manifest]
                 [command(:svcs), "-l", @resource[:name]]
-                if $?.exitstatus == 1
+                if $CHILD_STATUS.exitstatus == 1
                     Puppet.notice "Importing %s for %s" % [ @resource[:manifest], @resource[:name] ]
                     svccfg :import, resource[:manifest]
                 end
diff --git a/lib/puppet/provider/zone/solaris.rb b/lib/puppet/provider/zone/solaris.rb
index 1aaa70d..4d7e747 100644
--- a/lib/puppet/provider/zone/solaris.rb
+++ b/lib/puppet/provider/zone/solaris.rb
@@ -150,7 +150,7 @@ Puppet::Type.type(:zone).provide(:solaris) do
             pipe.puts str
         end
 
-        unless $? == 0
+        unless $CHILD_STATUS == 0
             raise ArgumentError, "Failed to apply configuration"
         end
     end
diff --git a/lib/puppet/rails.rb b/lib/puppet/rails.rb
index 714dda8..be252e4 100644
--- a/lib/puppet/rails.rb
+++ b/lib/puppet/rails.rb
@@ -97,7 +97,7 @@ module Puppet::Rails
     # Migrate to the latest db schema.
     def self.migrate
         dbdir = nil
-        $:.each { |d|
+        $LOAD_PATH.each { |d|
             tmp = File.join(d, "puppet/rails/database")
             if FileTest.directory?(tmp)
                 dbdir = tmp
diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb
index 3861002..1f97492 100644
--- a/lib/puppet/util.rb
+++ b/lib/puppet/util.rb
@@ -215,7 +215,7 @@ module Util
         end
 
         if failonfail
-            unless $? == 0
+            unless $CHILD_STATUS == 0
                 raise ExecutionFailure, output
             end
         end
@@ -380,7 +380,7 @@ module Util
     def memory
         unless defined?(@pmap)
             pmap = %x{which pmap 2>/dev/null}.chomp
-            if $? != 0 or pmap =~ /^no/
+            if $CHILD_STATUS != 0 or pmap =~ /^no/
                 @pmap = nil
             else
                 @pmap = pmap
diff --git a/lib/puppet/util/autoload.rb b/lib/puppet/util/autoload.rb
index 27a3613..f0be0ec 100644
--- a/lib/puppet/util/autoload.rb
+++ b/lib/puppet/util/autoload.rb
@@ -143,6 +143,6 @@ class Puppet::Util::Autoload
     end
 
     def search_directories(env=nil)
-        [module_directories(env), Puppet[:libdir].split(File::PATH_SEPARATOR), $:].flatten
+        [module_directories(env), Puppet[:libdir].split(File::PATH_SEPARATOR), $LOAD_PATH].flatten
     end
 end
diff --git a/lib/puppet/util/command_line.rb b/lib/puppet/util/command_line.rb
index 9ccc94a..fa1b08b 100644
--- a/lib/puppet/util/command_line.rb
+++ b/lib/puppet/util/command_line.rb
@@ -33,7 +33,7 @@ module Puppet
             end
 
             def available_subcommands
-                absolute_appdir = $:.collect { |x| File.join(x,'puppet','application') }.detect{ |x| File.directory?(x) }
+                absolute_appdir = $LOAD_PATH.collect { |x| File.join(x,'puppet','application') }.detect{ |x| File.directory?(x) }
                 Dir[File.join(absolute_appdir, '*.rb')].map{|fn| File.basename(fn, '.rb')}
             end
 
diff --git a/lib/puppet/util/rdoc/generators/puppet_generator.rb b/lib/puppet/util/rdoc/generators/puppet_generator.rb
index c2c27c8..c32a401 100644
--- a/lib/puppet/util/rdoc/generators/puppet_generator.rb
+++ b/lib/puppet/util/rdoc/generators/puppet_generator.rb
@@ -177,7 +177,7 @@ module Generators
                 File.makedirs(NODE_DIR)
                 File.makedirs(PLUGIN_DIR)
             rescue
-                $stderr.puts $!.message
+                $stderr.puts $ERROR_INFO.message
                 exit 1
             end
         end
diff --git a/lib/puppet/util/reference.rb b/lib/puppet/util/reference.rb
index f34e54b..74d75bb 100644
--- a/lib/puppet/util/reference.rb
+++ b/lib/puppet/util/reference.rb
@@ -41,10 +41,10 @@ class Puppet::Util::Reference
             f.puts text
         end
         rst2latex = %x{which rst2latex}
-        if $? != 0 or rst2latex =~ /no /
+        if $CHILD_STATUS != 0 or rst2latex =~ /no /
             rst2latex = %x{which rst2latex.py}
         end
-        if $? != 0 or rst2latex =~ /no /
+        if $CHILD_STATUS != 0 or rst2latex =~ /no /
             raise "Could not find rst2latex"
         end
         rst2latex.chomp!
@@ -53,7 +53,7 @@ class Puppet::Util::Reference
             # If we get here without an error, /tmp/puppetdoc.tex isn't a tricky cracker's symlink
         end
         output = %x{#{cmd}}
-        unless $? == 0
+        unless $CHILD_STATUS == 0
             $stderr.puts "rst2latex failed"
             $stderr.puts output
             exit(1)
@@ -75,16 +75,16 @@ class Puppet::Util::Reference
             f.puts text
         end
         pandoc = %x{which pandoc}
-        if $? != 0 or pandoc =~ /no /
+        if $CHILD_STATUS != 0 or pandoc =~ /no /
             pandoc = %x{which pandoc}
         end
-        if $? != 0 or pandoc =~ /no /
+        if $CHILD_STATUS != 0 or pandoc =~ /no /
             raise "Could not find pandoc"
         end
         pandoc.chomp!
         cmd = %{#{pandoc} -s -r rst -w markdown #{dir}/#{name}.rst -o #{dir}/#{name}.mdwn}
         output = %x{#{cmd}}
-        unless $? == 0
+        unless $CHILD_STATUS == 0
             $stderr.puts "Pandoc failed to create #{name} reference."
             $stderr.puts output
             exit(1)
@@ -201,7 +201,7 @@ class Puppet::Util::Reference
         puts "Writing %s reference to trac as %s" % [@name, @page]
         cmd = %{sudo trac-admin /opt/rl/trac/puppet wiki import %s /tmp/puppetdoc.txt} % self.page
         output = %x{#{cmd}}
-        unless $? == 0
+        unless $CHILD_STATUS == 0
             $stderr.puts "trac-admin failed"
             $stderr.puts output
             exit(1)
diff --git a/lib/puppet/util/suidmanager.rb b/lib/puppet/util/suidmanager.rb
index b8e7d53..404f788 100644
--- a/lib/puppet/util/suidmanager.rb
+++ b/lib/puppet/util/suidmanager.rb
@@ -90,7 +90,7 @@ module Puppet::Util::SUIDManager
 
     def run_and_capture(command, new_uid=nil, new_gid=nil)
         output = Puppet::Util.execute(command, :failonfail => false, :uid => new_uid, :gid => new_gid)
-        [output, $?.dup]
+        [output, $CHILD_STATUS.dup]
     end
     module_function :run_and_capture
 
@@ -98,7 +98,7 @@ module Puppet::Util::SUIDManager
         status = nil
         asuser(new_uid, new_gid) do
             Kernel.system(command)
-            status = $?.dup
+            status = $CHILD_STATUS.dup
         end
         status
     end
diff --git a/spec/integration/ssl/certificate_authority_spec.rb b/spec/integration/ssl/certificate_authority_spec.rb
index 553c9b3..349e5cb 100755
--- a/spec/integration/ssl/certificate_authority_spec.rb
+++ b/spec/integration/ssl/certificate_authority_spec.rb
@@ -128,7 +128,7 @@ describe Puppet::SSL::CertificateAuthority do
                 ca_cert = Puppet[:cacert]
                 client_cert = File.join(Puppet[:signeddir], "luke.madstop.com.pem")
                 output = %x{openssl verify -CAfile #{ca_cert} #{client_cert}}
-                $?.should == 0
+                $CHILD_STATUS.should == 0
             end
         end
     end
diff --git a/spec/integration/util/autoload_spec.rb b/spec/integration/util/autoload_spec.rb
index a1c8aaa..ab1ff74 100755
--- a/spec/integration/util/autoload_spec.rb
+++ b/spec/integration/util/autoload_spec.rb
@@ -37,7 +37,7 @@ describe Puppet::Util::Autoload do
 
     def with_loader(name, path)
         dir = tmpfile(name + path)
-        $: << dir
+        $LOAD_PATH << dir
         Dir.mkdir(dir)
         rbdir = File.join(dir, path.to_s)
         Dir.mkdir(rbdir)
@@ -45,7 +45,7 @@ describe Puppet::Util::Autoload do
         yield rbdir, loader
         Dir.rmdir(rbdir)
         Dir.rmdir(dir)
-        $:.pop
+        $LOAD_PATH.pop
         AutoloadIntegrator.clear
     end
 
diff --git a/spec/integration/util/feature_spec.rb b/spec/integration/util/feature_spec.rb
index 55a3065..b2adbd0 100755
--- a/spec/integration/util/feature_spec.rb
+++ b/spec/integration/util/feature_spec.rb
@@ -12,7 +12,7 @@ describe Puppet::Util::Feature do
         libdir = tmpfile("feature_lib")
         Dir.mkdir(libdir)
 
-        $: << libdir
+        $LOAD_PATH << libdir
 
         $features = Puppet::Util::Feature.new("feature_lib")
 
diff --git a/spec/unit/provider/service/debian_spec.rb b/spec/unit/provider/service/debian_spec.rb
index 08cf50c..1d30eb8 100755
--- a/spec/unit/provider/service/debian_spec.rb
+++ b/spec/unit/provider/service/debian_spec.rb
@@ -66,13 +66,13 @@ describe provider_class do
 
         it "should return true when invoke-rc.d exits with 104 status" do
             @provider.stubs(:system)
-            $?.stubs(:exitstatus).returns(104)
+            $CHILD_STATUS.stubs(:exitstatus).returns(104)
             @provider.enabled?.should == :true
         end
 
         it "should return true when invoke-rc.d exits with 106 status" do
             @provider.stubs(:system)
-            $?.stubs(:exitstatus).returns(106)
+            $CHILD_STATUS.stubs(:exitstatus).returns(106)
             @provider.enabled?.should == :true
         end
 
@@ -80,7 +80,7 @@ describe provider_class do
         [-100, -1, 0, 1, 100, "foo", "", :true, :false].each do |exitstatus|
             it "should return false when invoke-rc.d exits with #{exitstatus} status" do
                 @provider.stubs(:system)
-                $?.stubs(:exitstatus).returns(exitstatus)
+                $CHILD_STATUS.stubs(:exitstatus).returns(exitstatus)
                 @provider.enabled?.should == :false
             end
         end
diff --git a/spec/unit/provider/service/init_spec.rb b/spec/unit/provider/service/init_spec.rb
index a685cc0..b8c2794 100755
--- a/spec/unit/provider/service/init_spec.rb
+++ b/spec/unit/provider/service/init_spec.rb
@@ -132,13 +132,13 @@ describe provider_class do
                 end
                 it "should consider the process running if the command returns 0" do
                     @provider.expects(:texecute).with(:status, ['/service/path/myservice', :status], false).returns("")
-                    $?.stubs(:exitstatus).returns(0)
+                    $CHILD_STATUS.stubs(:exitstatus).returns(0)
                     @provider.status.should == :running
                 end
                 [-10,-1,1,10].each { |ec|
                     it "should consider the process stopped if the command returns something non-0" do
                         @provider.expects(:texecute).with(:status, ['/service/path/myservice', :status], false).returns("")
-                        $?.stubs(:exitstatus).returns(ec)
+                        $CHILD_STATUS.stubs(:exitstatus).returns(ec)
                         @provider.status.should == :stopped
                     end
                 }
@@ -159,7 +159,7 @@ describe provider_class do
             it "should stop and restart the process" do
                 @provider.expects(:texecute).with(:stop, ['/service/path/myservice', :stop ], true).returns("")
                 @provider.expects(:texecute).with(:start,['/service/path/myservice', :start], true).returns("")
-                $?.stubs(:exitstatus).returns(0)
+                $CHILD_STATUS.stubs(:exitstatus).returns(0)
                 @provider.restart
             end
         end
diff --git a/spec/unit/provider/service/redhat_spec.rb b/spec/unit/provider/service/redhat_spec.rb
index 0f919ac..82596fd 100755
--- a/spec/unit/provider/service/redhat_spec.rb
+++ b/spec/unit/provider/service/redhat_spec.rb
@@ -88,13 +88,13 @@ describe provider_class do
             end
             it "should consider the process running if the command returns 0" do
                 @provider.expects(:texecute).with(:status, ['/sbin/service', 'myservice', 'status'], false)
-                $?.stubs(:exitstatus).returns(0)
+                $CHILD_STATUS.stubs(:exitstatus).returns(0)
                 @provider.status.should == :running
             end
             [-10,-1,1,10].each { |ec|
                 it "should consider the process stopped if the command returns something non-0" do
                     @provider.expects(:texecute).with(:status, ['/sbin/service', 'myservice', 'status'], false)
-                    $?.stubs(:exitstatus).returns(ec)
+                    $CHILD_STATUS.stubs(:exitstatus).returns(ec)
                     @provider.status.should == :stopped
                 end
             }
diff --git a/spec/unit/util/autoload_spec.rb b/spec/unit/util/autoload_spec.rb
index 0f73a73..4186a1f 100755
--- a/spec/unit/util/autoload_spec.rb
+++ b/spec/unit/util/autoload_spec.rb
@@ -49,7 +49,7 @@ describe Puppet::Util::Autoload do
         it "should include the module directories, the Puppet libdir, and all of the Ruby load directories" do
             Puppet.stubs(:[]).with(:libdir).returns(%w{/libdir1 /lib/dir/two /third/lib/dir}.join(File::PATH_SEPARATOR))
             @autoload.expects(:module_directories).returns %w{/one /two}
-            @autoload.search_directories.should == %w{/one /two /libdir1 /lib/dir/two /third/lib/dir} + $:
+            @autoload.search_directories.should == %w{/one /two /libdir1 /lib/dir/two /third/lib/dir} + $LOAD_PATH
         end
 
         it "should include in its search path all of the search directories that have a subdirectory matching the autoload path" do
@@ -91,7 +91,7 @@ describe Puppet::Util::Autoload do
 
             @autoload.load("myfile")
 
-            $".should be_include("tmp/myfile.rb")
+            $LOADED_FEATURES.should be_include("tmp/myfile.rb")
         end
     end
 
diff --git a/test/certmgr/certmgr.rb b/test/certmgr/certmgr.rb
index ab4372c..41a4a87 100755
--- a/test/certmgr/certmgr.rb
+++ b/test/certmgr/certmgr.rb
@@ -170,7 +170,7 @@ class TestCertMgr < Test::Unit::TestCase
             #output = %x{openssl verify -CApath #{Puppet[:certdir]} -purpose sslserver #{cert.certfile}}
         }
 
-        assert_equal($?,0)
+        assert_equal($CHILD_STATUS,0)
         assert_equal(File.join(Puppet[:certdir], "signedcertest.pem: OK\n"), output)
     end
 
diff --git a/test/language/functions.rb b/test/language/functions.rb
index a9d7c1a..9cd4d24 100755
--- a/test/language/functions.rb
+++ b/test/language/functions.rb
@@ -402,7 +402,7 @@ class TestLangFunctions < Test::Unit::TestCase
         #    "Got told autofunc already exists")
 
         dir = tempfile()
-        $: << dir
+        $LOAD_PATH << dir
         newpath = File.join(dir, "puppet", "parser", "functions")
         FileUtils.mkdir_p(newpath)
 
diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb
index e11de04..522112d 100755
--- a/test/lib/puppettest.rb
+++ b/test/lib/puppettest.rb
@@ -133,7 +133,7 @@ module PuppetTest
     # Rails clobbers RUBYLIB, thanks
     def libsetup
         curlibs = ENV["RUBYLIB"].split(":")
-        $:.reject do |dir| dir =~ /^\/usr/ end.each do |dir|
+        $LOAD_PATH.reject do |dir| dir =~ /^\/usr/ end.each do |dir|
             unless curlibs.include?(dir)
                 curlibs << dir
             end
diff --git a/test/lib/puppettest/exetest.rb b/test/lib/puppettest/exetest.rb
index 0d66c5a..b0857d1 100644
--- a/test/lib/puppettest/exetest.rb
+++ b/test/lib/puppettest/exetest.rb
@@ -27,7 +27,7 @@ module PuppetTest::ExeTest
     end
 
     def setlibdir
-        ENV["RUBYLIB"] = $:.find_all { |dir|
+        ENV["RUBYLIB"] = $LOAD_PATH.find_all { |dir|
             dir =~ /puppet/ or dir =~ /\.\./
         }.join(":")
     end
@@ -71,7 +71,7 @@ module PuppetTest::ExeTest
             output = %x{#{cmd}}.chomp
         }
         assert_equal("", output, "Puppetmasterd produced output %s" % output)
-        assert($? == 0, "Puppetmasterd exit status was %s" % $?)
+        assert($CHILD_STATUS == 0, "Puppetmasterd exit status was %s" % $CHILD_STATUS)
         sleep(1)
 
         cleanup do
@@ -110,7 +110,7 @@ module PuppetTest::ExeTest
         # we default to mandating that it's running, but teardown
         # doesn't require that
         if pid
-            if pid == $$
+            if pid == $PID
                 raise Puppet::Error, "Tried to kill own pid"
             end
             begin
diff --git a/test/other/puppet.rb b/test/other/puppet.rb
index 0dea54d..6fdf468 100755
--- a/test/other/puppet.rb
+++ b/test/other/puppet.rb
@@ -55,11 +55,11 @@ class TestPuppetModule < Test::Unit::TestCase
     end
 
     def test_libdir
-        oldlibs = $:.dup
+        oldlibs = $LOAD_PATH.dup
         cleanup do
-            $:.each do |dir|
+            $LOAD_PATH.each do |dir|
                 unless oldlibs.include?(dir)
-                    $:.delete(dir)
+                    $LOAD_PATH.delete(dir)
                 end
             end
         end
@@ -68,12 +68,12 @@ class TestPuppetModule < Test::Unit::TestCase
         Dir.mkdir(one)
         Dir.mkdir(two)
 
-        # Make sure setting the libdir gets the dir added to $:
+        # Make sure setting the libdir gets the dir added to $LOAD_PATH
         assert_nothing_raised do
             Puppet[:libdir] = one
         end
 
-        assert($:.include?(one), "libdir was not added")
+        assert($LOAD_PATH.include?(one), "libdir was not added")
 
         # Now change it, make sure it gets added and the old one gets
         # removed
@@ -81,8 +81,8 @@ class TestPuppetModule < Test::Unit::TestCase
             Puppet[:libdir] = two
         end
 
-        assert($:.include?(two), "libdir was not added")
-        assert(! $:.include?(one), "old libdir was not removed")
+        assert($LOAD_PATH.include?(two), "libdir was not added")
+        assert(! $LOAD_PATH.include?(one), "old libdir was not removed")
     end
 end
 
diff --git a/test/puppet/tc_suidmanager.rb b/test/puppet/tc_suidmanager.rb
index 0d51dda..ddf6a0e 100755
--- a/test/puppet/tc_suidmanager.rb
+++ b/test/puppet/tc_suidmanager.rb
@@ -122,8 +122,8 @@ class TestSUIDManager < Test::Unit::TestCase
     end
 
     def set_exit_status!
-        # We want to make sure $? is set, this is the only way I know how.
-        Kernel.system '' if $?.nil?
+        # We want to make sure $CHILD_STATUS is set, this is the only way I know how.
+        Kernel.system '' if $CHILD_STATUS.nil?
     end
 end
 
diff --git a/test/ral/type/cron.rb b/test/ral/type/cron.rb
index fc2d03e..bd334f2 100755
--- a/test/ral/type/cron.rb
+++ b/test/ral/type/cron.rb
@@ -40,7 +40,7 @@ class TestCron < Test::Unit::TestCase
             tab = Puppet::Type.type(:cron).filetype.read(@me)
         }
 
-        if $? == 0
+        if $CHILD_STATUS == 0
             @currenttab = tab
         else
             @currenttab = nil
diff --git a/test/ral/type/host.rb b/test/ral/type/host.rb
index 81a4c08..b6c4d9c 100755
--- a/test/ral/type/host.rb
+++ b/test/ral/type/host.rb
@@ -130,7 +130,7 @@ class TestHost < Test::Unit::TestCase
         host = mkhost()
 
         assert_raise(Puppet::Error) {
-            host[:name] = "!invalid.hostname.$$$"
+            host[:name] = "!invalid.hostname.$PID$"
         }
 
         assert_raise(Puppet::Error) {
diff --git a/test/ral/type/zone.rb b/test/ral/type/zone.rb
index eaf850f..d8a191b 100755
--- a/test/ral/type/zone.rb
+++ b/test/ral/type/zone.rb
@@ -249,7 +249,7 @@ end
 }
     end
 
-    assert_equal(0, $?, "Did not successfully create zone")
+    assert_equal(0, $CHILD_STATUS, "Did not successfully create zone")
 
     hash = nil
     assert_nothing_raised {
diff --git a/test/util/subclass_loader.rb b/test/util/subclass_loader.rb
index ca2522d..622f9c3 100755
--- a/test/util/subclass_loader.rb
+++ b/test/util/subclass_loader.rb
@@ -17,8 +17,8 @@ class TestPuppetUtilSubclassLoader < Test::Unit::TestCase
         # Make a fake client
         unless defined?(@basedir)
             @basedir ||= tempfile()
-            $: << @basedir
-            cleanup { $:.delete(@basedir) if $:.include?(@basedir) }
+            $LOAD_PATH << @basedir
+            cleanup { $LOAD_PATH.delete(@basedir) if $LOAD_PATH.include?(@basedir) }
         end
 
         libdir = File.join([@basedir, path.split(File::SEPARATOR)].flatten)

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list