[cage] Update release manager guide about committing to trunk near a release, based...
[parrot.git] / t / pharness / 01-default_tests.t
blob8c90086e10d82d2a10baaeffdf8ccc87b3315ae6
1 #! perl
2 # Copyright (C) 2007-2009, Parrot Foundation.
3 # $Id$
4 # 01-default_tests.t
6 use strict;
7 use warnings;
9 use lib qw( lib );
10 use Test::More;
11 eval {
12     use Parrot::Config qw( %PConfig );
14 plan( skip_all => 't/harness only runs once configuration has completed' ) if $@;
15 plan( tests => 29 );
16 use Carp;
17 use Cwd;
18 use File::Temp qw( tempdir );
19 use Parrot::Harness::DefaultTests;
21 @Parrot::Harness::DefaultTests::runcore_tests = qw( alpha.t );
22 @Parrot::Harness::DefaultTests::core_tests = qw( beta.t );
23 @Parrot::Harness::DefaultTests::configure_tests = qw( gamma.t );
24 @Parrot::Harness::DefaultTests::developing_tests = qw( epsilon.t );
25 @Parrot::Harness::DefaultTests::library_tests = qw( zeta.t );
28 my ($core_tests_only, $runcore_tests_only);
29 my (@default_tests, $default_tests_ref);
30 my %default_tests_seen;
32 my $cwd = cwd();
33 my $longopts = {};
35     # Simulate non-existence of DEVELOPING
36     my $tdir1 = tempdir( CLEANUP => 1 );
37     ok( chdir $tdir1, "Able to change to tempdir for testing");
39 #    ($core_tests_only, $runcore_tests_only) = (0,1);
40     $longopts = { core_tests_only => 0, runcore_tests_only => 1 };
41     ok(@default_tests =
42         get_common_tests( $longopts ),
43         "get_common_tests() returned successfully");
44     is(scalar(@default_tests), 1, "Got expected 1 test");
45     is($default_tests[0], q{alpha.t}, "runcore_tests only as expected");
47     @default_tests = ();
48     $longopts = { core_tests_only => 1, runcore_tests_only => 0 };
49     ok(@default_tests =
50         get_common_tests( $longopts ),
51         "get_common_tests() returned successfully");
52     is(scalar(@default_tests), 2, "Got expected 2 tests");
53     is($default_tests[1], q{beta.t}, "core_tests only as expected");
55     @default_tests = ();
56     $longopts = { core_tests_only => 0, runcore_tests_only => 0 };
57     ok(@default_tests =
58         get_common_tests( $longopts ),
59         "get_common_tests() returned successfully");
60     is(scalar(@default_tests), 4, "Got expected 4 tests");
61     is($default_tests[0], q{gamma.t}, "Start with configure_tests as expected");
62     is($default_tests[3], q{zeta.t}, "End with library_tests as expected");
64     @default_tests = ();
65     $longopts = { core_tests_only => 0, runcore_tests_only => 0 };
66     ok($default_tests_ref =
67         get_common_tests( $longopts ),
68         "get_common_tests() returned successfully");
69     is(scalar(@{ $default_tests_ref }), 4, "Got expected 4 tests");
71     ok(chdir $cwd, "Able to change back to starting directory after testing");
75     # Simulate existence of DEVELOPING
76     my $tdir2 = tempdir( CLEANUP => 1 );
77     ok( chdir $tdir2, "Able to change to tempdir for testing");
78     open my $FH, ">", q{DEVELOPING}
79         or croak "Unable to open file for writing";
80     print $FH qq{12345\n};
81     close $FH or croak "Unable to close file after writing";
83     $longopts = { core_tests_only => 0, runcore_tests_only => 1 };
84     ok(@default_tests =
85         get_common_tests( $longopts ),
86         "get_common_tests() returned successfully");
87     is(scalar(@default_tests), 1, "Got expected 1 test");
88     is($default_tests[0], q{alpha.t}, "runcore_tests only as expected");
90     @default_tests = ();
91     $longopts = { core_tests_only => 1, runcore_tests_only => 0 };
92     ok(@default_tests =
93         get_common_tests( $longopts ),
94         "get_common_tests() returned successfully");
95     is(scalar(@default_tests), 2, "Got expected 2 tests");
96     is($default_tests[1], q{beta.t}, "core_tests only as expected");
98     @default_tests = ();
99     $longopts = { core_tests_only => 0, runcore_tests_only => 0 };
100     ok(@default_tests =
101         get_common_tests( $longopts ),
102         "get_common_tests() returned successfully");
103     is(scalar(@default_tests), 4, "Got expected 4 tests");
104     is($default_tests[0], q{gamma.t}, "Start with configure_tests as expected");
105     is($default_tests[3], q{zeta.t}, "End with library_tests as expected");
107     @default_tests = ();
108     $longopts = { core_tests_only => 0, runcore_tests_only => 0 };
109     ok($default_tests_ref =
110         get_common_tests( $longopts ),
111         "get_common_tests() returned successfully");
112     is(scalar(@{ $default_tests_ref }), 4, "Got expected 4 tests");
113     # reset for subsequent tests
115     ok(chdir $cwd, "Able to change back to starting directory after testing");
118 pass("Completed all tests in $0");
120 ################### DOCUMENTATION ###################
122 =head1 NAME
124 01-default_tests.t - test Parrot::Harness::DefaultTests
126 =head1 SYNOPSIS
128     % prove t/pharness/01-default_tests.t
130 =head1 DESCRIPTION
132 This file holds tests for Parrot::Harness::DefaultTests::get_common_tests().
134 =head1 AUTHOR
136 James E Keenan
138 =head1 SEE ALSO
140 Parrot::Harness::DefaultTests, F<t/harness>.
142 =cut
144 # Local Variables:
145 #   mode: cperl
146 #   cperl-indent-level: 4
147 #   fill-column: 100
148 # End:
149 # vim: expandtab shiftwidth=4: