Daemon-Control/t/03_perl_gets_control.t
Ævar Arnfjörð Bjarmason 65a6aac920 Don't hardcode "perl" in invocations, use $^X instead
The tests would break if you were building the module in an
environment where "perl" in $PATH wasn't the "perl" you were calling
Makefile.PL with.
2013-05-08 16:28:18 +00:00

34 lines
851 B
Perl

#!/usr/bin/perl
use warnings;
use strict;
use Test::More;
my ( $file, $ilib );
# Let's make it so people can test in t/ or in the dist directory.
if ( -f 't/bin/03_perl_gets_control.pl' ) { # Dist Directory.
$file = "t/bin/03_perl_gets_control.pl";
$ilib = "lib";
} elsif ( -f 'bin/03_perl_gets_control.pl' ) {
$file = "bin/03_perl_gets_control.pl";
$ilib = "../lib";
} else {
die "Tests should be run in the dist directory or t/";
}
sub get_command_output {
my ( @command ) = @_;
open my $lf, "-|", @command
or die "Couldn't get pipe to '@command': $!";
my $content = do { local $/; <$lf> };
close $lf;
return $content;
}
my $out;
ok $out = get_command_output( "$^X -I$ilib $file start" ), "Started perl daemon";
unlike $out, qr/FAILED/, "Code ref gets Daemon::Control instance.";
done_testing;