File Coverage

blib/lib/Devel/AssertApplicationCapabilities/cpSupportsMinusal.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::cpSupportsMinusal;
2              
3 1     1   6 use strict;
  1         1  
  1         43  
4 1     1   5 use vars qw($VERSION);
  1         1  
  1         117  
5             local $^W = 1;
6             $VERSION = '1.0';
7 1     1   5 use base qw(Devel::AssertApplicationCapabilities::_Base);
  1         1  
  1         698  
8              
9 1     1   7 use Devel::CheckApplicationCapabilities;
  1         18  
  1         33  
10 1     1   5 use File::Temp qw(tempdir);
  1         2  
  1         359  
11              
12             sub app_is {
13 2     2 0 3 my $app = shift;
14              
15 2         21 my $dir = tempdir();
16 2 50       1136 open(TEMPFILE, '>', "$dir/foo") ||
17             die("Can't create $dir/foo to test whether $app supports -al\n");
18 2         25 print TEMPFILE "Testing";
19 2         138 close(TEMPFILE);
20              
21             Devel::CheckApplicationCapabilities::_with_STDERR_closed(sub {
22 2     2   12819 system($app, '-al', "$dir/foo", "$dir/bar");
23 2         24 });
24              
25 2         75 my $rval = 0;
26 2 50 33     5432 if(-e "$dir/bar" && ((stat("$dir/foo"))[1] == (stat("$dir/bar"))[1])) { # same inode
27 2         7 $rval = 1;
28             }
29 2         393 unlink "$dir/foo", "$dir/bar";
30 2         281 rmdir $dir;
31 2         350 return $rval;
32             }
33              
34             =head1 NAME
35              
36             Devel::AssertApplicationCapabilities::cpSupportsMinusal- check that a 'cp' binary supports the -al argument.
37              
38             The check is whether 'cp -al 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;