Ticket #1061: library_files.trunk.diff
File library_files.trunk.diff, 14.6 KB (added by jkeenan, 12 years ago) |
---|
-
lib/Parrot/Harness/DefaultTests.pm
7 7 8 8 =head1 DESCRIPTION 9 9 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. 10 Upon request, this package exports six arrays holding various sets of paths to 11 directories holding test files: 12 12 13 Upon request, this package exports six arrays holding various sets of tests:14 15 13 @runcore_tests 16 14 @core_tests 17 15 @library_tests 18 16 @configure_tests 19 @standard_tests20 17 @developing_tests 21 18 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. 19 Each of these arrays holds a list of paths containing wildcards which are 20 expanded by the shell when provided to programs such as F<t/harness>. The 21 paths describe directories holding test files. 24 22 23 Example: 24 25 @core_tests = qw( 26 t/run/*.t 27 t/src/*.t 28 t/perl/*.t 29 ); 30 31 32 In addition, Parrot::Harness::Default Tests exports B<by default> one 33 subroutine: C<get_default_tests()>. In list context, C<get_default_tests()> 34 returns a list of shell-expandable paths to the most common tests. In scalar 35 context it returns a reference to that list. 36 25 37 =cut 26 38 27 39 package Parrot::Harness::DefaultTests; … … 34 46 @core_tests, 35 47 @library_tests, 36 48 @configure_tests, 37 @standard_tests,38 49 @developing_tests 39 50 ); 40 51 use base qw( Exporter ); 41 our @EXPORT = qw( get_ default_tests );52 our @EXPORT = qw( get_common_tests ); 42 53 our @EXPORT_OK = qw( 43 54 @runcore_tests 44 55 @core_tests 45 56 @library_tests 46 57 @configure_tests 47 @standard_tests48 58 @developing_tests 49 59 ); 50 60 … … 79 89 ); 80 90 81 91 # 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 options83 # present84 92 @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' ), 90 97 ); 91 98 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'; 99 sub get_common_tests { 100 my ($longopts) = @_; 95 101 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; 118 108 } 119 109 } 120 110 wantarray 121 ? return @ default_tests122 : return [ @ default_tests ];111 ? return @common_tests 112 : return [ @common_tests ]; 123 113 } 124 114 125 115 1; -
t/pharness/01-default_tests.t
12 12 use Parrot::Config qw( %PConfig ); 13 13 }; 14 14 plan( skip_all => 't/harness only runs once configuration has completed' ) if $@; 15 plan( tests => 30);15 plan( tests => 29 ); 16 16 use Carp; 17 17 use Cwd; 18 18 use File::Temp qw( tempdir ); … … 21 21 @Parrot::Harness::DefaultTests::runcore_tests = qw( alpha.t ); 22 22 @Parrot::Harness::DefaultTests::core_tests = qw( beta.t ); 23 23 @Parrot::Harness::DefaultTests::configure_tests = qw( gamma.t ); 24 @Parrot::Harness::DefaultTests::standard_tests = qw( delta.t );25 24 @Parrot::Harness::DefaultTests::developing_tests = qw( epsilon.t ); 26 25 @Parrot::Harness::DefaultTests::library_tests = qw( zeta.t ); 27 26 … … 31 30 my %default_tests_seen; 32 31 33 32 my $cwd = cwd(); 33 my $longopts = {}; 34 34 { 35 35 # Simulate non-existence of DEVELOPING 36 36 my $tdir1 = tempdir( CLEANUP => 1 ); 37 37 ok( chdir $tdir1, "Able to change to tempdir for testing"); 38 38 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 }; 40 41 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"); 43 44 is(scalar(@default_tests), 1, "Got expected 1 test"); 44 45 is($default_tests[0], q{alpha.t}, "runcore_tests only as expected"); 45 46 46 47 @default_tests = (); 47 ($core_tests_only, $runcore_tests_only) = (1,0);48 $longopts = { core_tests_only => 1, runcore_tests_only => 0 }; 48 49 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"); 51 52 is(scalar(@default_tests), 2, "Got expected 2 tests"); 52 53 is($default_tests[1], q{beta.t}, "core_tests only as expected"); 53 54 54 55 @default_tests = (); 55 ($core_tests_only, $runcore_tests_only) = (0,0);56 $longopts = { core_tests_only => 0, runcore_tests_only => 0 }; 56 57 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"); 59 60 is(scalar(@default_tests), 4, "Got expected 4 tests"); 60 61 is($default_tests[0], q{gamma.t}, "Start with configure_tests as expected"); 61 62 is($default_tests[3], q{zeta.t}, "End with library_tests as expected"); 62 63 63 64 @default_tests = (); 64 ($core_tests_only, $runcore_tests_only) = (0,0);65 $longopts = { core_tests_only => 0, runcore_tests_only => 0 }; 65 66 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"); 68 69 is(scalar(@{ $default_tests_ref }), 4, "Got expected 4 tests"); 69 70 70 71 ok(chdir $cwd, "Able to change back to starting directory after testing"); … … 79 80 print $FH qq{12345\n}; 80 81 close $FH or croak "Unable to close file after writing"; 81 82 82 ($core_tests_only, $runcore_tests_only) = (0,1);83 $longopts = { core_tests_only => 0, runcore_tests_only => 1 }; 83 84 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"); 86 87 is(scalar(@default_tests), 1, "Got expected 1 test"); 87 88 is($default_tests[0], q{alpha.t}, "runcore_tests only as expected"); 88 # reset for subsequent tests89 @Parrot::Harness::DefaultTests::standard_tests = qw( delta.t );90 89 91 90 @default_tests = (); 92 ($core_tests_only, $runcore_tests_only) = (1,0);91 $longopts = { core_tests_only => 1, runcore_tests_only => 0 }; 93 92 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"); 96 95 is(scalar(@default_tests), 2, "Got expected 2 tests"); 97 96 is($default_tests[1], q{beta.t}, "core_tests only as expected"); 98 # reset for subsequent tests99 @Parrot::Harness::DefaultTests::standard_tests = qw( delta.t );100 97 101 98 @default_tests = (); 102 ($core_tests_only, $runcore_tests_only) = (0,0);99 $longopts = { core_tests_only => 0, runcore_tests_only => 0 }; 103 100 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"); 106 103 is(scalar(@default_tests), 4, "Got expected 4 tests"); 107 104 is($default_tests[0], q{gamma.t}, "Start with configure_tests as expected"); 108 105 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 tests112 @Parrot::Harness::DefaultTests::standard_tests = qw( delta.t );113 106 114 107 @default_tests = (); 115 ($core_tests_only, $runcore_tests_only) = (0,0);108 $longopts = { core_tests_only => 0, runcore_tests_only => 0 }; 116 109 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"); 119 112 is(scalar(@{ $default_tests_ref }), 4, "Got expected 4 tests"); 120 113 # reset for subsequent tests 121 @Parrot::Harness::DefaultTests::standard_tests = qw( delta.t );122 114 123 115 ok(chdir $cwd, "Able to change back to starting directory after testing"); 124 116 } … … 137 129 138 130 =head1 DESCRIPTION 139 131 140 This file holds tests for Parrot::Harness::DefaultTests::get_ default_tests().132 This file holds tests for Parrot::Harness::DefaultTests::get_common_tests(). 141 133 142 134 =head1 AUTHOR 143 135 -
t/harness
4 4 5 5 use strict; 6 6 use warnings; 7 use Data::Dumper;$Data::Dumper::Indent=1; 7 8 use lib qw( lib ); 8 9 9 10 use Getopt::Std; … … 13 14 undef $Test::Harness::Switches; 14 15 15 16 use Parrot::Harness::DefaultTests qw( 16 get_ default_tests17 get_common_tests 17 18 @developing_tests 18 19 ); 19 20 use Parrot::Harness::Options qw( … … 50 51 ); 51 52 $ENV{TEST_PROG_ARGS} = $args; 52 53 53 # now build the list of tests to run, either from the command54 # line or from @default tests55 my @default_tests = get_default_tests(56 $longopts->{core_tests_only},57 $longopts->{runcore_tests_only}58 );59 60 54 my @tests; 61 55 if ($longopts->{code}) { 62 56 @tests = @developing_tests; 63 57 } 64 58 else { 65 @tests = map { glob($_) } (@ARGV ? @ARGV : @default_tests); 59 @tests = map { glob($_) } (@ARGV 60 ? @ARGV 61 : get_common_tests( $longopts ) 62 ); 66 63 } 67 64 68 65 my $harness; -
config/init/defaults.pm
20 20 21 21 use Config; 22 22 use FindBin; # see build_dir 23 use Parrot::BuildUtil; 23 24 use Parrot::Configure::Step; 24 use Parrot:: BuildUtil;25 use Parrot::Harness::DefaultTests (); 25 26 use Cwd qw(abs_path); 26 27 use File::Spec; 27 28 … … 266 267 # remember corrected archname - jit.pm was using $Config('archname') 267 268 _64_bit_adjustments($conf); 268 269 270 _set_default_tests($conf); 271 269 272 return 1; 270 273 } 271 274 … … 299 302 return 1; 300 303 } 301 304 305 sub _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 302 319 1; 303 320 304 321 # Local Variables: -
config/gen/makefiles/root.in
1417 1417 t/src/*.t 1418 1418 TOOLS_TEST_FILES := \ 1419 1419 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 1420 LIBRARY_TEST_FILES := @library_tests@ 1428 1421 PMC2CUTILS_DIR := t/tools/pmc2cutils 1429 1422 OPS2PMUTILS_DIR := t/tools/ops2pm 1430 1423 OPS2CUTILS_DIR := t/tools/ops2cutils … … 1451 1444 # We probably need a complete build before running the tests. 1452 1445 test_prep : all 1453 1446 1454 # We always want to test annotations are persisted in PBC during make test.1455 test_pbc_annotation_persistence : test_prep1456 $(PERL) t/harness $(EXTRA_TEST_ARGS) -r t/op/annotate.t1457 1458 1447 # Run test cases with a single call of t/harness. Users have to look at only 1459 1448 # one report. The default set of tests to run is contained in t/harness, 1460 1449 # make any edits there. Some tests are run in a separate harness only because … … 1464 1453 test : test_core nqp_test 1465 1454 1466 1455 # Test Parrot core. 1467 test_core: test_prep test_pbc_annotation_persistence1456 test_core: test_prep 1468 1457 $(PERL) t/harness $(EXTRA_TEST_ARGS) 1469 1458 1470 1459 # Test the NQP compiler … … 1500 1489 src_tests \ 1501 1490 run_tests \ 1502 1491 perl_tests \ 1503 extra_tests \1492 library_tests \ 1504 1493 nqp_test \ 1505 1494 codetest \ 1506 1495 benchmark_tests \ … … 1596 1585 configure_tests : 1597 1586 $(PERL) t/harness $(CONFIGURE_TEST_FILES) 1598 1587 1599 # extratests - tests run by make test but not by make fulltest or make cover1600 extra_tests : test_prep1601 $(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 1589 library_tests : test_prep 1590 $(PERL) t/harness $(EXTRA_TEST_ARGS) $(LIBRARY_TEST_FILES) 1602 1591 1603 1592 ############################################################################### 1604 1593 # … … 2113 2102 -@make@ perl_tests 2114 2103 2115 2104 cover-extra: cover.dummy 2116 -@make@ extra_tests2105 -@make@ library_tests 2117 2106 2118 2107 cover-codingstd: cover.dummy 2119 2108 -@make@ codingstd_tests