Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use Pipp::Test for testing.
  • Loading branch information
bschmalhofer committed Mar 2, 2009
1 parent 9c31985 commit 9f8f981
Show file tree
Hide file tree
Showing 35 changed files with 55 additions and 63 deletions.
2 changes: 1 addition & 1 deletion build/templates/Makefile.in
Expand Up @@ -122,7 +122,7 @@ help:
Makefile: build/templates/Makefile.in
$(PERL) Configure.pl

build: build-common
build: pipp$(EXE)

#build-common: build-pmc library/pipplib.pbc pipp.pbc $(PHP_EXT) Test.pir
build-common: build-pmc library/pipplib.pbc pipp.pbc $(PHP_EXT)
Expand Down
39 changes: 15 additions & 24 deletions t/harness
Expand Up @@ -35,15 +35,12 @@ use Cwd ();
use File::Spec ();
use TAP::Harness 3.12; # support closures for the 'exec' option
use TAP::Harness::Archive 0.12;
use Parrot::Config qw( %PConfig );
use Getopt::Long;
use Parrot::Harness::Smoke;
use Parrot::Test;

my ( $files_flag, $send_to_smolder_flag, $archive_flag, $verbose_flag );
my ( $send_to_smolder_flag, $archive_flag, $verbose_flag );
my ( $php_flag, $pct_flag, $phc_flag);
GetOptions(
'files' => \$files_flag,
'send-to-smolder' => \$send_to_smolder_flag,
'archive' => \$archive_flag,
'verbose' => \$verbose_flag,
Expand All @@ -56,30 +53,16 @@ my $hll = 'pipp';
my $verbosity = $verbose_flag ? 1 : $ENV{HARNESS_VERBOSE};
$verbosity ||= 0;

if ( $files_flag ) {
# Only the Makefile in 'parrot/languages' uses --files for unified testing
my $dir = File::Spec->catfile( $hll, 't' );
# unified testing can't handle test scripts written in PHP
my @files = grep { ! m!in_php|pmc|embed! } glob( File::Spec->catfile( $dir, '*/*.t' ) );
print join( "\n", @files );
print "\n" if scalar(@files);
}
else {
my $path_to_parrot = Parrot::Test::path_to_parrot();
my @cmd = ( "$path_to_parrot/parrot$PConfig{exe}", 'pipp.pbc' );
$ENV{PARROT_PIPP_TEST_MODULE} = 'Parrot::Test::Pipp::PCT';
{
my $path_to_parrot = path_to_parrot();
my @cmd = ( "$path_to_parrot/parrot", 'pipp.pbc' );

if ( $php_flag ) {
$ENV{PARROT_PIPP_TEST_MODULE} = 'Parrot::Test::Pipp::PHP';
@cmd = qw{ php-cgi -q -C -n } ;
}
elsif ( $phc_flag ) {
$ENV{PARROT_PIPP_TEST_MODULE} = 'Parrot::Test::Pipp::Phc';
push @cmd, '--variant=phc';
}
elsif ( $pct_flag ) {
$ENV{PARROT_PIPP_TEST_MODULE} = 'Parrot::Test::Pipp::PCT';
}

my @files;
if ( scalar(@ARGV) ) {
Expand All @@ -101,16 +84,16 @@ else {
my ( $harness, $test_file ) = @_;

# the directory t/embed contains only PIR test files
return [ "$path_to_parrot/parrot$PConfig{exe}", $test_file ] if $test_file =~ m!t/embed/.*[.]t$!;
return [ "$path_to_parrot/parrot", $test_file ] if $test_file =~ m!t/embed/.*[.]t$!;

# the directory t/pmc contains only PIR test files
return [ "$path_to_parrot/parrot$PConfig{exe}", $test_file ] if $test_file =~ m!t/pmc/.*[.]t$!;
return [ "$path_to_parrot/parrot", $test_file ] if $test_file =~ m!t/pmc/.*[.]t$!;

# the directory t/in_php contains only test scripts written in PHP
return [ @cmd, $test_file ] if $test_file =~ m!t/in_php/.*[.]t$!;

# all other directories contain test scripts written in Perl
return [ $PConfig{perl}, $test_file ];
return [ $^X, $test_file ];
};
if ( $archive_flag ) {
my %env_data = Parrot::Harness::Smoke::collect_test_environment_data();
Expand Down Expand Up @@ -144,6 +127,14 @@ else {
}
}

sub path_to_parrot {

my $path = $INC{'Parrot/Config.pm'};
$path =~ s{ /lib/Parrot/Config.pm \z}{}xms;

return Cwd::realpath( $path );
}

=head1 SEE ALSO
F<languages/perl6/t/harness>
Expand Down
2 changes: 1 addition & 1 deletion t/php/arithmetics.t
Expand Up @@ -18,7 +18,7 @@ use warnings;
use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";

use Parrot::Test;
use Pipp::Test;

# A little helper to do data driven testing
sub run_tests {
Expand Down
2 changes: 1 addition & 1 deletion t/php/array.t
Expand Up @@ -21,7 +21,7 @@ use warnings;
use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";

use Parrot::Test tests => 3;
use Pipp::Test tests => 3;

language_output_is( 'Pipp', <<'CODE', <<'OUT', 'Instantiate array with array() function' );
<?php
Expand Down
2 changes: 1 addition & 1 deletion t/php/base64.t
Expand Up @@ -24,7 +24,7 @@ use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";

use Test::More tests => 8;
use Parrot::Test;
use Pipp::Test;


language_output_is( 'Pipp', <<'CODE', <<'OUT', 'base64_encode(str)' );
Expand Down
2 changes: 1 addition & 1 deletion t/php/basic.t
Expand Up @@ -22,7 +22,7 @@ use warnings;
use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";

use Parrot::Test tests => 5;
use Pipp::Test tests => 5;

language_output_is( 'Pipp', <<'CODE', <<'OUT', 'whitespace after echo' );
<?php
Expand Down
2 changes: 1 addition & 1 deletion t/php/builtin.t
Expand Up @@ -24,7 +24,7 @@ use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";

use Test::More tests => 9;
use Parrot::Test;
use Pipp::Test;


language_output_like( 'Pipp', <<'CODE', <<'OUT', 'get_resource_type()' );
Expand Down
2 changes: 1 addition & 1 deletion t/php/closures.t
Expand Up @@ -19,7 +19,7 @@ use warnings;
use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";

use Parrot::Test tests => 7;
use Pipp::Test tests => 7;

=for perl6
Expand Down
2 changes: 1 addition & 1 deletion t/php/comments.t
Expand Up @@ -26,7 +26,7 @@ use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";
use Test::More tests => 10;

# Parrot modules
use Parrot::Test;
use Pipp::Test;

language_output_is( 'Pipp', <<'CODE', <<'OUT', 'end of line comment //' );
<script language="php">
Expand Down
2 changes: 1 addition & 1 deletion t/php/concat.t
Expand Up @@ -20,7 +20,7 @@ use warnings;
use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";

use Parrot::Test tests => 3;
use Pipp::Test tests => 3;

language_output_is( 'Pipp', <<'CODE', <<'OUT', 'concatenate 2 strings' );
<?php
Expand Down
5 changes: 3 additions & 2 deletions t/php/constant.t
Expand Up @@ -21,8 +21,9 @@ use warnings;
use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";

use Parrot::Test tests => 25;
use Parrot::Config qw( %PConfig );
use Pipp::Test tests => 25;

my %PConfig = Pipp::Test::read_parrot_config();

language_output_is( 'Pipp', <<'CODE', <<'OUT', 'define() and constant(), string' );
<?php
Expand Down
2 changes: 1 addition & 1 deletion t/php/control_flow.t
Expand Up @@ -20,7 +20,7 @@ use warnings;
use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";

use Parrot::Test tests => 23;
use Pipp::Test tests => 23;

language_output_is( 'Pipp', <<'CODE', <<'OUT', 'if, one statement in block' );
<?php
Expand Down
2 changes: 1 addition & 1 deletion t/php/ctype.t
Expand Up @@ -24,7 +24,7 @@ use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";

use Test::More tests => 4;
use Parrot::Test;
use Pipp::Test;


language_output_is( 'Pipp', <<'CODE', <<'OUT', 'ctype_alnum() ok' );
Expand Down
2 changes: 1 addition & 1 deletion t/php/file.t
Expand Up @@ -24,7 +24,7 @@ use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";

use Test::More tests => 10;
use Parrot::Test;
use Pipp::Test;

unlink 'file.txt' if -f 'file.txt';

Expand Down
2 changes: 1 addition & 1 deletion t/php/filestat.t
Expand Up @@ -24,7 +24,7 @@ use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";

use Test::More tests => 3;
use Parrot::Test;
use Pipp::Test;


unlink 'file.txt' if (-f 'file.txt');
Expand Down
5 changes: 3 additions & 2 deletions t/php/filesystem.t
Expand Up @@ -22,8 +22,9 @@ use warnings;
use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";

use Parrot::Test tests => 5;
use Parrot::Config qw( %PConfig );
use Pipp::Test tests => 5;

my %PConfig = Pipp::Test::read_parrot_config();

# test dirname
{
Expand Down
2 changes: 1 addition & 1 deletion t/php/functions.t
Expand Up @@ -19,7 +19,7 @@ use warnings;
use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";

use Parrot::Test tests => 16;
use Pipp::Test tests => 16;

language_output_is( 'Pipp', <<'CODE', <<'OUT', 'function with no args' );
<?php
Expand Down
2 changes: 1 addition & 1 deletion t/php/gmp.t
Expand Up @@ -24,7 +24,7 @@ use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";

use Test::More;
use Parrot::Test;
use Pipp::Test;

plan tests => 24;

Expand Down
2 changes: 1 addition & 1 deletion t/php/hello.t
Expand Up @@ -19,7 +19,7 @@ use warnings;
use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";

use Parrot::Test tests => 20;
use Pipp::Test tests => 20;

my $h = "Hello, World!\n";

Expand Down
2 changes: 1 addition & 1 deletion t/php/info.t
Expand Up @@ -22,7 +22,7 @@ use warnings;
use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";

use Parrot::Test tests => 10;
use Pipp::Test tests => 10;


language_output_is( 'Pipp', <<'CODE', <<'OUT', 'php_egg_logo_guid()' );
Expand Down
2 changes: 1 addition & 1 deletion t/php/math.t
Expand Up @@ -24,7 +24,7 @@ use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";

use Test::More tests => 39;
use Parrot::Test;
use Pipp::Test;


language_output_is( 'Pipp', <<'CODE', <<'OUT', 'abs' );
Expand Down
2 changes: 1 addition & 1 deletion t/php/md5.t
Expand Up @@ -24,7 +24,7 @@ use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";

use Test::More tests => 5;
use Parrot::Test;
use Pipp::Test;


language_output_is( 'Pipp', <<'CODE', <<'OUT', 'md5(msg)' );
Expand Down
2 changes: 1 addition & 1 deletion t/php/namespace.t
Expand Up @@ -23,7 +23,7 @@ use warnings;
use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";

use Parrot::Test tests => 8;
use Pipp::Test tests => 8;

language_output_is( 'Pipp', <<'CODE', <<'OUT', 'parsing of namespace directive' );
<?php
Expand Down
2 changes: 1 addition & 1 deletion t/php/null.t
Expand Up @@ -21,7 +21,7 @@ use warnings;
use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";

use Parrot::Test tests => 3;
use Pipp::Test tests => 3;


language_output_is( 'Pipp', <<'CODE', <<'OUT', 'Stringification of an undefined var' );
Expand Down
2 changes: 1 addition & 1 deletion t/php/oo.t
Expand Up @@ -19,7 +19,7 @@ use warnings;
use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";

use Parrot::Test tests => 17;
use Pipp::Test tests => 17;

language_output_is( 'Pipp', <<'CODE', <<'OUT', 'definition of a class' );
<?php
Expand Down
6 changes: 3 additions & 3 deletions t/php/pcre.t
Expand Up @@ -23,9 +23,9 @@ use warnings;
use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";

use Test::More;
use Parrot::Test;
use Parrot::Config;
use Pipp::Test;

my %PConfig = Pipp::Test::read_parrot_config();

if ( $PConfig{HAS_PCRE} ) {
plan tests => 8;
Expand Down
2 changes: 1 addition & 1 deletion t/php/rand.t
Expand Up @@ -24,7 +24,7 @@ use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";

use Test::More tests => 20;
use Parrot::Test;
use Pipp::Test;


language_output_is( 'Pipp', <<'CODE', <<'OUT', 'getrandmax()' );
Expand Down
2 changes: 1 addition & 1 deletion t/php/references.t
Expand Up @@ -19,7 +19,7 @@ use warnings;
use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";

use Parrot::Test tests => 1;
use Pipp::Test tests => 1;

language_output_is( 'Pipp', <<'CODE', <<'OUT', 'references', todo => 'not implemented yet' );
<?php
Expand Down
2 changes: 1 addition & 1 deletion t/php/relops.t
Expand Up @@ -26,7 +26,7 @@ use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";

use Parrot::Config ();
use Parrot::Test;
use Pipp::Test;
use Test::More tests => 13;

# True tests
Expand Down
2 changes: 1 addition & 1 deletion t/php/sha1.t
Expand Up @@ -24,7 +24,7 @@ use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";

use Test::More tests => 5;
use Parrot::Test;
use Pipp::Test;


language_output_is( 'Pipp', <<'CODE', <<'OUT', 'sha1(msg)' );
Expand Down
2 changes: 1 addition & 1 deletion t/php/string.t
Expand Up @@ -22,7 +22,7 @@ use warnings;
use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";

use Parrot::Test tests => 40;
use Pipp::Test tests => 40;


language_output_is( 'Pipp', <<'CODE', <<'OUT', 'bin2hex' );
Expand Down
2 changes: 1 addition & 1 deletion t/php/superglobals.t
Expand Up @@ -19,7 +19,7 @@ use warnings;
use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";

use Parrot::Test tests => 6;
use Pipp::Test tests => 6;

language_output_is( 'Pipp', <<'CODE', <<'OUT', 'php_sapi_name' );
<?php
Expand Down
2 changes: 1 addition & 1 deletion t/php/tags.t
Expand Up @@ -23,7 +23,7 @@ use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";

use Test::More tests => 8;
use Parrot::Test;
use Pipp::Test;


language_output_is( 'Pipp', <<'CODE', <<'OUT', 'short tags w/ close' );
Expand Down
3 changes: 1 addition & 2 deletions t/php/type.t
Expand Up @@ -22,8 +22,7 @@ use warnings;
use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";

use Test::More;
use Parrot::Test tests => 18;
use Pipp::Test tests => 18;

language_output_is( 'Pipp', <<'CODE', <<'OUT', 'floatval()' );
<?php
Expand Down

0 comments on commit 9f8f981

Please sign in to comment.