use
5.028;
our
@EXPORT
=
qw( corrupt_annexed_file device_id_issues git_annex_available run_bin )
;
sub
corrupt_annexed_file {
my
(
$git
,
$file
) =
@_
;
my
(
$key
) =
$git
->annex(
"lookupkey"
,
$file
);
my
(
$loc
) =
$git
->annex(
"contentlocation"
,
$key
);
$loc
= rel2abs
$loc
,
$git
->dir;
chmod
0777,
$loc
;
append_file
$loc
,
"bazbaz\n"
;
}
sub
device_id_issues {
local
$CWD
= tempdir
CLEANUP
=> 1;
mkdir
"foo"
;
write_file
"bar"
,
"bar\n"
;
my
$foo_id
= (
stat
"foo"
)[0];
my
$bar_id
= (
stat
"bar"
)[0];
return
(
$foo_id
!=
$bar_id
);
}
sub
git_annex_available {
`sh -c
"command -v git-annex"
`;
return
!$?;
}
sub
run_bin {
(
my
$bin
=
"App::"
.
shift
) =~
tr
/-/_/;
local
@ARGV
=
@_
;
my
(
$stdout
,
$stderr
,
$exit
) = capture {
my
$exit
;
try
{
$exit
=
$bin
->main;
}
catch
{
say
STDERR
$_
;
$exit
= 255;
};
return
$exit
;
};
my
@stdout
=
split
"\n"
,
$stdout
;
my
@stderr
=
split
"\n"
,
$stderr
;
return
(\
@stdout
, \
@stderr
,
$exit
);
}
1;