File: write.t

package info (click to toggle)
libfile-chmod-perl 0.42-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 224 kB
  • sloc: perl: 476; makefile: 2
file content (23 lines) | stat: -rw-r--r-- 558 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
use strict;
use warnings;
use Test::More;
use English '-no_match_vars';
use File::Temp ();
use File::chmod qw( chmod getmod );
$File::chmod::UMASK = 0;

plan skip_all => "Windows perms work differently" if $OSNAME eq 'MSWin32';

my $tmp = File::Temp->new;
my $fn  = $tmp->filename;

chmod( 0000, $fn );
note sprintf "state of %s: %o\n", $fn, getmod( $fn );

ok chmod("+w", $fn ), "chmod +w $fn";
is sprintf( '%o', getmod( $fn ) ), 222, "$fn is 222";

ok chmod("-w", $fn ), "chmod -w $fn";
is sprintf( '%o', getmod( $fn ) ), 000, "$fn is 000";

done_testing;