|
Packit |
6427f8 |
#!/usr/bin/perl -w
|
|
Packit |
6427f8 |
use strict;
|
|
Packit |
6427f8 |
use Test::More tests => 4;
|
|
Packit |
6427f8 |
use constant NO_SUCH_FILE => "this_file_had_better_not_exist";
|
|
Packit |
6427f8 |
use FindBin qw($Bin);
|
|
Packit |
6427f8 |
use File::Spec;
|
|
Packit |
6427f8 |
use constant TOUCH_ME => File::Spec->catfile($Bin, 'touch_me');
|
|
Packit |
6427f8 |
use autodie;
|
|
Packit |
6427f8 |
|
|
Packit |
6427f8 |
eval { utime(undef, undef, NO_SUCH_FILE); };
|
|
Packit |
6427f8 |
isa_ok($@, 'autodie::exception', 'exception thrown for utime');
|
|
Packit |
6427f8 |
|
|
Packit |
6427f8 |
my($atime, $mtime) = (stat TOUCH_ME)[8, 9];
|
|
Packit |
6427f8 |
|
|
Packit |
6427f8 |
eval { utime(undef, undef, TOUCH_ME); };
|
|
Packit |
6427f8 |
ok(! $@, "We can utime a file just fine.") or diag $@;
|
|
Packit |
6427f8 |
|
|
Packit |
6427f8 |
eval { utime(undef, undef, NO_SUCH_FILE, TOUCH_ME); };
|
|
Packit |
6427f8 |
isa_ok($@, 'autodie::exception', 'utime exception on single failure.');
|
|
Packit |
6427f8 |
is($@->return, 1, "utime fails correctly on a 'true' failure.");
|
|
Packit |
6427f8 |
|
|
Packit |
6427f8 |
# Reset timestamps so that Git doesn't think the file has changed when
|
|
Packit |
6427f8 |
# running the test in the core perl distribution.
|
|
Packit |
6427f8 |
utime($atime, $mtime, TOUCH_ME);
|