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.
57 lines
1.2 KiB
Perl
57 lines
1.2 KiB
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/01_lsb_03.pl' ) { # Dist Directory.
|
|
$file = "t/bin/01_lsb_03.pl";
|
|
$ilib = "lib";
|
|
} elsif ( -f 'bin/01_lsb_03.pl' ) {
|
|
$file = "bin/01_lsb_03.pl";
|
|
$ilib = "../lib";
|
|
} else {
|
|
die "Tests should be run in the dist directory or t/";
|
|
}
|
|
|
|
|
|
open my $lf, "-|", $^X, "-I$ilib", $file, "get_init_file"
|
|
or die "Failed to open pipe to $file: $!";
|
|
my $content = do { local $/; <$lf> };
|
|
close $lf;
|
|
|
|
my $content_expected = do { local $/; <DATA> };
|
|
|
|
like $content, qr/$content_expected/, "LSB File Generation Works.";
|
|
|
|
done_testing;
|
|
|
|
__DATA__
|
|
#!/bin/sh
|
|
|
|
# Generated at [\w: ]+ with Daemon::Control (?:DEV|[\d.]+)
|
|
|
|
### BEGIN INIT INFO
|
|
# Provides: My Daemon
|
|
# Required-Start: \$syslog \$remote_fs
|
|
# Required-Stop: \$syslog
|
|
# Default-Start: 2 3 4 5
|
|
# Default-Stop: 0 1 6
|
|
# Short-Description: My Daemon Short
|
|
# Description: My Daemon controls the My Daemon daemon.
|
|
### END INIT INFO`
|
|
|
|
|
|
|
|
Test This
|
|
One Block
|
|
|
|
if \[ -x /usr/sbin/mydaemon/init.pl \];
|
|
then
|
|
/usr/sbin/mydaemon/init.pl \$1
|
|
else
|
|
echo "Required program /usr/sbin/mydaemon/init.pl not found!"
|
|
exit 1;
|
|
fi
|