Ticket #1061: library_files.trunk.diff

File library_files.trunk.diff, 14.6 KB (added by jkeenan, 12 years ago)

svn diff between trunk (at branch point) and library_files branch

  • lib/Parrot/Harness/DefaultTests.pm

     
    77 
    88=head1 DESCRIPTION 
    99 
    10 This file exports by default a single subroutine, C<get_default_tests()>, 
    11 which is the list of tests run by F<t/harness> by default. 
     10Upon request, this package exports six arrays holding various sets of paths to 
     11directories holding test files: 
    1212 
    13 Upon request, this package exports six arrays holding various sets of tests: 
    14  
    1513    @runcore_tests 
    1614    @core_tests 
    1715    @library_tests 
    1816    @configure_tests 
    19     @standard_tests 
    2017    @developing_tests 
    2118 
    22 In list context, C<get_default_tests()> returns the list of default tests.  In 
    23 scalar context it returns a reference to that list. 
     19Each of these arrays holds a list of paths containing wildcards which are 
     20expanded by the shell when provided to programs such as F<t/harness>.  The 
     21paths describe directories holding test files. 
    2422 
     23Example: 
     24 
     25    @core_tests = qw( 
     26        t/run/*.t 
     27        t/src/*.t 
     28        t/perl/*.t 
     29    ); 
     30 
     31 
     32In addition, Parrot::Harness::Default Tests exports B<by default> one 
     33subroutine:  C<get_default_tests()>.  In list context, C<get_default_tests()> 
     34returns a list of shell-expandable paths to the most common tests.  In scalar 
     35context it returns a reference to that list. 
     36 
    2537=cut 
    2638 
    2739package Parrot::Harness::DefaultTests; 
     
    3446    @core_tests, 
    3547    @library_tests, 
    3648    @configure_tests, 
    37     @standard_tests, 
    3849    @developing_tests 
    3950); 
    4051use base qw( Exporter ); 
    41 our @EXPORT = qw( get_default_tests ); 
     52our @EXPORT = qw( get_common_tests ); 
    4253our @EXPORT_OK = qw( 
    4354    @runcore_tests 
    4455    @core_tests 
    4556    @library_tests 
    4657    @configure_tests 
    47     @standard_tests 
    4858    @developing_tests 
    4959); 
    5060 
     
    7989); 
    8090 
    8191# configure tests are tests to be run at the beginning of 'make test'; 
    82 # standard tests are other tests run by default with no core options 
    83 # present 
    8492@configure_tests = qw( t/configure/*.t t/steps/*.t t/postconfigure/*.t ); 
    85 @standard_tests = qw( 
    86     t/compilers/json/*.t 
    87     t/examples/*.t 
    88     t/doc/*.t 
    89     t/distro/manifest.t 
     93 
     94@developing_tests = ( 
     95    't/distro/file_metadata.t', 
     96    ( glob 't/codingstd/*.t' ), 
    9097); 
    9198 
    92 @developing_tests = ( 't/distro/file_metadata.t' ); 
    93 # Add in all t/codingstd except for a few skips. 
    94 push @developing_tests, glob 't/codingstd/*.t'; 
     99sub get_common_tests { 
     100    my ($longopts) = @_; 
    95101 
    96 sub get_default_tests { 
    97     my ($core_tests_only, $runcore_tests_only) = @_; 
    98  
    99     # Add metadata.t and coding standards tests only if we're DEVELOPING 
    100  
    101     # Note:  As of 2008-10-21, we're no longer including @standard_tests in 
    102     # @default_tests -- which means they're not included in 'make test'. 
    103     # But, for the time being, at least, we are still making 
    104     # it an exportable variable.  So we'll test for it in 
    105     # t/pharness/01-default_tests.t. 
    106  
    107     if ( -e "DEVELOPING" ) { 
    108         push @standard_tests, @developing_tests; 
    109     } 
    110  
    111     # build the list of default tests 
    112     my @default_tests = @runcore_tests; 
    113     unless ($runcore_tests_only) { 
    114        push @default_tests, @core_tests; 
    115        unless ($core_tests_only) { 
    116            push @default_tests, @library_tests; 
    117            unshift @default_tests, @configure_tests; 
     102    my @common_tests = @runcore_tests; 
     103    unless ($longopts->{runcore_tests_only}) { 
     104       push @common_tests, @core_tests; 
     105       unless ($longopts->{core_tests_only}) { 
     106           push @common_tests, @library_tests; 
     107           unshift @common_tests, @configure_tests; 
    118108       } 
    119109    } 
    120110    wantarray 
    121         ? return @default_tests 
    122         : return [ @default_tests ]; 
     111        ? return @common_tests 
     112        : return [ @common_tests ]; 
    123113} 
    124114 
    1251151; 
  • t/pharness/01-default_tests.t

     
    1212    use Parrot::Config qw( %PConfig ); 
    1313}; 
    1414plan( skip_all => 't/harness only runs once configuration has completed' ) if $@; 
    15 plan( tests => 30 ); 
     15plan( tests => 29 ); 
    1616use Carp; 
    1717use Cwd; 
    1818use File::Temp qw( tempdir ); 
     
    2121@Parrot::Harness::DefaultTests::runcore_tests = qw( alpha.t ); 
    2222@Parrot::Harness::DefaultTests::core_tests = qw( beta.t ); 
    2323@Parrot::Harness::DefaultTests::configure_tests = qw( gamma.t ); 
    24 @Parrot::Harness::DefaultTests::standard_tests = qw( delta.t ); 
    2524@Parrot::Harness::DefaultTests::developing_tests = qw( epsilon.t ); 
    2625@Parrot::Harness::DefaultTests::library_tests = qw( zeta.t ); 
    2726 
     
    3130my %default_tests_seen; 
    3231 
    3332my $cwd = cwd(); 
     33my $longopts = {}; 
    3434{ 
    3535    # Simulate non-existence of DEVELOPING 
    3636    my $tdir1 = tempdir( CLEANUP => 1 ); 
    3737    ok( chdir $tdir1, "Able to change to tempdir for testing"); 
    3838 
    39     ($core_tests_only, $runcore_tests_only) = (0,1); 
     39#    ($core_tests_only, $runcore_tests_only) = (0,1); 
     40    $longopts = { core_tests_only => 0, runcore_tests_only => 1 }; 
    4041    ok(@default_tests = 
    41         get_default_tests($core_tests_only, $runcore_tests_only), 
    42         "get_default_tests() returned successfully"); 
     42        get_common_tests( $longopts ), 
     43        "get_common_tests() returned successfully"); 
    4344    is(scalar(@default_tests), 1, "Got expected 1 test"); 
    4445    is($default_tests[0], q{alpha.t}, "runcore_tests only as expected"); 
    4546 
    4647    @default_tests = (); 
    47     ($core_tests_only, $runcore_tests_only) = (1,0); 
     48    $longopts = { core_tests_only => 1, runcore_tests_only => 0 }; 
    4849    ok(@default_tests = 
    49         get_default_tests($core_tests_only, $runcore_tests_only), 
    50         "get_default_tests() returned successfully"); 
     50        get_common_tests( $longopts ), 
     51        "get_common_tests() returned successfully"); 
    5152    is(scalar(@default_tests), 2, "Got expected 2 tests"); 
    5253    is($default_tests[1], q{beta.t}, "core_tests only as expected"); 
    5354 
    5455    @default_tests = (); 
    55     ($core_tests_only, $runcore_tests_only) = (0,0); 
     56    $longopts = { core_tests_only => 0, runcore_tests_only => 0 }; 
    5657    ok(@default_tests = 
    57         get_default_tests($core_tests_only, $runcore_tests_only), 
    58         "get_default_tests() returned successfully"); 
     58        get_common_tests( $longopts ), 
     59        "get_common_tests() returned successfully"); 
    5960    is(scalar(@default_tests), 4, "Got expected 4 tests"); 
    6061    is($default_tests[0], q{gamma.t}, "Start with configure_tests as expected"); 
    6162    is($default_tests[3], q{zeta.t}, "End with library_tests as expected"); 
    6263 
    6364    @default_tests = (); 
    64     ($core_tests_only, $runcore_tests_only) = (0,0); 
     65    $longopts = { core_tests_only => 0, runcore_tests_only => 0 }; 
    6566    ok($default_tests_ref = 
    66         get_default_tests($core_tests_only, $runcore_tests_only), 
    67         "get_default_tests() returned successfully"); 
     67        get_common_tests( $longopts ), 
     68        "get_common_tests() returned successfully"); 
    6869    is(scalar(@{ $default_tests_ref }), 4, "Got expected 4 tests"); 
    6970 
    7071    ok(chdir $cwd, "Able to change back to starting directory after testing"); 
     
    7980    print $FH qq{12345\n}; 
    8081    close $FH or croak "Unable to close file after writing"; 
    8182 
    82     ($core_tests_only, $runcore_tests_only) = (0,1); 
     83    $longopts = { core_tests_only => 0, runcore_tests_only => 1 }; 
    8384    ok(@default_tests = 
    84         get_default_tests($core_tests_only, $runcore_tests_only), 
    85         "get_default_tests() returned successfully"); 
     85        get_common_tests( $longopts ), 
     86        "get_common_tests() returned successfully"); 
    8687    is(scalar(@default_tests), 1, "Got expected 1 test"); 
    8788    is($default_tests[0], q{alpha.t}, "runcore_tests only as expected"); 
    88     # reset for subsequent tests 
    89     @Parrot::Harness::DefaultTests::standard_tests = qw( delta.t ); 
    9089 
    9190    @default_tests = (); 
    92     ($core_tests_only, $runcore_tests_only) = (1,0); 
     91    $longopts = { core_tests_only => 1, runcore_tests_only => 0 }; 
    9392    ok(@default_tests = 
    94         get_default_tests($core_tests_only, $runcore_tests_only), 
    95         "get_default_tests() returned successfully"); 
     93        get_common_tests( $longopts ), 
     94        "get_common_tests() returned successfully"); 
    9695    is(scalar(@default_tests), 2, "Got expected 2 tests"); 
    9796    is($default_tests[1], q{beta.t}, "core_tests only as expected"); 
    98     # reset for subsequent tests 
    99     @Parrot::Harness::DefaultTests::standard_tests = qw( delta.t ); 
    10097 
    10198    @default_tests = (); 
    102     ($core_tests_only, $runcore_tests_only) = (0,0); 
     99    $longopts = { core_tests_only => 0, runcore_tests_only => 0 }; 
    103100    ok(@default_tests = 
    104         get_default_tests($core_tests_only, $runcore_tests_only), 
    105         "get_default_tests() returned successfully"); 
     101        get_common_tests( $longopts ), 
     102        "get_common_tests() returned successfully"); 
    106103    is(scalar(@default_tests), 4, "Got expected 4 tests"); 
    107104    is($default_tests[0], q{gamma.t}, "Start with configure_tests as expected"); 
    108105    is($default_tests[3], q{zeta.t}, "End with library_tests as expected"); 
    109     is(scalar(@Parrot::Harness::DefaultTests::standard_tests), 
    110         2, "Got expected 2 coding standards tests"); 
    111     # reset for subsequent tests 
    112     @Parrot::Harness::DefaultTests::standard_tests = qw( delta.t ); 
    113106 
    114107    @default_tests = (); 
    115     ($core_tests_only, $runcore_tests_only) = (0,0); 
     108    $longopts = { core_tests_only => 0, runcore_tests_only => 0 }; 
    116109    ok($default_tests_ref = 
    117         get_default_tests($core_tests_only, $runcore_tests_only), 
    118         "get_default_tests() returned successfully"); 
     110        get_common_tests( $longopts ), 
     111        "get_common_tests() returned successfully"); 
    119112    is(scalar(@{ $default_tests_ref }), 4, "Got expected 4 tests"); 
    120113    # reset for subsequent tests 
    121     @Parrot::Harness::DefaultTests::standard_tests = qw( delta.t ); 
    122114 
    123115    ok(chdir $cwd, "Able to change back to starting directory after testing"); 
    124116} 
     
    137129 
    138130=head1 DESCRIPTION 
    139131 
    140 This file holds tests for Parrot::Harness::DefaultTests::get_default_tests(). 
     132This file holds tests for Parrot::Harness::DefaultTests::get_common_tests(). 
    141133 
    142134=head1 AUTHOR 
    143135 
  • t/harness

     
    44 
    55use strict; 
    66use warnings; 
     7use Data::Dumper;$Data::Dumper::Indent=1; 
    78use lib qw( lib ); 
    89 
    910use Getopt::Std; 
     
    1314undef $Test::Harness::Switches; 
    1415 
    1516use Parrot::Harness::DefaultTests qw( 
    16     get_default_tests 
     17    get_common_tests 
    1718    @developing_tests 
    1819); 
    1920use Parrot::Harness::Options qw( 
     
    5051); 
    5152$ENV{TEST_PROG_ARGS} = $args; 
    5253 
    53 # now build the list of tests to run, either from the command 
    54 # line or from @default tests 
    55 my @default_tests = get_default_tests( 
    56     $longopts->{core_tests_only}, 
    57     $longopts->{runcore_tests_only} 
    58 ); 
    59  
    6054my @tests; 
    6155if ($longopts->{code}) { 
    6256    @tests = @developing_tests; 
    6357} 
    6458else { 
    65     @tests = map { glob($_) } (@ARGV ? @ARGV : @default_tests); 
     59    @tests = map { glob($_) } (@ARGV 
     60        ? @ARGV 
     61        : get_common_tests( $longopts ) 
     62    ); 
    6663} 
    6764 
    6865my $harness; 
  • config/init/defaults.pm

     
    2020 
    2121use Config; 
    2222use FindBin;    # see build_dir 
     23use Parrot::BuildUtil; 
    2324use Parrot::Configure::Step; 
    24 use Parrot::BuildUtil; 
     25use Parrot::Harness::DefaultTests (); 
    2526use Cwd qw(abs_path); 
    2627use File::Spec; 
    2728 
     
    266267    # remember corrected archname - jit.pm was using $Config('archname') 
    267268    _64_bit_adjustments($conf); 
    268269 
     270    _set_default_tests($conf); 
     271 
    269272    return 1; 
    270273} 
    271274 
     
    299302    return 1; 
    300303} 
    301304 
     305sub _set_default_tests { 
     306    my $conf = shift; 
     307    $conf->data->set( 'runcore_tests' => 
     308        ( join ' ' => @Parrot::Harness::DefaultTests::runcore_tests ) ); 
     309    $conf->data->set( 'core_tests' => 
     310        ( join ' ' => @Parrot::Harness::DefaultTests::core_tests ) ); 
     311    $conf->data->set( 'library_tests' => 
     312        ( join ' ' => @Parrot::Harness::DefaultTests::library_tests ) ); 
     313    $conf->data->set( 'configure_tests' => 
     314        ( join ' ' => @Parrot::Harness::DefaultTests::configure_tests ) ); 
     315    $conf->data->set( 'developing_tests' => 
     316        ( join ' ' => @Parrot::Harness::DefaultTests::developing_tests ) ); 
     317} 
     318 
    3023191; 
    303320 
    304321# Local Variables: 
  • config/gen/makefiles/root.in

     
    14171417    t/src/*.t 
    14181418TOOLS_TEST_FILES := \ 
    14191419    t/tools/*.t 
    1420 EXTRA_TEST_FILES := \ 
    1421     t/compilers/pct/*.t \ 
    1422     t/compilers/pge/*.t \ 
    1423     t/compilers/pge/p5regex/*.t \ 
    1424     t/compilers/pge/perl6regex/*.t \ 
    1425     t/compilers/tge/*.t \ 
    1426     t/library/*.t \ 
    1427     t/tools/*.t 
     1420LIBRARY_TEST_FILES := @library_tests@ 
    14281421PMC2CUTILS_DIR := t/tools/pmc2cutils 
    14291422OPS2PMUTILS_DIR := t/tools/ops2pm 
    14301423OPS2CUTILS_DIR := t/tools/ops2cutils 
     
    14511444# We probably need a complete build before running the tests. 
    14521445test_prep : all 
    14531446 
    1454 # We always want to test annotations are persisted in PBC during make test. 
    1455 test_pbc_annotation_persistence : test_prep 
    1456         $(PERL) t/harness $(EXTRA_TEST_ARGS) -r t/op/annotate.t 
    1457  
    14581447# Run test cases with a single call of t/harness. Users have to look at only 
    14591448# one report. The default set of tests to run is contained in t/harness, 
    14601449# make any edits there. Some tests are run in a separate harness only because 
     
    14641453test : test_core nqp_test 
    14651454 
    14661455# Test Parrot core. 
    1467 test_core: test_prep test_pbc_annotation_persistence 
     1456test_core: test_prep 
    14681457        $(PERL) t/harness $(EXTRA_TEST_ARGS) 
    14691458 
    14701459# Test the NQP compiler 
     
    15001489        src_tests \ 
    15011490        run_tests \ 
    15021491        perl_tests \ 
    1503         extra_tests \ 
     1492        library_tests \ 
    15041493        nqp_test \ 
    15051494        codetest \ 
    15061495        benchmark_tests \ 
     
    15961585configure_tests : 
    15971586        $(PERL) t/harness $(CONFIGURE_TEST_FILES) 
    15981587 
    1599 # extra tests - tests run by make test but not by make fulltest or make cover 
    1600 extra_tests : test_prep 
    1601         $(PERL) t/harness $(EXTRA_TEST_ARGS) $(EXTRA_TEST_FILES) 
     1588# library tests - tests run by make test but not by make fulltest or make cover 
     1589library_tests : test_prep 
     1590        $(PERL) t/harness $(EXTRA_TEST_ARGS) $(LIBRARY_TEST_FILES) 
    16021591 
    16031592############################################################################### 
    16041593# 
     
    21132102        -@make@ perl_tests 
    21142103 
    21152104cover-extra: cover.dummy 
    2116         -@make@ extra_tests 
     2105        -@make@ library_tests 
    21172106 
    21182107cover-codingstd: cover.dummy 
    21192108        -@make@ codingstd_tests