2 # Copyright (C) 2007, The Perl Foundation.
12 use Parrot::Config qw( %PConfig );
14 plan( skip_all => 't/harness only runs once configuration has completed' )
19 use File::Temp qw( tempdir );
20 use Parrot::Harness::DefaultTests;
22 @Parrot::Harness::DefaultTests::runcore_tests = qw( alpha.t );
23 @Parrot::Harness::DefaultTests::core_tests = qw( beta.t );
24 @Parrot::Harness::DefaultTests::configure_tests = qw( gamma.t );
25 @Parrot::Harness::DefaultTests::standard_tests = qw( delta.t );
26 @Parrot::Harness::DefaultTests::developing_tests = qw( epsilon.t );
28 my ($core_tests_only, $runcore_tests_only);
29 my (@default_tests, $default_tests_ref);
30 my %default_tests_seen;
34 # Simulate non-existence of DEVELOPING
35 my $tdir1 = tempdir( CLEANUP => 1 );
36 ok( chdir $tdir1, "Able to change to tempdir for testing");
38 ($core_tests_only, $runcore_tests_only) = (0,1);
40 get_default_tests($core_tests_only, $runcore_tests_only),
41 "get_default_tests() returned successfully");
42 is(scalar(@default_tests), 1, "Got expected 1 test");
43 is($default_tests[0], q{alpha.t}, "runcore_tests only as expected");
46 ($core_tests_only, $runcore_tests_only) = (1,0);
48 get_default_tests($core_tests_only, $runcore_tests_only),
49 "get_default_tests() returned successfully");
50 is(scalar(@default_tests), 2, "Got expected 2 tests");
51 is($default_tests[1], q{beta.t}, "core_tests only as expected");
54 ($core_tests_only, $runcore_tests_only) = (0,0);
56 get_default_tests($core_tests_only, $runcore_tests_only),
57 "get_default_tests() returned successfully");
58 is(scalar(@default_tests), 4, "Got expected 4 tests");
59 is($default_tests[0], q{gamma.t}, "Start with configure_tests as expected");
60 is($default_tests[3], q{delta.t}, "End with standard_tests as expected");
63 ($core_tests_only, $runcore_tests_only) = (0,0);
64 ok($default_tests_ref =
65 get_default_tests($core_tests_only, $runcore_tests_only),
66 "get_default_tests() returned successfully");
67 is(scalar(@{ $default_tests_ref }), 4, "Got expected 4 tests");
69 ok(chdir $cwd, "Able to change back to starting directory after testing");
73 # Simulate existence of DEVELOPING
74 my $tdir2 = tempdir( CLEANUP => 1 );
75 ok( chdir $tdir2, "Able to change to tempdir for testing");
76 open my $FH, ">", q{DEVELOPING}
77 or croak "Unable to open file for writing";
78 print $FH qq{12345\n};
79 close $FH or croak "Unable to close file after writing";
81 ($core_tests_only, $runcore_tests_only) = (0,1);
83 get_default_tests($core_tests_only, $runcore_tests_only),
84 "get_default_tests() returned successfully");
85 is(scalar(@default_tests), 1, "Got expected 1 test");
86 is($default_tests[0], q{alpha.t}, "runcore_tests only as expected");
87 @Parrot::Harness::DefaultTests::standard_tests = qw( delta.t );
90 ($core_tests_only, $runcore_tests_only) = (1,0);
92 get_default_tests($core_tests_only, $runcore_tests_only),
93 "get_default_tests() returned successfully");
94 is(scalar(@default_tests), 2, "Got expected 2 tests");
95 is($default_tests[1], q{beta.t}, "core_tests only as expected");
96 @Parrot::Harness::DefaultTests::standard_tests = qw( delta.t );
99 ($core_tests_only, $runcore_tests_only) = (0,0);
101 get_default_tests($core_tests_only, $runcore_tests_only),
102 "get_default_tests() returned successfully");
103 is(scalar(@default_tests), 5, "Got expected 5 tests");
104 is($default_tests[0], q{gamma.t}, "Start with configure_tests as expected");
105 is($default_tests[3], q{delta.t}, "End with standard_tests as expected");
106 is($default_tests[4], q{epsilon.t},
107 "standard_tests include developing_tests");
108 @Parrot::Harness::DefaultTests::standard_tests = qw( delta.t );
111 ($core_tests_only, $runcore_tests_only) = (0,0);
112 ok($default_tests_ref =
113 get_default_tests($core_tests_only, $runcore_tests_only),
114 "get_default_tests() returned successfully");
115 is(scalar(@{ $default_tests_ref }), 5, "Got expected 5 tests");
116 @Parrot::Harness::DefaultTests::standard_tests = qw( delta.t );
118 ok(chdir $cwd, "Able to change back to starting directory after testing");
121 pass("Completed all tests in $0");
123 ################### DOCUMENTATION ###################
127 01-default_tests.t - test Parrot::Harness::DefaultTests
131 % prove t/pharness/01-default_tests.t
135 This file holds tests for Parrot::Harness::DefaultTests::get_default_tests().
143 Parrot::Harness::DefaultTests, F<t/harness>.
149 # cperl-indent-level: 4
152 # vim: expandtab shiftwidth=4: