4 # A support module for testing files.
5 module PuppetSpec::Files
6 # This code exists only to support tests that run as root, pretty much.
7 # Once they have finally been eliminated this can all go... --daniel 2011-04-08
8 if Puppet.features.posix? then
10 path =~ /^\/tmp/ or path =~ /^\/var\/folders/
12 elsif Puppet.features.microsoft_windows?
14 tempdir = File.expand_path(File.join(Dir::LOCAL_APPDATA, "Temp"))
18 fail "Help! Can't find in_tmp for this platform"
22 $global_tempfiles ||= []
23 while path = $global_tempfiles.pop do
24 fail "Not deleting tmpfile #{path} outside regular tmpdir" unless in_tmp(path)
27 FileUtils.rm_r path, :secure => true
35 # Generate a temporary file, just for the name...
36 source = Tempfile.new(name)
40 # ...record it for cleanup,
41 $global_tempfiles ||= []
42 $global_tempfiles << File.expand_path(path)
50 FileUtils.mkdir_p(path)