2 # Copyright (C) 2007-2009, Parrot Foundation.
12 use Parrot::Config qw( %PConfig );
14 plan( skip_all => 't/harness only runs once configuration has completed' ) if $@;
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;
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 };
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");
48 $longopts = { core_tests_only => 1, runcore_tests_only => 0 };
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");
56 $longopts = { core_tests_only => 0, runcore_tests_only => 0 };
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");
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 };
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");
91 $longopts = { core_tests_only => 1, runcore_tests_only => 0 };
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");
99 $longopts = { core_tests_only => 0, runcore_tests_only => 0 };
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");
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 ###################
124 01-default_tests.t - test Parrot::Harness::DefaultTests
128 % prove t/pharness/01-default_tests.t
132 This file holds tests for Parrot::Harness::DefaultTests::get_common_tests().
140 Parrot::Harness::DefaultTests, F<t/harness>.
146 # cperl-indent-level: 4
149 # vim: expandtab shiftwidth=4: