2 # Copyright (C) 2007, Parrot Foundation.
8 use Test::More tests => 18;
10 use lib qw( lib t/configure/testlib );
11 use_ok('config::auto::warnings');
12 use Parrot::Configure::Options qw( process_options );
13 use Parrot::Configure::Step::Test;
14 use Parrot::Configure::Test qw(
15 test_step_constructor_and_description
17 use IO::CaptureOutput qw | capture |;
19 my ($args, $step_list_ref) = process_options(
26 my $conf = Parrot::Configure::Step::Test->new;
27 $conf->include_config_results( $args );
29 my $pkg = q{auto::warnings};
31 $conf->add_steps($pkg);
33 my $serialized = $conf->pcfreeze();
37 skip 'Tests not yet passing on Sun/Solaris',
39 if $^O =~ m/sun|solaris/i;
41 # Simulate the case where C compiler is not gcc.
42 $conf->options->set( %{$args} );
43 $step = test_step_constructor_and_description($conf);
44 $conf->data->set( gccversion => undef );
45 ok($step->runstep($conf), "runstep() returned true value");
46 is($step->result(), q{skipped}, "Got expected result");
48 $step->set_result( undef );
49 $conf->replenish($serialized);
51 # Simulate the case where C compiler is not gcc: verbose
52 $conf->options->set( verbose => 1 );
53 $step = test_step_constructor_and_description($conf);
54 $conf->data->set( gccversion => undef );
56 my ($stdout, $stderr, $rv);
58 sub { $rv = $step->runstep($conf); },
62 ok($rv, "runstep() returned true value");
63 is($step->result(), q{skipped}, "Got expected result");
64 like($stdout, qr/We do not \(yet\) probe for warnings for your compiler/s,
65 "Got expected verbose output: compiler with warnings not yet supported" );
68 $step->set_result( undef );
69 $conf->replenish($serialized);
71 # Simulate case where --cage warnings are requested
72 $conf->options->set( verbose => undef );
73 $step = test_step_constructor_and_description($conf);
74 $conf->data->set( gccversion => 'defined' );
75 $conf->data->set( 'g++' => undef );
76 $conf->options->set( cage => 1 );
77 ok($step->runstep($conf), "runstep() returned true value");
79 # This test is fragile, as it depends on the current state of --cage,
80 # which changes over time, and on the compiler, which may not support
82 like($conf->data->get( 'ccwarn' ),
83 qr/-Wunreachable-code/,
84 "'cage' warning set as expected"
87 } # End SKIP block for Sun/Solaris
91 pass("Completed all tests in $0");
93 ################### DOCUMENTATION ###################
97 auto/warnings-01.t - test auto::warnings
101 % prove t/steps/auto/warnings-01.t
105 The files in this directory test functionality used by F<Configure.pl>.
107 The tests in this file test aspects of auto::warnings.
115 config::auto::warnings, F<Configure.pl>.
121 # cperl-indent-level: 4
124 # vim: expandtab shiftwidth=4: