Add the original source packages to maemo, source lenny
[dh-make-perl] / dev / i386 / libtest-harness-perl / libtest-harness-perl-3.12 / xt / perls / harness_perl.t
1 #!/usr/bin/perl
2
3 use warnings;
4 use strict;
5
6 use Test::More;
7
8 # TODO we need to have some way to find one or more alternate versions
9 # of perl on the smoke machine so that we can verify that the installed
10 # perl can be used to test against the alternate perls without
11 # installing the harness in the alternate perls.  Does that make sense?
12 #
13 # Example:
14 #  harness process (i.e. bin/prove) is perl 5.8.8.
15 #  subprocesses    (i.e. t/test.t) are perl 5.6.2.
16
17 my @perls;
18
19 BEGIN {
20     my $perls_live_at = '/usr/local/stow/';
21     @perls = grep( { -e $_ }
22         map( {"$perls_live_at/perl-$_/bin/perl"} qw(5.5.4 5.6.2) ) );
23     if (@perls) {
24         plan( tests => scalar(@perls) * 4 );
25     }
26     else {
27         plan( skip_all => "no perls found in '$perls_live_at'" );
28     }
29 }
30
31 use File::Temp ();
32 use File::Path ();
33 use IPC::Run   ();
34
35 mkdir('twib') or die "cannot create 'twib' $!";
36
37 {    # create a lib
38     open( my $fh, '>', 'twib/foo.pm' );
39     print $fh "package twib;\nsub foo {'bar';}\n1;\n";
40 }
41
42 END {
43     File::Path::rmtree('twib');
44 }
45
46 my @tests = qw(
47   xt/perls/sample-tests/perl_version
48 );
49
50 # TODO and something with taint
51
52 # make the tests check that the perl is indeed the $perl (thus they are
53 # just printed tests.)
54 foreach my $perl (@perls) {
55
56     # TODO make the API be *not* an environment variable!
57     local $ENV{HARNESS_PERL} = $perl;
58
59     my ( $in, $out, $err ) = ( undef, '', '' );
60     my $ret = IPC::Run::run(
61         [
62             $^X, '-Ilib',
63             'bin/prove', '-It/lib', '-Itwib', @tests
64         ],
65         \$in, \$out, \$err
66     );
67     ok( $ret, 'no death' );
68     like( $out, qr/All tests successful/, 'success' );
69     like( $out, qr/Result: PASS/,         'passed' );
70     is($err, '', 'no error');
71 }
72
73 # vim:ts=4:sw=4:et:sta