Author: jkeenan Date: Sat Jan 26 19:00:03 2008 New Revision: 25269 Added: branches/harness/lib/Parrot/Harness/Smoke.pm (contents, props changed) branches/harness/t/pharness/ branches/harness/t/pharness/01-default_tests.t (contents, props changed) Modified: branches/harness/MANIFEST branches/harness/config/gen/makefiles/root.in branches/harness/lib/Parrot/Configure/Options/Test.pm branches/harness/lib/Parrot/Harness/DefaultTests.pm branches/harness/t/harness
Log: 1. Added lib/Parrot/Harness/Smoke.pm as location to which smoke-test related code was refactored from t/harness. 2. Fine-tuning of lib/Parrot/Harness/DefaultTests.pm to increase testability: elimination of use of $FindBin::Bin; lists of test directories are now 'our' variables so they can be overridden in tests. 3. Added t/pharness/01-default_tests.t to test Parrot::Harness::DefaultTests. 4. config/gen/makefiles/root.in and lib/Parrot/Configure/Options/Test.pm: Added t/pharness/ to lists of directories whose tests are run in 'perl Configure.pl --test', 'perl Configure.pl --test=build' and 'make buildtools_tests'. Modified: branches/harness/MANIFEST ============================================================================== --- branches/harness/MANIFEST (original) +++ branches/harness/MANIFEST Sat Jan 26 19:00:03 2008 @@ -1,7 +1,7 @@ # ex: set ro: # $Id$ # -# generated by tools/dev/mk_manifest_and_skip.pl Sat Jan 26 17:55:27 2008 UT +# generated by tools/dev/mk_manifest_and_skip.pl Sun Jan 27 02:38:37 2008 UT # # See tools/dev/install_files.pl for documentation on the # format of this file. @@ -2450,6 +2450,7 @@ lib/Parrot/Docs/Section/Tests.pm [devel] lib/Parrot/Docs/Section/Tools.pm [devel] lib/Parrot/Harness/DefaultTests.pm [devel] +lib/Parrot/Harness/Smoke.pm [devel] lib/Parrot/Headerizer.pm [devel] lib/Parrot/IO/Directory.pm [devel] lib/Parrot/IO/File.pm [devel] @@ -3193,6 +3194,7 @@ t/perl/Parrot_PIR_Formatter.t [] t/perl/Parrot_Test.t [] t/perl/README [] +t/pharness/01-default_tests.t [] t/pmc/addrregistry.t [] t/pmc/array.t [] t/pmc/bigint.t [] Modified: branches/harness/config/gen/makefiles/root.in ============================================================================== --- branches/harness/config/gen/makefiles/root.in (original) +++ branches/harness/config/gen/makefiles/root.in Sat Jan 26 19:00:03 2008 @@ -1393,11 +1393,13 @@ OPS2PMUTILS_DIR = t/tools/ops2pmutils OPS2CUTILS_DIR = t/tools/ops2cutils REVISIONUTILS_DIR = t/tools/revision +HARNESS_DIR = t/pharness BUILDTOOLS_TEST_FILES = \ $(PMC2CUTILS_DIR)/*.t \ $(OPS2PMUTILS_DIR)/*.t \ $(OPS2CUTILS_DIR)/*.t \ - $(REVISIONUTILS_DIR)/*.t + $(REVISIONUTILS_DIR)/*.t \ + $(HARNESS_DIR)/*.t MANIFEST_DIR = t/manifest MANIFEST_TEST_FILES = \ $(MANIFEST_DIR)/01-basic.t \ Modified: branches/harness/lib/Parrot/Configure/Options/Test.pm ============================================================================== --- branches/harness/lib/Parrot/Configure/Options/Test.pm (original) +++ branches/harness/lib/Parrot/Configure/Options/Test.pm Sat Jan 26 19:00:03 2008 @@ -52,6 +52,7 @@ glob("t/tools/ops2cutils/*.t"), glob("t/tools/ops2pmutils/*.t"), glob("t/tools/revision/*.t"), + glob("t/pharness/*.t"), ); sub new { Modified: branches/harness/lib/Parrot/Harness/DefaultTests.pm ============================================================================== --- branches/harness/lib/Parrot/Harness/DefaultTests.pm (original) +++ branches/harness/lib/Parrot/Harness/DefaultTests.pm Sat Jan 26 19:00:03 2008 @@ -7,83 +7,84 @@ =head1 DESCRIPTION -This file exports a single subroutine, C<get_default_tests()>, which is the -list of tests run by F<t/harness> by default. +This file exports by default a single subroutine, C<get_default_tests()>, +which is the list of tests run by F<t/harness> by default. -C<get_default_tests()> in list context returns the list of default tests. In +In list context, C<get_default_tests()> returns the list of default tests. In scalar context it returns a reference to that list. =cut package Parrot::Harness::DefaultTests; use strict; -use lib qw( . lib ../lib ../../lib ); -use FindBin qw/$Bin/; use base qw( Exporter ); our @EXPORT = qw( get_default_tests ); +# runcore tests are always run. +our @runcore_tests = qw( + t/compilers/imcc/*/*.t + t/op/*.t + t/pmc/*.t + t/oo/*.t + t/native_pbc/*.t + t/dynpmc/*.t + t/dynoplibs/*.t + t/compilers/pge/*.t + t/compilers/pge/p5regex/*.t + t/compilers/pge/perl6regex/*.t + t/compilers/tge/*.t + t/library/*.t +); + +# core tests are run unless --runcore-tests is present. Typically +# this list and the list above are run in response to --core-tests +our @core_tests = qw( + t/run/*.t + t/src/*.t + t/tools/*.t + t/perl/*.t + t/stm/*.t +); + +# configure tests are tests to be run at the beginning of 'make test'; +# standard tests are other tests run by default with no core options +# present +our @configure_tests = qw( t/configure/*.t t/steps/*.t t/postconfigure/*.t ); +our @standard_tests = qw( + t/compilers/json/*.t + t/examples/*.t + t/doc/*.t + t/distro/manifest.t +); + +our @developing_tests = ( + 't/distro/file_metadata.t', + map { "t/codingstd/$_" } qw( + c_code_coda.t + c_header_guards.t + c_indent.t + c_struct.t + check_toxxx.t + copyright.t + cppcomments.t + cuddled_else.t + filenames.t + gmt_utc.t + linelength.t + pccmethod_deps.t + pir_code_coda.t + svn_id.t + tabs.t + trailing_space.t + ) +); + sub get_default_tests { my ($core_tests_only, $runcore_tests_only) = @_; - - # runcore tests are always run. - my @runcore_tests = qw( - t/compilers/imcc/*/*.t - t/op/*.t - t/pmc/*.t - t/oo/*.t - t/native_pbc/*.t - t/dynpmc/*.t - t/dynoplibs/*.t - t/compilers/pge/*.t - t/compilers/pge/p5regex/*.t - t/compilers/pge/perl6regex/*.t - t/compilers/tge/*.t - t/library/*.t - ); - - # core tests are run unless --runcore-tests is present. Typically - # this list and the list above are run in response to --core-tests - my @core_tests = qw( - t/run/*.t - t/src/*.t - t/tools/*.t - t/perl/*.t - t/stm/*.t - ); - - # configure tests are tests to be run at the beginning of 'make test'; - # standard tests are other tests run by default with no core options - # present - my @configure_tests = qw( t/configure/*.t t/steps/*.t t/postconfigure/*.t ); - my @standard_tests = qw( - t/compilers/json/*.t - t/examples/*.t - t/doc/*.t - t/distro/manifest.t - ); # add metadata.t and coding standards tests only if we're DEVELOPING - if ( -e "$Bin/../DEVELOPING" ) { - push @standard_tests, 't/distro/file_metadata.t'; - push @standard_tests, map { "t/codingstd/$_" } qw( - c_code_coda.t - c_header_guards.t - c_indent.t - c_struct.t - check_toxxx.t - copyright.t - cppcomments.t - cuddled_else.t - filenames.t - gmt_utc.t - linelength.t - pccmethod_deps.t - pir_code_coda.t - svn_id.t - tabs.t - trailing_space.t - ); - # XXX: This takes WAY too long to run: perlcritic.t + if ( -e "DEVELOPING" ) { + push @standard_tests, @developing_tests; } # build the list of default tests Added: branches/harness/lib/Parrot/Harness/Smoke.pm ============================================================================== --- (empty file) +++ branches/harness/lib/Parrot/Harness/Smoke.pm Sat Jan 26 19:00:03 2008 @@ -0,0 +1,104 @@ +# Copyright (C) 2006-2007, The Perl Foundation. +# $Id$ + +=head1 NAME + +Parrot::Harness::Smoke - Subroutines used by F<t/harness> to generate smoke reports + +=head1 DESCRIPTION + +This package exports on request subroutines used by F<t/harness> to generate +smoke reports. + +Currently, only one such subroutine is supported: + + generate_html_smoke_report ( + tests => [EMAIL PROTECTED], + args => $args, + ); + +=cut + +package Parrot::Harness::Smoke; +use strict; +use lib qw( . lib ../lib ../../lib ); +use Parrot::Config qw/%PConfig/; +use base qw( Exporter ); +our @EXPORT_OK = qw( generate_html_smoke_report ); + + +sub generate_html_smoke_report { + my $argsref = shift; + my @smoke_config_vars = qw( + osname archname cc build_dir cpuarch revision VERSION optimize DEVEL + ); + + eval { + require Test::TAP::HTMLMatrix; + require Test::TAP::Model::Visual; + }; + die "You must have Test::TAP::HTMLMatrix installed.\n\n$@" + if $@; + + { + no warnings qw/redefine once/; + *Test::TAP::Model::run_tests = sub { + my $self = shift; + + $self->_init; + $self->{meat}{start_time} = time; + + my %stats; + + foreach my $file (@_) { + my $data; + print STDERR "- $file\n"; + $data = $self->run_test($file); + $stats{tests} += $data->{results}{max} || 0; + $stats{ok} += $data->{results}{ok} || 0; + } + + printf STDERR "%s OK from %s tests (%.2f%% ok)\n\n", + $stats{ok}, + $stats{tests}, + $stats{ok} / $stats{tests} * 100; + + $self->{meat}{end_time} = time; + }; + + my $start = time(); + my $model = Test::TAP::Model::Visual->new(); + $model->run_tests( @{ $argsref->{tests} } ); + + my $end = time(); + + my $duration = $end - $start; + + my $v = Test::TAP::HTMLMatrix->new( + $model, + join("\n", + "duration: $duration", + "branch: unknown", + "harness_args: " . (($argsref->{args}) ? $argsref->{args} : "N/A"), + map { "$_: $PConfig{$_}" } sort @smoke_config_vars), + ); + + $v->has_inline_css(1); # no separate css file + + open HTML, ">", "smoke.html"; + print HTML $v->html; + close HTML; + + print "smoke.html has been generated.\n"; + } +} + +1; + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: + Modified: branches/harness/t/harness ============================================================================== --- branches/harness/t/harness (original) +++ branches/harness/t/harness Sat Jan 26 19:00:03 2008 @@ -91,9 +91,8 @@ use Getopt::Std; use Test::Harness(); -use Parrot::Config qw/%PConfig/; -#use FindBin qw/$Bin/; use Parrot::Harness::DefaultTests; +use Parrot::Harness::Smoke qw( generate_html_smoke_report ); # handle the long options @@ -184,68 +183,10 @@ elsif (!$html) { Test::Harness::runtests(@tests); } else { - my @smoke_config_vars = qw( - osname archname cc build_dir cpuarch revision VERSION optimize DEVEL - ); - - eval { - require Test::TAP::HTMLMatrix; - require Test::TAP::Model::Visual; - }; - die "You must have Test::TAP::HTMLMatrix installed.\n\n$@" - if $@; - - { - no warnings qw/redefine once/; - *Test::TAP::Model::run_tests = sub { - my $self = shift; - - $self->_init; - $self->{meat}{start_time} = time; - - my %stats; - - foreach my $file (@_) { - my $data; - print STDERR "- $file\n"; - $data = $self->run_test($file); - $stats{tests} += $data->{results}{max} || 0; - $stats{ok} += $data->{results}{ok} || 0; - } - - printf STDERR "%s OK from %s tests (%.2f%% ok)\n\n", - $stats{ok}, - $stats{tests}, - $stats{ok} / $stats{tests} * 100; - - $self->{meat}{end_time} = time; - }; - - my $start = time(); - my $model = Test::TAP::Model::Visual->new(); - $model->run_tests(@tests); - - my $end = time(); - - my $duration = $end - $start; - - my $v = Test::TAP::HTMLMatrix->new( - $model, - join("\n", - "duration: $duration", - "branch: unknown", - "harness_args: " . (($args) ? $args : "N/A"), - map { "$_: $PConfig{$_}" } sort @smoke_config_vars), - ); - - $v->has_inline_css(1); # no separate css file - - open HTML, ">", "smoke.html"; - print HTML $v->html; - close HTML; - - print "smoke.html has been generated.\n"; - } + generate_html_smoke_report ( { + tests => [EMAIL PROTECTED], + args => $args, + } ); } =head1 HISTORY Added: branches/harness/t/pharness/01-default_tests.t ============================================================================== --- (empty file) +++ branches/harness/t/pharness/01-default_tests.t Sat Jan 26 19:00:03 2008 @@ -0,0 +1,161 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 01-default_tests.t + +use strict; +use warnings; + +use lib qw( lib ); +#use Test::More; +#eval { +# use Parrot::Config qw( %PConfig ); +#}; +#plan( skip_all => 't/harness only runs once configuration has completed' ) +# if $@; +#plan( tests => 2 ); +use Test::More qw( no_plan ); +use Carp; +use Cwd; +use File::Temp qw( tempdir ); +use Parrot::Harness::DefaultTests; +use FindBin qw/$Bin/; + [EMAIL PROTECTED]::Harness::DefaultTests::runcore_tests = qw( alpha.t ); [EMAIL PROTECTED]::Harness::DefaultTests::core_tests = qw( beta.t ); [EMAIL PROTECTED]::Harness::DefaultTests::configure_tests = qw( gamma.t ); [EMAIL PROTECTED]::Harness::DefaultTests::standard_tests = qw( delta.t ); [EMAIL PROTECTED]::Harness::DefaultTests::developing_tests = qw( epsilon.t ); + +my ($core_tests_only, $runcore_tests_only); +my (@default_tests, $default_tests_ref); +my %default_tests_seen; + +my $cwd = cwd(); +{ + # Simulate non-existence of DEVELOPING + my $tdir1 = tempdir(); + ok( chdir $tdir1, "Able to change to tempdir for testing"); + + ($core_tests_only, $runcore_tests_only) = (0,1); + ok(@default_tests = + get_default_tests($core_tests_only, $runcore_tests_only), + "get_default_tests() returned successfully"); + is(scalar(@default_tests), 1, "Got expected 1 test"); + is($default_tests[0], q{alpha.t}, "runcore_tests only as expected"); + + @default_tests = (); + ($core_tests_only, $runcore_tests_only) = (1,0); + ok(@default_tests = + get_default_tests($core_tests_only, $runcore_tests_only), + "get_default_tests() returned successfully"); + is(scalar(@default_tests), 2, "Got expected 2 tests"); + is($default_tests[1], q{beta.t}, "core_tests only as expected"); + + @default_tests = (); + ($core_tests_only, $runcore_tests_only) = (0,0); + ok(@default_tests = + get_default_tests($core_tests_only, $runcore_tests_only), + "get_default_tests() returned successfully"); + is(scalar(@default_tests), 4, "Got expected 4 tests"); + is($default_tests[0], q{gamma.t}, "Start with configure_tests as expected"); + is($default_tests[3], q{delta.t}, "End with standard_tests as expected"); + + @default_tests = (); + ($core_tests_only, $runcore_tests_only) = (0,0); + ok($default_tests_ref = + get_default_tests($core_tests_only, $runcore_tests_only), + "get_default_tests() returned successfully"); + is(scalar(@{ $default_tests_ref }), 4, "Got expected 4 tests"); + + ok(chdir $cwd, "Able to change back to starting directory after testing"); +} + +{ + # Simulate existence of DEVELOPING + my $tdir2 = tempdir(); + ok( chdir $tdir2, "Able to change to tempdir for testing"); + open my $FH, ">", q{DEVELOPING} + or croak "Unable to open file for writing"; + print $FH qq{12345\n}; + close $FH or croak "Unable to close file after writing"; + + ($core_tests_only, $runcore_tests_only) = (0,1); + ok(@default_tests = + get_default_tests($core_tests_only, $runcore_tests_only), + "get_default_tests() returned successfully"); + is(scalar(@default_tests), 1, "Got expected 1 test"); + is($default_tests[0], q{alpha.t}, "runcore_tests only as expected"); + @Parrot::Harness::DefaultTests::standard_tests = qw( delta.t ); + + @default_tests = (); + ($core_tests_only, $runcore_tests_only) = (1,0); + ok(@default_tests = + get_default_tests($core_tests_only, $runcore_tests_only), + "get_default_tests() returned successfully"); + is(scalar(@default_tests), 2, "Got expected 2 tests"); + is($default_tests[1], q{beta.t}, "core_tests only as expected"); + @Parrot::Harness::DefaultTests::standard_tests = qw( delta.t ); + + @default_tests = (); + ($core_tests_only, $runcore_tests_only) = (0,0); + ok(@default_tests = + get_default_tests($core_tests_only, $runcore_tests_only), + "get_default_tests() returned successfully"); + is(scalar(@default_tests), 5, "Got expected 5 tests"); + is($default_tests[0], q{gamma.t}, "Start with configure_tests as expected"); + is($default_tests[3], q{delta.t}, "End with standard_tests as expected"); + is($default_tests[4], q{epsilon.t}, + "standard_tests include developing_tests"); + @Parrot::Harness::DefaultTests::standard_tests = qw( delta.t ); + + @default_tests = (); + ($core_tests_only, $runcore_tests_only) = (0,0); + ok($default_tests_ref = + get_default_tests($core_tests_only, $runcore_tests_only), + "get_default_tests() returned successfully"); + is(scalar(@{ $default_tests_ref }), 5, "Got expected 5 tests"); + @Parrot::Harness::DefaultTests::standard_tests = qw( delta.t ); + + ok(chdir $cwd, "Able to change back to starting directory after testing"); +} + +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +01-default_tests.t - test Parrot::Harness::DefaultTests + +=head1 SYNOPSIS + + % prove t/pharness/01-default_tests.t + +=head1 DESCRIPTION + + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +Parrot::Harness::DefaultTests, F<t/harness>. + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: + +#### + +#( -e "$Bin/../DEVELOPING" ) ? print STDERR "Exists\n" +# : print STDERR "with bin Does not exist\n"; +#( -e "DEVELOPING" ) ? print STDERR "Exists\n" +# : print STDERR "Does not exist\n"; +