diff options
author | Chris Price <chris@puppetlabs.com> | 2012-06-26 17:44:39 -0700 |
---|---|---|
committer | Chris Price <chris@puppetlabs.com> | 2012-06-26 17:44:39 -0700 |
commit | 29f8f89c19b2189aa78ab430e94671669cb4716c (patch) | |
tree | 51b8c47d5576217b4bc8bf45510f38790b43b806 /spec/lib/puppet_spec/files.rb | |
parent | e299ac6212b0468426f971b216447ef6bc679149 (diff) | |
parent | d9410f72e416da15eb1660d15ba2b4288ccc0873 (diff) | |
download | puppet-stdlib-29f8f89c19b2189aa78ab430e94671669cb4716c.tar.gz puppet-stdlib-29f8f89c19b2189aa78ab430e94671669cb4716c.tar.bz2 |
Merge pull request #73 from branan/use_spechelper_gem
Update for new gem version of puppetlabs_spec_helper
Diffstat (limited to 'spec/lib/puppet_spec/files.rb')
-rwxr-xr-x | spec/lib/puppet_spec/files.rb | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/spec/lib/puppet_spec/files.rb b/spec/lib/puppet_spec/files.rb deleted file mode 100755 index 30fb4fc..0000000 --- a/spec/lib/puppet_spec/files.rb +++ /dev/null @@ -1,53 +0,0 @@ -require 'fileutils' -require 'tempfile' - -# A support module for testing files. -module PuppetSpec::Files - # This code exists only to support tests that run as root, pretty much. - # Once they have finally been eliminated this can all go... --daniel 2011-04-08 - if Puppet.features.posix? then - def self.in_tmp(path) - path =~ /^\/tmp/ or path =~ /^\/var\/folders/ - end - elsif Puppet.features.microsoft_windows? - def self.in_tmp(path) - tempdir = File.expand_path(File.join(Dir::LOCAL_APPDATA, "Temp")) - path =~ /^#{tempdir}/ - end - else - fail "Help! Can't find in_tmp for this platform" - end - - def self.cleanup - $global_tempfiles ||= [] - while path = $global_tempfiles.pop do - fail "Not deleting tmpfile #{path} outside regular tmpdir" unless in_tmp(path) - - begin - FileUtils.rm_r path, :secure => true - rescue Errno::ENOENT - # nothing to do - end - end - end - - def tmpfile(name) - # Generate a temporary file, just for the name... - source = Tempfile.new(name) - path = source.path - source.close! - - # ...record it for cleanup, - $global_tempfiles ||= [] - $global_tempfiles << File.expand_path(path) - - # ...and bam. - path - end - - def tmpdir(name) - path = tmpfile(name) - FileUtils.mkdir_p(path) - path - end -end |