diff options
author | Daniel Pittman <daniel@rimspace.net> | 2011-03-03 10:35:27 -0800 |
---|---|---|
committer | Daniel Pittman <daniel@rimspace.net> | 2011-03-03 16:29:24 -0800 |
commit | f490526726a5f35437cda11652ae9977d89279e5 (patch) | |
tree | 1746dfc20ee292aa5e268aa62441af46523d8d3c /spec/lib/puppet_spec | |
parent | 6b8f1b724d08e62af6fcf6a2ea55d72b74876de3 (diff) | |
download | puppet-f490526726a5f35437cda11652ae9977d89279e5.tar.gz puppet-f490526726a5f35437cda11652ae9977d89279e5.tar.xz puppet-f490526726a5f35437cda11652ae9977d89279e5.zip |
(#6582) move more helper code into methods, out of RSpec#configure
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 <nick@puppetlabs.com>
Diffstat (limited to 'spec/lib/puppet_spec')
-rw-r--r-- | spec/lib/puppet_spec/files.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/lib/puppet_spec/files.rb b/spec/lib/puppet_spec/files.rb index 52ed903ec..38c51a572 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 |