utime.t revision 1.1.1.1
1#!/usr/bin/perl -w
2use strict;
3use Test::More tests => 4;
4use constant NO_SUCH_FILE => "this_file_had_better_not_exist";
5use FindBin qw($Bin);
6use File::Spec;
7use constant TOUCH_ME     => File::Spec->catfile($Bin, 'touch_me');
8use autodie;
9
10eval { utime(undef, undef, NO_SUCH_FILE); };
11isa_ok($@, 'autodie::exception', 'exception thrown for utime');
12
13my($atime, $mtime) = (stat TOUCH_ME)[8, 9];
14
15eval { utime(undef, undef, TOUCH_ME); };
16ok(! $@, "We can utime a file just fine.") or diag $@;
17
18eval { utime(undef, undef, NO_SUCH_FILE, TOUCH_ME); };
19isa_ok($@, 'autodie::exception', 'utime exception on single failure.');
20is($@->return, 1, "utime fails correctly on a 'true' failure.");
21
22# Reset timestamps so that Git doesn't think the file has changed when
23# running the test in the core perl distribution.
24utime($atime, $mtime, TOUCH_ME);
25