Blame t/chmod.t

Packit 6427f8
#!/usr/bin/perl -w
Packit 6427f8
use strict;
Packit 6427f8
use Test::More tests => 7;
Packit 6427f8
use constant NO_SUCH_FILE => "this_file_had_better_not_exist";
Packit 6427f8
use constant ERROR_REGEXP => qr{Can't chmod\(0755, '${\(NO_SUCH_FILE)}'\):};
Packit 6427f8
use constant SINGLE_DIGIT_ERROR_REGEXP => qr{Can't chmod\(0010, '${\(NO_SUCH_FILE)}'\):};
Packit 6427f8
use autodie;
Packit 6427f8
Packit 6427f8
# This tests RT #50423, Debian #550462
Packit 6427f8
Packit 6427f8
eval { chmod(0755, NO_SUCH_FILE); };
Packit 6427f8
isa_ok($@, 'autodie::exception', 'exception thrown for chmod');
Packit 6427f8
like($@, ERROR_REGEXP, "Message should include numeric mode in octal form");
Packit 6427f8
Packit 6427f8
eval { chmod(8, NO_SUCH_FILE); };
Packit 6427f8
isa_ok($@, 'autodie::exception', 'exception thrown for chmod');
Packit 6427f8
like($@, SINGLE_DIGIT_ERROR_REGEXP, "Message should include numeric mode in octal form");
Packit 6427f8
Packit 6427f8
eval { chmod(0755, $0); };
Packit 6427f8
ok(! $@, "We can chmod ourselves just fine.");
Packit 6427f8
Packit 6427f8
eval { chmod(0755, $0, NO_SUCH_FILE) };
Packit 6427f8
isa_ok($@, 'autodie::exception', 'chmod exception on any file failure.');
Packit 6427f8
is($@->return,1,"Confirm autodie on a 'true' chown failure.");