1#!/usr/bin/perl -w 2use strict; 3use Test::More tests => 7; 4use constant NO_SUCH_FILE => "this_file_had_better_not_exist"; 5use constant ERROR_REGEXP => qr{Can't chmod\(0755, '${\(NO_SUCH_FILE)}'\):}; 6use constant SINGLE_DIGIT_ERROR_REGEXP => qr{Can't chmod\(0010, '${\(NO_SUCH_FILE)}'\):}; 7use autodie; 8 9# This tests RT #50423, Debian #550462 10 11eval { chmod(0755, NO_SUCH_FILE); }; 12isa_ok($@, 'autodie::exception', 'exception thrown for chmod'); 13like($@, ERROR_REGEXP, "Message should include numeric mode in octal form"); 14 15eval { chmod(8, NO_SUCH_FILE); }; 16isa_ok($@, 'autodie::exception', 'exception thrown for chmod'); 17like($@, SINGLE_DIGIT_ERROR_REGEXP, "Message should include numeric mode in octal form"); 18 19eval { chmod(0755, $0); }; 20ok(! $@, "We can chmod ourselves just fine."); 21 22eval { chmod(0755, $0, NO_SUCH_FILE) }; 23isa_ok($@, 'autodie::exception', 'chmod exception on any file failure.'); 24is($@->return,1,"Confirm autodie on a 'true' chown failure."); 25