File Coverage

lib/Remote/Perl/Bootstrap.pm
Criterion Covered Total %
statement 45 45 100.0
branch 4 6 66.6
condition n/a
subroutine 10 10 100.0
pod 0 2 0.0
total 59 63 93.6


line stmt bran cond sub pod time code
1 133     133   111526 use v5.36;
  133         838  
2             package Remote::Perl::Bootstrap;
3             our $VERSION = '0.004';
4              
5 133     133   1251 use autodie qw(open close);
  133         12720  
  133         873  
6 133     133   74886 use File::Spec;
  133         345  
  133         5950  
7 133     133   799 use Exporter 'import';
  133         401  
  133         13244  
8             our @EXPORT_OK = qw(bootstrap_payload wait_for_ready READY_MARKER);
9              
10             # The pre-protocol readiness marker the client sends after being eval'd.
11 133     133   1006 use constant READY_MARKER => "REMOTEPERL1\n";
  133         217  
  133         10928  
12              
13             # Sentinel that terminates the client code in the DATA section.
14 133     133   885 use constant BOOT_END => '__REMOTE_PERL_BOOT_END__';
  133         1298  
  133         11770  
15              
16             # The wrapper script sent as the "perl script" over the pipe.
17             # Remote perl compiles and runs this; it reads client code from
18             # up to the sentinel, then eval's it.
19             # NOTE: the __END__ token here is intentional and parsed by the remote perl.
20             # NOTE: use strict/warnings explicitly rather than `use v5.36` so that no
21             # feature pragmas leak into eval'd user code via the outer bootstrap scope.
22             # NOTE: WRAPPER runs on the remote side and must stay compatible with Perl 5.10+.
23 133     133   1236 use constant WRAPPER => <<'END_WRAPPER';
  133         261  
  133         68748  
24             use strict; use warnings;
25             binmode(STDIN); binmode(STDOUT); $| = 1;
26             eval(do {
27             my $c = '';
28             while (defined(my $line = )) {
29             last if $line eq "__REMOTE_PERL_BOOT_END__\n";
30             $c .= $line;
31             }
32             $c
33             }) or do { print STDERR "remperl bootstrap failed: $@\n"; exit 1 };
34             __END__