This convenience function causes files to be removed in the same
way that tempfile() does.
It uses the same variable that tempfile() does, to catch and
warn on any collisions.
die "Can't find temporary file name starting \"tmp$$\"";
}
+# register_tempfile - Adds a list of files to be removed at the end of the current test file
+# Arguments :
+# a list of files to be removed later
+
+# returns a count of how many file names were actually added
+
+# Reuses %tmpfiles so that tempfile() will also skip any files added here
+# even if the file doesn't exist yet.
+
+sub register_tempfile {
+ my $count = 0;
+ for( @_ ){
+ if( $tmpfiles{$_} ){
+ _print_stderr "# Temporary file '$_' already added\n";
+ }else{
+ $tmpfiles{$_} = 1;
+ $count = $count + 1;
+ }
+ }
+ return $count;
+}
+
# This is the temporary file for _fresh_perl
my $tmpfile = tempfile();
}
}
-skip_files(20,'Y','Z');
+ok( register_tempfile("${prefix}F"), 'registered the next file with register_tempfile' );
+is( tempfile(), "${prefix}G", 'tempfile() properly skips files added with register_tempfile()' );
+
+skip_files(18,'Y','Z');
is( tempfile(), "${prefix}Z", 'Last single letter filename');
is( tempfile(), "${prefix}AA", 'First double letter filename');