Any/Test/Backend/Cygwin.pm untested

filter: Statementstmt 0.0% 0 / 39 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 19 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 79 CC 2 SCAR 11.0
CC
2
Cov
0%
_start_and_check
6.0
_validate_backend_opts
2.0
BEGIN
2.0
CRAP 3.0
1 package Net::SSH::Any::Test::Backend::Cygwin;
2  
3 use strict;
4 use warnings;
5  
6 use Net::SSH::Any;
7 use Net::SSH::Any::Constants qw(SSHA_BACKEND_ERROR);
8  
9 use parent 'Net::SSH::Any::Test::Backend::OpenSSH_Daemon';
10  
11 sub _validate_backend_opts {
12 my $tssh = shift;
13  
14 $^O eq 'MSWin32' or return;
15  
16 my $opts = $tssh->{current_opts};
17 $opts->{cygwin_url} //= "http://cygwin.com/setup-x86.exe";
18 $opts->{cygwin_site} //= "http://mirrors.kernel.org/sourceware/cygwin/";
19  
20 1;
21 }
22  
23 sub _start_and_check {
24 my $tssh = shift;
25  
26 my $opts = $tssh->{current_opts};
27  
28 my $wdir = $tssh->_backend_wdir;
29 my $installer = File::Spec->join($wdir, 'cygwin-setup.exe');
30 $tssh->_log("Downloading Cygwin installer to $installer");
31 $tssh->_load_module('HTTP::Tiny') or return;
32 my $ua = HTTP::Tiny->new;
33 my $res = $ua->mirror($opts->{cygwin_url}, $installer);
34 unless ($res->{success}) {
35 $tssh->_set_error(SSHA_BACKEND_ERROR, "Unable to download Cygwin installer: $res->{status} $res->{reason}");
36 return;
37 }
38  
39 my $rootdir = File::Spec->join($wdir, 'Cygwin');
40 $tssh->_run_cmd( {find => 0,
41 name => 'cygwin-installer'},
42 $installer,
43 -R => $rootdir,
44 -s => $opts->{cygwin_site},
45 -P => 'openssh',
46 '-q', '-B', '-n') or return;
47  
48 local $ENV{PATH} = "$ENV{PATH};$rootdir\\bin;$rootdir\\sbin";
49  
50 $opts->{local_ssh_cmd} //= "$rootdir/bin/ssh.exe";
51 $opts->{local_sshd_cmd} //= "$rootdir/usr/sbin/sshd.exe";
52 $opts->{local_bash_cmd} //= "$rootdir/bin/bash.exe";
53  
54 $tssh->SUPER::_validate_backend_opts and
55 $tssh->SUPER::_start_and_check;
56 }
57  
58 1;