Please review pull request #139: Add "puppet-acceptance" to base tmp dir path opened by (cprice-puppet)

Description:

This pull request is no big deal; if you guys don't want it, that's cool. I'm just trying to separate out my changes related to ticket #6162 into smaller bits that can be reviewed / accepted / rejected independently. :)


This commit just changes the default "root" temp dir for acceptance
tests from "/tmp" to "/tmp/puppet-acceptance". The goal here is to
quarantine acceptance test temp files into one easily-identifiable
directory that can be cleaned up.

This would only affect tests that were calling the *::File.tmpdir
methods, and should have no effect on the success or failure of any
tests.

  • Opened: Fri Feb 10 00:22:11 UTC 2012
  • Based on: puppetlabs:master (8bb6c4da906ed079730cd2592cc731093ae8fe5d)
  • Requested merge: cprice-puppet:quarantine-tempfiles (130985992aae213637683de524f8f0376ec14b04)

Diff follows:

diff --git a/lib/host/unix/file.rb b/lib/host/unix/file.rb
index 7227651..36a30d5 100644
--- a/lib/host/unix/file.rb
+++ b/lib/host/unix/file.rb
@@ -2,14 +2,35 @@ module Unix::File
   include CommandFactory
 
   def tmpfile(name)
-    execute("mktemp -t #{name}.XXXXXX")
+    execute("mktemp --tmpdir=#{base_tmpdir} -t #{name}.XXXXXX")
   end
 
   def tmpdir(name)
-    execute("mktemp -td #{name}.XXXXXX")
+    execute("mktemp --tmpdir=#{base_tmpdir} -td #{name}.XXXXXX")
   end
 
   def path_split(paths)
     paths.split(':')
   end
+
+
+
+  # private utility method to get the base temp dir path; the goal here is to quarantine acceptance test temp files into
+  # one easily-identifiable directory that can be cleaned up easily
+  def base_tmpdir()
+    unless @base_tmp_dir then
+      @base_tmp_dir = "#{get_system_tmpdir}/puppet-acceptance"
+      mkdirs(@base_tmp_dir)
+    end
+    @base_tmp_dir
+  end
+  private :base_tmpdir
+
+  # private utility method for determining the system tempdir
+  def get_system_tmpdir()
+    # hard-coded for now, but this could execute a command on the system to check environment variables, etc.
+    "/tmp"
+  end
+  private :get_system_tmpdir
+
 end
diff --git a/lib/host/windows/file.rb b/lib/host/windows/file.rb
index 60b7d3d..d66af72 100644
--- a/lib/host/windows/file.rb
+++ b/lib/host/windows/file.rb
@@ -2,14 +2,32 @@ module Windows::File
   include CommandFactory
 
   def tmpfile(name)
-    execute("cygpath -m $(mktemp -t #{name}.XXXXXX)")
+    execute("cygpath -m $(mktemp --tmpdir=#{base_tmpdir} -t #{name}.XXXXXX)")
   end
 
   def tmpdir(name)
-    execute("cygpath -m $(mktemp -td #{name}.XXXXXX)")
+    execute("cygpath -m $(mktemp --tmpdir=#{base_tmpdir} -td #{name}.XXXXXX)")
   end
 
   def path_split(paths)
     paths.split(';')
   end
+
+  # private utility method to get the base temp dir path; the goal here is to quarantine acceptance test temp files into
+  # one easily-identifiable directory that can be cleaned up easily
+  def base_tmpdir()
+    unless @base_tmp_dir then
+      @base_tmp_dir = "#{get_system_tmpdir}/puppet-acceptance"
+      mkdirs(@base_tmp_dir)
+    end
+    @base_tmp_dir
+  end
+  private :base_tmpdir
+
+  # private utility method for determining the system tempdir
+  def get_system_tmpdir()
+    # hard-coded for now, but this could execute a command on the system to check environment variables, etc.
+    "/tmp"
+  end
+  private :get_system_tmpdir
 end

    

--
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