# New Ticket Created by Reini Urban
# Please include the string: [perl #58852]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=58852 >
Enhance tools/install/smoke.pl to test already installed parrot by using
%PConfig and a DESTDIR arg for a temporary installation.
Attached patch is r31113 in the branch cygwin070patches.
parrot in bin
% cd /usr/local/parrot-$version
% perl tools/install/smoke.pl -Ilib
parrot in .
% perl tools/install/smoke.pl --bindir=.
test installation in DESTDIR:
% cd /usr/src/parrot
% mkdir .inst
% make install DESTDIR=.inst
% perl tools/install/smoke.pl DESTDIR=.inst
Options:
-I libdir
Add libdir to the libpath to find Parrot::Config
--bindir=/usr/bin
Override Parrot::Config bindir
--libdir=/usr/lib
Override Parrot::Config libdir
--prefix=/usr
Override Parrot::Config prefix and adjust
libdir and bindir accordingly.
DESTDIR=instpath
Use the temp. installation in instpath.
--
Reini Urban
http://phpwiki.org/ http://murbreak.at/
Index: tools/install/smoke.pl
===================================================================
--- tools/install/smoke.pl (revision 31112)
+++ tools/install/smoke.pl (working copy)
@@ -4,6 +4,10 @@
use strict;
use warnings;
+use 5.008;
+use Getopt::Long;
+use lib qw( lib );
+use vars qw( %PConfig );
use Test::More tests => 29;
@@ -13,39 +17,116 @@
=head1 SYNOPSIS
+ parrot in bin
+
% cd /usr/local/parrot-$version
- % perl tools/install/smoke.pl
+ % perl tools/install/smoke.pl -Ilib
+ parrot in .
+
+ % perl tools/install/smoke.pl --bindir=.
+
+ test installation in DESTDIR:
+
+ % cd /usr/src/parrot
+ % mkdir .inst
+ % make install DESTDIR=.inst
+ % perl tools/install/smoke.pl DESTDIR=.inst
+
+
=head1 DESCRIPTION
Checks that most of things run (or just start) into the install directory,
-try to detect missing part.
+try to detect missing parts.
+=head1 OPTIONS
+
+=over
+
+=item -I libdir
+
+Add libdir to the libpath to find Parrot::Config
+
+=item --bindir=/usr/bin
+
+Override Parrot::Config bindir
+
+=item --libdir=/usr/lib
+
+Override Parrot::Config libdir
+
+=item --prefix=/usr
+
+Override Parrot::Config prefix and adjust
+libdir and bindir accordingly.
+
+=item DESTDIR=instpath
+
+Use the temp. installation in instpath.
+
+=back
+
=cut
+my (@libdirs, $prefix, $bindir, $libdir, $DESTDIR);
+my $opts = GetOptions( 'I=s' => [EMAIL PROTECTED],
+ 'prefix=s' => \$prefix,
+ 'bindir=s' => \$bindir,
+ 'libdir=s' => \$libdir,
+ 'DESTDIR=s' => \$DESTDIR,
+ );
+if (@libdirs) {
+ push @INC, @libdirs;
+}
+require Parrot::Config;
+Parrot::Config->import;
+require Parrot::Test;
+
+$bindir = $PConfig{bindir} unless $bindir;
+$libdir = $PConfig{libdir} unless $libdir;
+if ($prefix) {
+ $bindir = $prefix . "/bin";
+ $libdir = $prefix . "/lib";
+}
+# Check for DESTDIR arg and adjust the path
+if (@ARGV and $ARGV[0] =~ /^DESTDIR/) {
+ if ($ARGV[0] =~ /^DESTDIR=(\S+)/) {
+ $DESTDIR = $1;
+ } else {
+ $DESTDIR = $ARGV[1];
+ }
+}
+if ($DESTDIR) {
+ my $envsep = $^O eq 'MSWin32' ? ';' : ':';
+ $ENV{PATH} = $DESTDIR.$bindir.$envsep.$ENV{PATH};
+ $bindir = $DESTDIR . $bindir;
+ $libdir = $DESTDIR . $libdir;
+}
+
use File::Spec::Functions;
my $filename;
my $exe;
my $out;
my $FH;
-my $parrot = catfile('bin', 'parrot');
+my $parrot = catfile($bindir, 'parrot');
#
# parrot executable
#
+-x $parrot or die "$parrot does not exist\n";
-$exe = catfile('bin', 'pbc_merge');
+$exe = catfile($bindir, 'pbc_merge');
$out = `$exe`;
ok($out =~ /^pbc_merge/, "check pbc_merge");
-$exe = catfile('bin', 'pdump');
+$exe = catfile($bindir, 'pdump');
$out = `$exe`;
ok($out =~ /^pdump/, "check pdump");
ok(system("$parrot -V") == 0, "display parrot version");
-$exe = catfile('bin', 'perl6');
+$exe = catfile($bindir, 'perl6');
$out = `$exe -v`;
ok($out =~ /Rakudo/, "check rakudo");
@@ -58,10 +139,11 @@
or die "Can't open $filename ($!).\n";
print $FH "token TOP { \\s* }\n";
close $FH;
-$out = `$parrot lib/parrot/library/PGE/Perl6Grammar.pir $filename`;
+$out = `$parrot $libdir/parrot/library/PGE/Perl6Grammar.pir $filename`;
ok($out =~ /^\n## <::TOP>/, "check PGE");
unlink($filename);
+# compilers/tge is typically not installed
$filename = 'test.tg';
open $FH, '>', $filename
or die "Can't open $filename ($!).\n";
@@ -71,6 +153,7 @@
ok($out =~ /^\n\.sub '_ROOT_past'/, "check TGE");
unlink($filename);
+# compilers/nqp is typically not installed
$filename = 'test.nqp';
open $FH, '>', $filename
or die "Can't open $filename ($!).\n";
@@ -129,7 +212,7 @@
or die "Can't open $filename ($!).\n";
print $FH "H";
close $FH;
-$out = `$parrot languages/HQ9Plus/HQ9Plus.pbc $filename`;
+$out = `$parrot languages/hq9plus/hq9plus.pbc $filename`;
ok($out eq "Hello, world!\n", "check HQ9Plus");
unlink($filename);