fix codetest failure - ASSERT_ARGS does not have a ; after and
[parrot.git] / tools / install / smoke.pl
blob87ceca51e9b379ec106bb0e570699542e3f7e491
1 #! perl
2 # Copyright (C) 2007-2009, Parrot Foundation.
3 # $Id$
5 use strict;
6 use warnings;
7 use 5.008;
9 use Getopt::Long;
10 use File::Spec::Functions;
12 use Test::More tests => 7;
14 =head1 NAME
16 tools/install/smoke.pl - checks parrot in install directory
18 =head1 SYNOPSIS
20 parrot in install tree
22 % cd /usr/local/parrot-$version
23 % perl smoke.pl
25 parrot in build tree
27 % perl tools/install/smoke.pl --bindir=.
29 test installation in DESTDIR:
31 % cd /usr/src/parrot
32 % mkdir .inst
33 % make install DESTDIR=.inst
34 % perl tools/install/smoke.pl DESTDIR=.inst
36 =head1 DESCRIPTION
38 Checks that most of things run (or just start) into the install directory,
39 try to detect missing parts.
41 =head1 OPTIONS
43 =over
45 =item --bindir=/usr/bin
47 Override default value : 'bin'
49 =back
51 =cut
53 my ($bindir, $DESTDIR);
54 my $opts = GetOptions(
55 'bindir=s' => \$bindir,
56 'DESTDIR=s' => \$DESTDIR,
59 $bindir = 'bin' unless $bindir;
61 chdir $DESTDIR if ($DESTDIR);
63 sub quote {
64 my $exe = shift;
65 $exe .= '.exe' if ($^O eq 'MSWin32');
66 $exe = '"' . $exe . '"' if ($exe =~ / /);
67 return $exe;
70 my $filename;
71 my $exe;
72 my $out;
73 my $FH;
74 my $parrot = quote(catfile($bindir, 'parrot'));
75 my $pirc = quote(catfile($bindir, 'pirc'));
76 my $nqp = quote(catfile($bindir, 'parrot-nqp'));
79 # parrot executable
82 $exe = quote(catfile($bindir, 'pbc_merge'));
83 $out = `$exe`;
84 ok($out =~ /^pbc_merge/, "check pbc_merge");
86 $exe = quote(catfile($bindir, 'pbc_dump'));
87 $out = `$exe`;
88 ok($out =~ /^pbc_dump/, "check pbc_dump");
90 ok(system("$parrot -V") == 0, "display parrot version");
92 $out = `$parrot -V`;
93 $out =~ m/version (\S+) built/;
94 my $version = $1;
96 my $libdir = ($bindir eq 'bin')
97 ? ($^O eq 'MSWin32') ? 'lib/parrot/library' : "lib/parrot/$version/library"
98 : 'runtime/parrot/library';
100 my $compdir = ($bindir eq 'bin')
101 ? ($^O eq 'MSWin32') ? 'lib/parrot/languages' : "lib/parrot/$version/languages"
102 : 'compilers';
105 # some compiler tools
108 $filename = 'test.pg';
109 open $FH, '>', $filename
110 or die "Can't open $filename ($!).\n";
111 print $FH <<'PGE';
112 grammar WSpace
114 token TOP { \s* }
116 close $FH;
117 $out = `$parrot $libdir/PGE/Perl6Grammar.pbc $filename`;
118 ok($out =~ /## <WSpace::TOP>/, "check PGE");
119 unlink($filename);
121 SKIP:
123 skip("pirc", 1) unless (-e $pirc);
124 $filename = 'test.pir';
125 open $FH, '>', $filename
126 or die "Can't open $filename ($!).\n";
127 print $FH <<'PIR';
128 .sub main
129 say "hello world!"
130 .end
132 close $FH;
133 $out = `$pirc -n $filename`;
134 ok($out eq "ok\n", "check pirc");
135 unlink($filename);
138 $filename = 'test.nqp';
139 open $FH, '>', $filename
140 or die "Can't open $filename ($!).\n";
141 print $FH "say('hello world!');\n";
142 close $FH;
143 $out = `$nqp $filename`;
144 ok($out eq "hello world!\n", "check nqp-rx");
145 unlink($filename);
147 # compilers/tge is typically not installed
148 $filename = 'test.tg';
149 open $FH, '>', $filename
150 or die "Can't open $filename ($!).\n";
151 print $FH "transform past (ROOT) { }\n";
152 close $FH;
153 $out = `$parrot $compdir/tge/tgc.pir $filename`;
154 ok($out =~ /^\n\.sub '_ROOT_past'/, "check TGE");
155 unlink($filename);
157 # Local Variables:
158 # mode: cperl
159 # cperl-indent-level: 4
160 # fill-column: 100
161 # End:
162 # vim: expandtab shiftwidth=4: