Deprecate shellwords.pl with a warning
[p5sagit/p5-mst-13.2.git] / lib / autodie / t / mkdir.t
CommitLineData
0b09a93a 1#!/usr/bin/perl -w
2use strict;
3use Test::More;
4use FindBin qw($Bin);
5use constant TMPDIR => "$Bin/mkdir_test_delete_me";
6
7# Delete our directory if it's there
8rmdir TMPDIR;
9
10# See if we can create directories and remove them
11mkdir TMPDIR or plan skip_all => "Failed to make test directory";
12
13# Test the directory was created
14-d TMPDIR or plan skip_all => "Failed to make test directory";
15
16# Try making it a second time (this should fail)
17if(mkdir TMPDIR) { plan skip_all => "Attempt to remake a directory succeeded";}
18
19# See if we can remove the directory
20rmdir TMPDIR or plan skip_all => "Failed to remove directory";
21
22# Check that the directory was removed
23if(-d TMPDIR) { plan skip_all => "Failed to delete test directory"; }
24
25# Try to delete second time
26if(rmdir TMPDIR) { plan skip_all => "Able to rmdir directory twice"; }
27
28plan tests => 12;
29
30# Create a directory (this should succeed)
31eval {
32 use autodie;
33
34 mkdir TMPDIR;
35};
36is($@, "", "mkdir returned success");
37ok(-d TMPDIR, "Successfully created test directory");
38
39# Try to create it again (this should fail)
40eval {
41 use autodie;
42
43 mkdir TMPDIR;
44};
45ok($@, "Re-creating directory causes failure.");
46isa_ok($@, "autodie::exception", "... errors are of the correct type");
47ok($@->matches("mkdir"), "... it's also a mkdir object");
48ok($@->matches(":filesys"), "... and a filesys object");
49
50# Try to delete directory (this should succeed)
51eval {
52 use autodie;
53
54 rmdir TMPDIR;
55};
56is($@, "", "rmdir returned success");
57ok(! -d TMPDIR, "Successfully removed test directory");
58
59# Try to delete directory again (this should fail)
60eval {
61 use autodie;
62
63 rmdir TMPDIR;
64};
65ok($@, "Re-deleting directory causes failure.");
66isa_ok($@, "autodie::exception", "... errors are of the correct type");
67ok($@->matches("rmdir"), "... it's also a rmdir object");
68ok($@->matches(":filesys"), "... and a filesys object");
69