File: perms.t

package info (click to toggle)
libfile-slurp-perl 9999.19-4
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 340 kB
  • ctags: 40
  • sloc: perl: 1,671; makefile: 39
file content (31 lines) | stat: -rw-r--r-- 534 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/local/bin/perl -w

use strict ;
use Test::More ;
use File::Slurp ;

plan skip_all => "meaningless on Win32" if $^O =~ /win32/i ;
plan tests => 2 ;

my $file = "perms.$$" ;

my $text = <<END ;
This is a bit of contents
to store in a file.
END

umask 027 ;

write_file( $file, $text ) ;
is( getmode( $file ), 0640, 'default perms works' ) ;
unlink $file ;

write_file( $file, { perms => 0777 }, $text ) ;
is( getmode( $file ), 0750, 'set perms works' ) ;
unlink $file ;

exit ;

sub getmode {
	return 07777 & (stat $_[0])[2] ;
}