2 # Copyright (C) 2007-2008, Parrot Foundation.
8 use Test::More tests => 20;
11 use_ok('config::gen::opengl');
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 ########## regular ##########
21 my ($args, $step_list_ref) = process_options(
28 my $conf = Parrot::Configure::Step::Test->new;
29 $conf->include_config_results( $args );
31 my $real_opengl_status = $conf->data->get('has_opengl');
33 my ($pkg, $step, $result);
34 my $serialized = $conf->pcfreeze();
36 $pkg = q{gen::opengl};
37 $conf->add_steps($pkg);
38 $conf->options->set( %{$args} );
39 $step = test_step_constructor_and_description($conf);
41 ##### mock no OpenGL #####
42 $conf->data->set( has_opengl => 0 );
43 $result = $step->runstep($conf);
44 ok($result, "runstep() returned true value");
45 is($step->result(), q{skipped}, "Got expected result when no 'has_opengl'" );
48 skip 'opengl not detected',
49 13 unless $real_opengl_status;
51 # The complex nature of gen::opengl::runstep() makes it difficult to write
52 # tests that will DTRT when OpenGL is not really present on this machine.
53 # In particular, tests for verbose output will fail when
54 # $real_opengl_status is false. So we'll SKIP.
56 $conf->replenish($serialized);
58 ########### verbose ###########
60 ($args, $step_list_ref) = process_options( {
61 argv => [ q{--verbose} ],
65 $conf->add_steps($pkg);
66 $conf->options->set( %{$args} );
67 $step = test_step_constructor_and_description($conf);
69 my ($stdout, $stderr);
71 sub { $result = $step->runstep($conf); },
75 ok($result, "runstep() returned true value");
77 qr/Checking for OpenGL headers using the following globs/s,
78 "Got expected verbose output"
81 qr/Found the following OpenGL headers/s,
82 "Got expected verbose output"
85 qr/PASS\s+FAIL\s+IGNORE\s+HEADER/s,
86 "Got expected verbose output"
89 qr/unique signatures successfully translated/s,
90 "Got expected verbose output"
94 $conf->replenish($serialized);
96 ########### extra verbose ###########
98 ($args, $step_list_ref) = process_options( {
99 argv => [ q{--verbose=3} ],
100 mode => q{configure},
103 $conf->add_steps($pkg);
104 $conf->options->set( %{$args} );
105 $step = test_step_constructor_and_description($conf);
107 my ($stdout, $stderr);
109 sub { $result = $step->runstep($conf); },
113 ok($result, "runstep() returned true value");
115 qr/COUNT\s+NCI SIGNATURE/s,
116 "Got expected verbose output"
121 pass("Completed all tests in $0");
123 ################### DOCUMENTATION ###################
127 gen/opengl-01.t - test gen::opengl
131 % prove t/steps/gen/opengl-01.t
135 The files in this directory test functionality used by F<Configure.pl>.
137 The tests in this file test gen::opengl.
141 Geoffrey Broadwell; modified from a similar file by James E Keenan.
145 config::gen::opengl, F<Configure.pl>.
151 # cperl-indent-level: 4
154 # vim: expandtab shiftwidth=4: