File Coverage

blib/lib/Devel/AssertApplicationCapabilities/cpCanHardLink.pm
Criterion Covered Total %
statement 28 28 100.0
branch 2 4 50.0
condition 1 3 33.3
subroutine 7 7 100.0
pod 0 1 0.0
total 38 43 88.3


line stmt bran cond sub pod time code
1             package Devel::AssertApplicationCapabilities::cpCanHardLink;
2              
3 1     1   6 use strict;
  1         2  
  1         42  
4 1     1   6 use vars qw($VERSION);
  1         2  
  1         61  
5             local $^W = 1;
6             $VERSION = '1.0';
7 1     1   4 use base qw(Devel::AssertApplicationCapabilities::_Base);
  1         1  
  1         559  
8              
9 1     1   5 use Devel::CheckApplicationCapabilities;
  1         18  
  1         37  
10 1     1   6 use File::Temp qw(tempdir);
  1         1  
  1         249  
11              
12             sub app_is {
13 2     2 0 4 my $app = shift;
14              
15 2         21 my $dir = tempdir();
16 2 50       2081 open(TEMPFILE, '>', "$dir/foo") ||
17             die("Can't create $dir/foo to test whether $app supports -l\n");
18 2         23 print TEMPFILE "Testing";
19 2         83 close(TEMPFILE);
20              
21             Devel::CheckApplicationCapabilities::_with_STDERR_closed(sub {
22 2     2   32651 system($app, '-l', "$dir/foo", "$dir/bar");
23 2         19 });
24              
25 2         144 my $rval = 0;
26 2 50 33     467 if(-e "$dir/bar" && ((stat("$dir/foo"))[1] == (stat("$dir/bar"))[1])) { # same inode
27 2         12 $rval = 1;
28             }
29 2         557 unlink "$dir/foo", "$dir/bar";
30 2         292 rmdir $dir;
31 2         303 return $rval;
32             }
33              
34             =head1 NAME
35              
36             Devel::AssertApplicationCapabilities::cpCanHardLink - check that a 'cp' binary can create hard links with -l.
37              
38             The check is whether 'cp -l blah/foo blah/bar' results in two
39             files with the same inode number.
40              
41             =head1 SOURCE CODE REPOSITORY
42              
43             L
44              
45             =head1 AUTHOR, COPYRIGHT and LICENCE
46              
47             Copyright 2012 David Cantrell
48              
49             This software is free-as-in-speech software, and may be used,
50             distributed, and modified under the terms of either the GNU
51             General Public Licence version 2 or the Artistic Licence. It's
52             up to you which one you use. The full text of the licences can
53             be found in the files GPL2.txt and ARTISTIC.txt, respectively.
54              
55             =head1 CONSPIRACY
56              
57             This module is also free-as-in-mason software.
58              
59             =cut
60              
61             1;