summaryrefslogtreecommitdiff
path: root/lib/Temp/File-Temp-0.12/t/tempfile.t
diff options
context:
space:
mode:
authorAndreas Mair <amair.sob@googlemail.com>2005-03-21 11:57:02 +0100
committerAndreas Mair <amair.sob@googlemail.com>2005-03-21 11:57:02 +0100
commit5083c05ce2e2bfc5719346d809719ebf01b0e69d (patch)
tree71e65c65489eebc70a366006be250529a97b5410 /lib/Temp/File-Temp-0.12/t/tempfile.t
parent7525bed2d315a25ac2caf95ff0bf44c905d58a7e (diff)
downloadvdradmin-am-5083c05ce2e2bfc5719346d809719ebf01b0e69d.tar.gz
vdradmin-am-5083c05ce2e2bfc5719346d809719ebf01b0e69d.tar.bz2
2005-03-20: 0.97-am2v0.97-am2
- TV and remote templates have same remote control. Added patches: - fix for timers.conf of vdr1.3.23+ (Submitted by x-stefan @vdrportal.de) - Localnet Patch; no password request if client ip in given ip range) (Submitted by "Reiner Buehl" <reiner@buehl.net>) 2005-03-19: Templates cleanup: - timer_list.html - timer_new.html - toolbar.html - tv_flash.html - tv.html 2005-03-18: - reworked summary display of recordings - summary editbox preserves linefeeds while editing timers Templates cleanup: - prog_timeline.html - rc.html - rec_edit.html - rec_list.html 2005-03-12: - Added stream button in prog_summmary (suggested by Unimatrix0 @vdrportal.de) Templates cleanup: - at_new.html - at_timer_list.html - config.html - error.html - index.html - left.html - noauth.html - noperm.html - prog_details.html (TODO) - prog_list2.html - prog_list.html - prog_summary.html (TODO) Added patches: - vdradmin-0.96_For_vdr-1.3_StoreAutotimerChannelID_And_EventIdCheckDisable.diff (posted at the VDR mailinglist by "Rantanen Teemu" <teemu.rantanen@tekla.com>) - vdradmin-0.96_OneShot_Timers_English_Only.diff and merged it to "Deutsch" template (posted at the VDR mailinglist by "Rantanen Teemu" <teemu.rantanen@tekla.com>) - included changes from vdradmin-0.96-3-ctvdr-1 (see HISTORY.ct). Changes that have been forgotten while merging previous patches: - Fixed: timer listing now shows "VPS" instead of "Auto (alt)". - removed unneeded <br>. They are still used for display only.
Diffstat (limited to 'lib/Temp/File-Temp-0.12/t/tempfile.t')
-rw-r--r--lib/Temp/File-Temp-0.12/t/tempfile.t140
1 files changed, 140 insertions, 0 deletions
diff --git a/lib/Temp/File-Temp-0.12/t/tempfile.t b/lib/Temp/File-Temp-0.12/t/tempfile.t
new file mode 100644
index 0000000..6e3fa94
--- /dev/null
+++ b/lib/Temp/File-Temp-0.12/t/tempfile.t
@@ -0,0 +1,140 @@
+#!/usr/local/bin/perl -w
+# Test for File::Temp - tempfile function
+
+use strict;
+use Test;
+BEGIN { plan tests => 20}
+use File::Spec;
+
+# Will need to check that all files were unlinked correctly
+# Set up an END block here to do it
+
+# Arrays containing list of dirs/files to test
+my (@files, @dirs, @still_there);
+
+# And a test for files that should still be around
+# These are tidied up
+END {
+ foreach (@still_there) {
+ ok( -f $_ );
+ ok( unlink( $_ ) );
+ ok( !(-f $_) );
+ }
+}
+
+# Loop over an array hoping that the files dont exist
+END { foreach (@files) { ok( !(-e $_) )} }
+
+# And a test for directories
+END { foreach (@dirs) { ok( !(-d $_) )} }
+
+# 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
+use File::Temp qw/ tempfile tempdir/;
+
+# Now we start the tests properly
+ok(1);
+
+
+# Tempfile
+# Open tempfile in some directory, unlink at end
+my ($fh, $tempfile) = tempfile(
+ UNLINK => 1,
+ SUFFIX => '.txt',
+ );
+
+ok( (-f $tempfile) );
+# Should still be around after closing
+ok( close( $fh ) );
+ok( (-f $tempfile) );
+# Check again at exit
+push(@files, $tempfile);
+
+# TEMPDIR test
+# Create temp directory in current dir
+my $template = 'tmpdirXXXXXX';
+print "# Template: $template\n";
+my $tempdir = tempdir( $template ,
+ DIR => File::Spec->curdir,
+ CLEANUP => 1,
+ );
+
+print "# TEMPDIR: $tempdir\n";
+
+ok( (-d $tempdir) );
+push(@dirs, $tempdir);
+
+# Create file in the temp dir
+($fh, $tempfile) = tempfile(
+ DIR => $tempdir,
+ UNLINK => 1,
+ SUFFIX => '.dat',
+ );
+
+print "# TEMPFILE: Created $tempfile\n";
+
+ok( (-f $tempfile));
+push(@files, $tempfile);
+
+# Test tempfile
+# ..and again
+($fh, $tempfile) = tempfile(
+ DIR => $tempdir,
+ );
+
+
+ok( (-f $tempfile ));
+push(@files, $tempfile);
+
+print "# TEMPFILE: Created $tempfile\n";
+
+# and another (with template)
+
+($fh, $tempfile) = tempfile( 'helloXXXXXXX',
+ DIR => $tempdir,
+ UNLINK => 1,
+ SUFFIX => '.dat',
+ );
+
+print "# TEMPFILE: Created $tempfile\n";
+
+ok( (-f $tempfile) );
+push(@files, $tempfile);
+
+
+# Create a temporary file that should stay around after
+# it has been closed
+($fh, $tempfile) = tempfile( 'permXXXXXXX', UNLINK => 0 );
+print "# TEMPFILE: Created $tempfile\n";
+ok( -f $tempfile );
+ok( close( $fh ) );
+push( @still_there, $tempfile); # check at END
+
+# 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
+$fh = eval { tempfile( 'ftmpXXXXX', DIR => File::Spec->tmpdir ) };
+
+if ($fh) {
+
+ # print something to it to make sure something is there
+ ok( print $fh "Test\n" );
+
+ # Close it - can not check it is gone since we dont know the name
+ ok( close($fh) );
+
+} else {
+ skip "Skip Failed probably due to NFS", 1;
+ skip "Skip Failed probably due to NFS", 1;
+}
+
+# Now END block will execute to test the removal of directories
+print "# End of tests. Execute END blocks\n";
+