changes
[urisagit/Perl-Docs.git] / t / perms.t
1 #!/usr/local/bin/perl -w
2
3 use strict ;
4 use Test::More ;
5 use File::Slurp ;
6
7 plan skip_all => "meaningless on Win32" if $^O =~ /win32/i ;
8 plan tests => 2 ;
9
10 my $file = "perms.$$" ;
11
12 my $text = <<END ;
13 This is a bit of contents
14 to store in a file.
15 END
16
17 umask 027 ;
18
19 write_file( $file, $text ) ;
20 is( getmode( $file ), 0640, 'default perms works' ) ;
21 unlink $file ;
22
23 write_file( $file, { perms => 0777 }, $text ) ;
24 is( getmode( $file ), 0750, 'set perms works' ) ;
25 unlink $file ;
26
27 exit ;
28
29 sub getmode {
30         return 07777 & (stat $_[0])[2] ;
31 }