2 # Copyright (C) 2007, Parrot Foundation.
8 use Test::More tests => 49;
12 use File::Temp qw| tempdir |;
14 use_ok('config::init::defaults');
15 use Parrot::Configure;
16 use Parrot::Configure::Step;
17 use Parrot::Configure::Options qw( process_options );
18 use base qw(Parrot::Configure::Step);
19 use Parrot::Configure::Test qw(
20 test_step_constructor_and_description
23 ########## no debugging; profile; m 32 ##########
25 my $pkg = q{init::defaults};
26 my ($args, $step_list_ref) = process_options(
28 argv => [ q{--debugging=0}, q{--profile}, q{--m=32} ],
33 my $conf = Parrot::Configure->new;
34 $conf->add_steps($pkg);
36 my $serialized = $conf->pcfreeze();
38 $conf->options->set( %{$args} );
39 my $step = test_step_constructor_and_description($conf);
40 my $ret = $step->runstep($conf);
41 ok( defined $ret, "runstep() returned defined value" );
43 $conf->replenish($serialized);
45 ########## mock absence of 'DEVELOPING' ##########
49 my $tdir = tempdir( CLEANUP => 1 );
50 ok( chdir $tdir, "Changed to temporary directory for testing" );
51 ok( copy( "$cwd/VERSION", "$tdir/VERSION" ),
52 "Able to copy VERSION for testing" );
54 my $pkg = q{init::defaults};
55 my ($args, $step_list_ref) = process_options(
61 $conf->options->set( %{$args} );
62 my $step = test_step_constructor_and_description($conf);
64 my $ret = $step->runstep($conf);
65 ok( defined $ret, "runstep() returned defined value" );
67 unlink "$tdir/VERSION"
68 or croak "Unable to unlink file from tempdir after testing";
69 ok( chdir $cwd, "Able to change back to directory after testing" );
72 $conf->replenish($serialized);
74 ########## m 32 ##########
76 ($args, $step_list_ref) = process_options(
78 argv => [ q{--m=32} ],
83 $conf->options->set( %{$args} );
84 $step = test_step_constructor_and_description($conf);
86 $conf->data->set( archname => 'x86_64' );
87 $conf->data->set( cc => 'cc' );
88 $conf->data->set( link => 'cc' );
89 $conf->data->set( ld => 'env cc' );
90 $conf->data->set( ld_load_flags => '-bundle -L/usr/local/lib64' );
91 $conf->data->set( ld_share_flags => '-bundle -L/usr/local/lib64' );
92 $conf->data->set( ldflags => '-bundle -L/usr/local/lib64' );
93 $conf->data->set( linkflags => '-bundle -L/usr/local/lib64' );
94 ok(init::defaults::_64_bit_adjustments($conf),
95 "_64_bit_adjustments() returned true");
96 is($conf->data->get( 'archname' ), 'i386', "Got expected value for 'archname'");
97 is($conf->data->get( 'cc' ), 'cc -m32', "Got expected value for 'cc'");
98 is($conf->data->get( 'link' ), 'cc -m32', "Got expected value for 'link'");
99 is($conf->data->get( 'ld' ), 'env cc -m32', "Got expected value for 'ld'");
100 is($conf->data->get( 'ld_load_flags' ), '-bundle -L/usr/local/lib',
101 "Got expected value for 'ld_load_flags'");
102 is($conf->data->get( 'ld_share_flags' ), '-bundle -L/usr/local/lib',
103 "Got expected value for 'ld_share_flags");
104 is($conf->data->get( 'ldflags' ), '-bundle -L/usr/local/lib',
105 "Got expected value for 'ldflags'");
106 is($conf->data->get( 'linkflags' ), '-bundle -L/usr/local/lib',
107 "Got expected value for 'linkflags'");
109 $conf->replenish($serialized);
111 ########## regular ##########
113 ($args, $step_list_ref) = process_options(
116 mode => q{configure},
120 $conf->options->set( %{$args} );
121 $step = test_step_constructor_and_description($conf);
123 $conf->data->set( archname => 'x86_64' );
124 $conf->data->set( cc => 'cc' );
125 $conf->data->set( link => 'cc' );
126 $conf->data->set( ld => 'env cc' );
127 $conf->data->set( ld_load_flags => '-bundle -L/usr/local/lib64' );
128 $conf->data->set( ld_share_flags => '-bundle -L/usr/local/lib64' );
129 $conf->data->set( ldflags => '-bundle -L/usr/local/lib64' );
130 $conf->data->set( linkflags => '-bundle -L/usr/local/lib64' );
131 ok(init::defaults::_64_bit_adjustments($conf),
132 "_64_bit_adjustments() returned true");
133 is($conf->data->get( 'archname' ), 'x86_64', "Got expected value for 'archname'");
134 is($conf->data->get( 'cc' ), 'cc', "Got expected value for 'cc'");
135 is($conf->data->get( 'link' ), 'cc', "Got expected value for 'link'");
136 is($conf->data->get( 'ld' ), 'env cc', "Got expected value for 'ld'");
137 is($conf->data->get( 'ld_load_flags' ), '-bundle -L/usr/local/lib64',
138 "Got expected value for 'ld_load_flags'");
139 is($conf->data->get( 'ld_share_flags' ), '-bundle -L/usr/local/lib64',
140 "Got expected value for 'ld_share_flags");
141 is($conf->data->get( 'ldflags' ), '-bundle -L/usr/local/lib64',
142 "Got expected value for 'ldflags'");
143 is($conf->data->get( 'linkflags' ), '-bundle -L/usr/local/lib64',
144 "Got expected value for 'linkflags'");
146 $conf->replenish($serialized);
148 ##### with extra-nci-thunks #####
149 ($args, $step_list_ref) = process_options(
152 mode => q{configure},
156 $conf->options->set( %{$args} );
157 $step = test_step_constructor_and_description($conf);
158 $ret = $step->runstep($conf);
159 ok( defined $ret, "runstep() returned defined value" );
160 ok($conf->data->get( 'has_extra_nci_thunks' ),
161 "Got expected value for has_extra_nci_thunks" );
162 ok($conf->data->get( 'HAS_EXTRA_NCI_THUNKS' ),
163 "Got expected value for HAS_EXTRA_NCI_THUNKS" );
165 $conf->replenish($serialized);
167 ##### without extra-nci-thunks #####
168 ($args, $step_list_ref) = process_options(
170 argv => [ q{--without-extra-nci-thunks} ],
171 mode => q{configure},
175 $conf->options->set( %{$args} );
176 $step = test_step_constructor_and_description($conf);
177 $ret = $step->runstep($conf);
178 ok( defined $ret, "runstep() returned defined value" );
179 ok(! $conf->data->get( 'has_extra_nci_thunks' ),
180 "Got expected value for has_extra_nci_thunks" );
181 ok(! $conf->data->get( 'HAS_EXTRA_NCI_THUNKS' ),
182 "Got expected value for HAS_EXTRA_NCI_THUNKS" );
184 pass("Completed all tests in $0");
186 ################### DOCUMENTATION ###################
190 init/defaults-01.t - test init::defaults
194 % prove t/steps/init/defaults-01.t
198 The files in this directory test functionality used by F<Configure.pl>.
200 The tests in this file test init::defaults.
208 config::init::defaults, F<Configure.pl>.
214 # cperl-indent-level: 4
217 # vim: expandtab shiftwidth=4: