1 package App::Rgit::TestUtils;
7 use File::Temp qw/tempfile/;
8 use POSIX qw/WIFEXITED WEXITSTATUS WIFSIGNALED WTERMSIG SIGINT SIGQUIT/;
11 no warnings 'redefine';
12 *WIFEXITED = sub { 1 } unless eval { WIFEXITED(0); 1 };
13 *WEXITSTATUS = sub { shift() >> 8 } unless eval { WEXITSTATUS(0); 1 };
14 *WIFSIGNALED = sub { shift() & 127 } unless eval { WIFSIGNALED(0); 1 };
17 use base qw/Exporter/;
19 our @EXPORT_OK = (qw/can_run_git/);
22 my ($fh, $filename) = tempfile(UNLINK => 1);
33 my $git = 't/bin/git';
34 if ($^O eq 'MSWin32') {
38 @ret = (0, "no $git executable");
44 @ret = (0, "no $git executable");
49 system { $git } $git, @args;
52 @ret = (0, $! || "unknown");
57 $status = WEXITSTATUS($?) if WIFEXITED($?);
59 if (WIFSIGNALED($?)) {
60 @ret = (0, 'process recieved signal ' . WTERMSIG($?));
62 @ret = (0, "process exited with code $status");
66 return wantarray ? @ret : $ret[0];