Automatically clean up your filesystem after tests
Version: 0.03Test::File::Cleaner is a Perl module to automatically clean up your filesystem after tests.
License: Perl Artistic License
Operating System: Linux
# Create the cleaner
my $Cleaner = Test::File::Cleaner->new( 'file_dmz' );
# Do some tests that create files
# Cleaner cleans when it is DESTROYed
# Alternatively, force an immediate clean up
When writing file-related testing code, it is common to end up with a number of files scattered all over the testing directories. If you are running the test scripts over and over these leftover files can interfere with subsequent test runs, and so they need to be cleaned up.
This clean up code typically needs to be done at END-time, so that the files are cleaned up even if you break out of the test script while it is running. The code to do this can get long and is labourious to maintain.
Test::File::Cleaner attempts to solve this problem. When you create a Cleaner object for a particular directory, the object scans and saves the contents of the directory.
When the object is DESTROYed, it compares the current state to the original, and removes any new files and directories created during the testing process.