# Test for File::Temp - tempfile function
use strict;
use Test;
# Will need to check that all files were unlinked correctly
# Set up an END block here to do it
# And a test for files that should still be around
# These are tidied up
END {
}
}
# Loop over an array hoping that the files dont exist
# And a test for directories
# Need to make sure that the END blocks are setup before
# the ones that File::Temp configures since END blocks are evaluated
# in revers order and we need to check the files *after* File::Temp
# removes them
# Now we start the tests properly
# Tempfile
# Open tempfile in some directory, unlink at end
UNLINK => 1,
);
# Should still be around after closing
# Check again at exit
# TEMPDIR test
# Create temp directory in current dir
CLEANUP => 1,
);
# Create file in the temp dir
UNLINK => 1,
);
# Test tempfile
# ..and again
);
# Test tempfile
# ..and another with changed permissions (read-only)
);
# and another (with template)
UNLINK => 1,
);
# Create a temporary file that should stay around after
# it has been closed
# Would like to create a temp file and just retrieve the handle
# but the test is problematic since:
# - We dont know the filename so we cant check that it is tidied
# correctly
# - The unlink0 required on unix for tempfile creation will fail
# on NFS
# Try to do what we can.
# Tempfile croaks on error so we need an eval
# print something to it to make sure something is there
# Close it - can not check it is gone since we dont know the name
} else {
}
# Now END block will execute to test the removal of directories
print "# End of tests. Execute END blocks\n";