summaryrefslogtreecommitdiff
path: root/cpan/autodie/t
diff options
context:
space:
mode:
authorChris 'BinGOs' Williams <chris@bingosnet.co.uk>2015-06-12 11:58:41 +0100
committerChris 'BinGOs' Williams <chris@bingosnet.co.uk>2015-06-12 18:26:37 +0100
commit35c0561a7bae0fd58527c372c899da0d87f75d37 (patch)
treea9d7e8212c73be1b0f332e440d69ccf000a0bd4b /cpan/autodie/t
parentf3f2f486c173c975f5389913bb2b5b16f4ffd6cb (diff)
downloadperl-35c0561a7bae0fd58527c372c899da0d87f75d37.tar.gz
Update autodie to CPAN version 2.27
[DELTA] 2.27 2015-06-10 19:19:49+10:00 Australia/Melbourne * DEPRECATION: Deprecate the use of "Fatal qw(:lexcial)". It is an implementation detail of autodie and is about to change. * SPEED: Allow wrappers for CORE::exec and CORE::system to be reused as they are not dependent on the calling package. * TEST: Avoid hard-coded directory separator in t/system.t. Thanks to A. Sinan Unur for reporting it and providing a patch. (GH#62) * TEST: Add missing "require autodie" in import-into test and ensure Import::Into remains an optional test dependency. * TEST / INTERNAL / TRAVIS: Set "sudo: false" to gain access to the Travis container based infrastructure. * TEST: Bump version of Import::Into to 1.002004 as older versions are insufficient for our test. Thanks to Olivier Mengué for reporting it. (RT#101377)
Diffstat (limited to 'cpan/autodie/t')
-rwxr-xr-xcpan/autodie/t/chmod.t9
-rw-r--r--cpan/autodie/t/dbmopen.t14
-rw-r--r--cpan/autodie/t/internal.t41
-rw-r--r--cpan/autodie/t/lib/my/pragma.pm1
-rw-r--r--cpan/autodie/t/mkdir.t18
5 files changed, 63 insertions, 20 deletions
diff --git a/cpan/autodie/t/chmod.t b/cpan/autodie/t/chmod.t
index 9093b52c4f..00715aee3c 100755
--- a/cpan/autodie/t/chmod.t
+++ b/cpan/autodie/t/chmod.t
@@ -1,13 +1,20 @@
#!/usr/bin/perl -w
use strict;
-use Test::More tests => 4;
+use Test::More tests => 7;
use constant NO_SUCH_FILE => "this_file_had_better_not_exist";
+use constant ERROR_REGEXP => qr{Can't chmod\(0755, '${\(NO_SUCH_FILE)}'\):};
+use constant SINGLE_DIGIT_ERROR_REGEXP => qr{Can't chmod\(0010, '${\(NO_SUCH_FILE)}'\):};
use autodie;
# This tests RT #50423, Debian #550462
eval { chmod(0755, NO_SUCH_FILE); };
isa_ok($@, 'autodie::exception', 'exception thrown for chmod');
+like($@, ERROR_REGEXP, "Message should include numeric mode in octal form");
+
+eval { chmod(8, NO_SUCH_FILE); };
+isa_ok($@, 'autodie::exception', 'exception thrown for chmod');
+like($@, SINGLE_DIGIT_ERROR_REGEXP, "Message should include numeric mode in octal form");
eval { chmod(0755, $0); };
ok(! $@, "We can chmod ourselves just fine.");
diff --git a/cpan/autodie/t/dbmopen.t b/cpan/autodie/t/dbmopen.t
index 31698e65be..5083f38e01 100644
--- a/cpan/autodie/t/dbmopen.t
+++ b/cpan/autodie/t/dbmopen.t
@@ -1,8 +1,9 @@
#!/usr/bin/perl -w
use strict;
-use Test::More qw(no_plan);
+use Test::More tests => 9;
use constant ERROR_REGEXP => qr{Can't dbmopen\(%hash, 'foo/bar/baz', 0666\):};
+use constant SINGLE_DIGIT_ERROR_REGEXP => qr{Can't dbmopen\(%hash, 'foo/bar/baz', 0010\):};
my $return = "default";
@@ -27,6 +28,17 @@ like($@, ERROR_REGEXP, "Message should include number in octal, not decimal");
eval {
use autodie;
+ dbmopen(my %foo, "foo/bar/baz", 8);
+};
+
+ok($@, "autodie allows dbmopen to throw errors.");
+isa_ok($@, "autodie::exception", "... errors are of the correct type");
+
+like($@, SINGLE_DIGIT_ERROR_REGEXP, "Message should include number in octal, not decimal");
+
+eval {
+ use autodie;
+
my %bar = ( foo => 1, bar => 2 );
dbmopen(%bar, "foo/bar/baz", 0666);
diff --git a/cpan/autodie/t/internal.t b/cpan/autodie/t/internal.t
index 3853044107..c4e5abc2ce 100644
--- a/cpan/autodie/t/internal.t
+++ b/cpan/autodie/t/internal.t
@@ -1,32 +1,46 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use strict;
use Scalar::Util qw(blessed);
use constant NO_SUCH_FILE => "this_file_or_dir_had_better_not_exist_XYZZY";
-use Test::More tests => 9;
+use Test::More tests => 7;
+
+use Fatal();
+
+# Silence the warnings from using Fatal qw(:lexical)
# Lexical tests using the internal interface.
-eval { Fatal->import(qw(:lexical :void)) };
+my @warnings;
+eval {
+ # Filter out deprecation warning (no warnings qw(deprecated) does
+ # not seem to work for some reason)
+ local $SIG{'__WARN__'} = sub {
+ push(@warnings, @_) unless $_[0] =~ m/Fatal qw\(:lexical/;
+ };
+ Fatal->import(qw(:lexical :void))
+};
like($@, qr{:void cannot be used with lexical}, ":void can't be used with :lexical");
+warn($_) while shift @warnings;
eval { Fatal->import(qw(open close :lexical)) };
like($@, qr{:lexical must be used as first}, ":lexical must come first");
{
- use Fatal qw(:lexical chdir);
-
+ BEGIN {
+ # Filter out deprecation warning (no warnings qw(deprecated) does
+ # not seem to work for some reason)
+ local $SIG{'__WARN__'} = sub {
+ push(@warnings, @_) unless $_[0] =~ m/Fatal qw\(:lexical/;
+ };
+ import Fatal qw(:lexical chdir);
+ };
+ warn($_) while shift @warnings;
eval { chdir(NO_SUCH_FILE); };
my $err = $@;
like ($err, qr/^Can't chdir/, "Lexical fatal chdir");
- TODO: {
- local $TODO = 'Fatal should not (but does) throw autodie::exceptions';
- is(blessed($err), undef,
- "Fatal does not throw autodie::exceptions");
- }
-
{
no Fatal qw(:lexical chdir);
eval { chdir(NO_SUCH_FILE); };
@@ -36,11 +50,6 @@ like($@, qr{:lexical must be used as first}, ":lexical must come first");
eval { chdir(NO_SUCH_FILE); };
$err = $@;
like ($err, qr/^Can't chdir/, "Lexical fatal chdir returns");
- TODO: {
- local $TODO = 'Fatal should not (but does) throw autodie::exceptions';
- is(blessed($err), undef,
- "Fatal does not throw autodie::exceptions");
- }
}
eval { chdir(NO_SUCH_FILE); };
diff --git a/cpan/autodie/t/lib/my/pragma.pm b/cpan/autodie/t/lib/my/pragma.pm
index 185d54fb93..3df2ced251 100644
--- a/cpan/autodie/t/lib/my/pragma.pm
+++ b/cpan/autodie/t/lib/my/pragma.pm
@@ -1,5 +1,6 @@
package my::pragma;
+require autodie;
use Import::Into qw(into);
sub import {
diff --git a/cpan/autodie/t/mkdir.t b/cpan/autodie/t/mkdir.t
index 7bd6529086..a5586bed34 100644
--- a/cpan/autodie/t/mkdir.t
+++ b/cpan/autodie/t/mkdir.t
@@ -3,6 +3,8 @@ use strict;
use Test::More;
use FindBin qw($Bin);
use constant TMPDIR => "$Bin/mkdir_test_delete_me";
+use constant ERROR_REGEXP => qr{Can't mkdir\('${\(TMPDIR)}', 0777\):};
+use constant SINGLE_DIGIT_ERROR_REGEXP => qr{Can't mkdir\('${\(TMPDIR)}', 0010\):};
# Delete our directory if it's there
rmdir TMPDIR;
@@ -25,7 +27,7 @@ if(-d TMPDIR) { plan skip_all => "Failed to delete test directory"; }
# Try to delete second time
if(rmdir TMPDIR) { plan skip_all => "Able to rmdir directory twice"; }
-plan tests => 12;
+plan tests => 18;
# Create a directory (this should succeed)
eval {
@@ -40,12 +42,24 @@ ok(-d TMPDIR, "Successfully created test directory");
eval {
use autodie;
- mkdir TMPDIR;
+ mkdir TMPDIR, 0777;
+};
+ok($@, "Re-creating directory causes failure.");
+isa_ok($@, "autodie::exception", "... errors are of the correct type");
+ok($@->matches("mkdir"), "... it's also a mkdir object");
+ok($@->matches(":filesys"), "... and a filesys object");
+like($@, ERROR_REGEXP, "Message should include numeric mask in octal form");
+
+eval {
+ use autodie;
+
+ mkdir TMPDIR, 8;
};
ok($@, "Re-creating directory causes failure.");
isa_ok($@, "autodie::exception", "... errors are of the correct type");
ok($@->matches("mkdir"), "... it's also a mkdir object");
ok($@->matches(":filesys"), "... and a filesys object");
+like($@, SINGLE_DIGIT_ERROR_REGEXP, "Message should include numeric mask in octal form");
# Try to delete directory (this should succeed)
eval {