fix ssh arguments the correct way
[scpubgit/Object-Remote.git] / t / perl_execute.t
CommitLineData
f129bfaf 1use strictures 1;
2use Test::More;
3
4use Data::Dumper;
5
6require 't/logsetup.pl';
7
8use Object::Remote::Connector::Local;
9use Object::Remote::Connector::SSH;
10
11my $defaults = Object::Remote::Connector::Local->new;
12
13my $normal = $defaults->final_perl_command;
14my $ulimit = Object::Remote::Connector::Local->new(ulimit => 536)->final_perl_command;
15my $nice = Object::Remote::Connector::Local->new(nice => 834)->final_perl_command;
16my $both = Object::Remote::Connector::Local->new(nice => 612, ulimit => 913)->final_perl_command;
17my $ssh = Object::Remote::Connector::SSH->new(nice => 494, ulimit => 782, ssh_to => 'testhost')->final_perl_command;
18
19is($defaults->timeout->{after}, 10, 'Default connection timeout value is correct');
20is($defaults->watchdog_timeout, undef, 'Watchdog is not enabled by default');
21is($defaults->nice, undef, 'Nice is not enabled by default');
22is($defaults->ulimit, undef, 'Ulimit is not enabled by default');
23is($defaults->stderr, undef, 'Child process STDERR is clone of parent process STDERR by default');
24
8506bc08 25is_deeply($normal, ['sh', '-c', 'perl -'], 'Default Perl interpreter arguments correct');
26is_deeply($ulimit, ['sh', '-c', 'ulimit -v 536; perl -'], 'Arguments for ulimit are correct');
27is_deeply($nice, ['sh', '-c', 'nice -n 834 perl -'], 'Arguments for nice are correct');
28is_deeply($both, ['sh', '-c', 'ulimit -v 913; nice -n 612 perl -'], 'Arguments for nice and ulimit are correct');
29is_deeply($ssh, [qw(ssh -A testhost), "sh -c 'ulimit -v 782; nice -n 494 perl -'"], "Arguments using ssh are correct");
f129bfaf 30
31done_testing;
32