From: Daniel Pittman <[email protected]>

We move the tempfile cleanup support off into the module that uses it, which
removes some of the dependency on magic globals from configure.  It still
exists, but is hidden in the same module that uses it, which helps.

Reviewed-By: Nick Lewis <[email protected]>
---
 spec/lib/puppet_spec/files.rb |   23 +++++++++++++++++++++++
 spec/spec_helper.rb           |   21 +--------------------
 2 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/spec/lib/puppet_spec/files.rb b/spec/lib/puppet_spec/files.rb
index 52ed903..38c51a5 100644
--- a/spec/lib/puppet_spec/files.rb
+++ b/spec/lib/puppet_spec/files.rb
@@ -3,6 +3,29 @@ require 'tempfile'
 
 # A support module for testing files.
 module PuppetSpec::Files
+  def self.cleanup
+    if defined?($tmpfiles)
+      $tmpfiles.each do |file|
+        file = File.expand_path(file)
+        if Puppet.features.posix? and file !~ /^\/tmp/ and file !~ 
/^\/var\/folders/
+          puts "Not deleting tmpfile #{file} outside of /tmp or /var/folders"
+          next
+        elsif Puppet.features.microsoft_windows?
+          tempdir = File.expand_path(File.join(Dir::LOCAL_APPDATA, "Temp"))
+          if file !~ /^#{tempdir}/
+            puts "Not deleting tmpfile #{file} outside of #{tempdir}"
+            next
+          end
+        end
+        if FileTest.exist?(file)
+          system("chmod -R 755 '#{file}'")
+          system("rm -rf '#{file}'")
+        end
+      end
+      $tmpfiles.clear
+    end
+  end
+
   def tmpfile(name)
     source = Tempfile.new(name)
     path = source.path
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index cf5f39b..7f36544 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -55,26 +55,7 @@ RSpec.configure do |config|
     Puppet::Node::Environment.clear
     Puppet::Util::Storage.clear
 
-    if defined?($tmpfiles)
-      $tmpfiles.each do |file|
-        file = File.expand_path(file)
-        if Puppet.features.posix? and file !~ /^\/tmp/ and file !~ 
/^\/var\/folders/
-          puts "Not deleting tmpfile #{file} outside of /tmp or /var/folders"
-          next
-        elsif Puppet.features.microsoft_windows?
-          tempdir = File.expand_path(File.join(Dir::LOCAL_APPDATA, "Temp"))
-          if file !~ /^#{tempdir}/
-            puts "Not deleting tmpfile #{file} outside of #{tempdir}"
-            next
-          end
-        end
-        if FileTest.exist?(file)
-          system("chmod -R 755 '#{file}'")
-          system("rm -rf '#{file}'")
-        end
-      end
-      $tmpfiles.clear
-    end
+    PuppetSpec::Files.cleanup
 
     @logs.clear
     Puppet::Util::Log.close_all
-- 
1.7.4.1

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to