Author: jkeenan
Date: Thu Aug 7 18:10:02 2008
New Revision: 30114
Added:
branches/scriptconfigure/t/configure/testlib/hisfoobar (contents, props
changed)
Modified:
branches/scriptconfigure/t/configure/062-options_conf_file.t
Log:
Add test for malformatted configuration file.
Modified: branches/scriptconfigure/t/configure/062-options_conf_file.t
==============================================================================
--- branches/scriptconfigure/t/configure/062-options_conf_file.t
(original)
+++ branches/scriptconfigure/t/configure/062-options_conf_file.t Thu Aug
7 18:10:02 2008
@@ -5,12 +5,9 @@
use strict;
use warnings;
-use Test::More qw(no_plan); # tests => 8;
-#use Carp;
-#use Cwd;
-#use Data::Dumper;
-#use File::Temp qw( tempdir );
+use Test::More tests => 9;
use lib qw( lib );
+use Parrot::Configure::Options ();
use Parrot::Configure::Options::Conf::File qw(
@valid_options
$script
@@ -21,7 +18,6 @@
use Parrot::Configure::Options::Conf::Shared qw(
@shared_valid_options
);
-#use IO::CaptureOutput qw| capture |;
my ($variables, $general, $substitutions);
my $data = {};;
@@ -136,9 +132,43 @@
$data, $substitutions, $general, \%valid_step_options
); };
like($@, qr/Bad variable substitution in $data->{file}/,
- "Got expected message when _set_general() died");
+ "Got expected message when _set_general() died: bad substitution");
$data = {};
+##### Test of bad entry in 'general' section
+
+$variables = <<END;
+CC=/usr/bin/gcc
+#CX=/usr/bin/g++
+
+ABC=abc
+END
+
+$substitutions =
+ Parrot::Configure::Options::Conf::File::_get_substitutions($variables);
+$general = <<END;
+cc=\$CC
+this=will not=work
+#abc=abc
+
+verbose
+verbose-step=init::hints
+configure_trace
+dizzy
+END
+
+$data->{debugging} = 1;
+$data->{maintainer} = undef;
+$data->{file} = q{Configure.pl};
+%valid_step_options = map {$_ => 1} @shared_valid_options;
+eval {
+ $data = Parrot::Configure::Options::Conf::File::_set_general(
+ $data, $substitutions, $general, \%valid_step_options
+ );
+};
+like($@, qr/Invalid general option dizzy in $data->{file}/,
+ "Got expected message when _set_general() died: bad 'general' entry");
+
##### Test of bad option
$variables = <<END;
@@ -160,10 +190,6 @@
configure_trace
END
-is_deeply($substitutions,
- { CC => '/usr/bin/gcc', ABC => 'abc' },
- "Got expected substitutions"
-);
$data->{debugging} = 1;
$data->{maintainer} = undef;
$data->{file} = q{Configure.pl};
@@ -187,7 +213,32 @@
Parrot::Configure::Options::Conf::File::_set_steps(
$data, $steps, \%valid_step_options);
};
-like($@, qr/dizzy/, "Invalid option correctly detected");
+like($@, qr/dizzy/, "Invalid option correctly detected during _set_steps()");
+
+########## Overall test of conditional_assignments() ##########
+
+{
+ my $args = {
+ mode => 'file',
+ argv => [ q{--file=t/configure/testlib/hisfoobar} ],
+ };
+ my ($options_components, $script);
+ ($args, $options_components, $script) =
+ Parrot::Configure::Options::_process_options_components($args);
+
+ my ($data, $short_circuits_seen_ref) =
+ Parrot::Configure::Options::_initial_pass(
+ $args, $options_components, $script
+ );
+
+ my $steps_list_ref;
+ eval {
+ ($data, $steps_list_ref) =
+ &{ $options_components->{conditionals} }($data);
+ };
+ like($@, qr/Configuration file $data->{file} did not parse correctly/,
+ "Got expected die message for options_components()");
+}
pass("Completed all tests in $0");
Added: branches/scriptconfigure/t/configure/testlib/hisfoobar
==============================================================================
--- (empty file)
+++ branches/scriptconfigure/t/configure/testlib/hisfoobar Thu Aug 7
18:10:02 2008
@@ -0,0 +1,85 @@
+# Copyright (C) 2001-2008, The Perl Foundation.
+# $Id$
+
+==variables
+
+CC=/usr/bin/gcc
+CX=/usr/bin/g++
+
+==general
+
+cc=$CC
+cxx=$CX
+link=$CX
+ld=/usr/bin/g++
+
+==steps
+
+init::manifest nomanicheck
+init::defaults
+init::install
+init::miniparrot
+init::hints verbose-step
+init::headers
+inter::progs
+inter::make
+inter::lex
+inter::yacc
+auto::gcc
+auto::glibc
+auto::backtrace
+auto::fink
+auto::macports
+auto::msvc
+auto::attributes
+auto::warnings
+init::optimize
+inter::shlibs
+inter::libparrot
+inter::charset
+inter::encoding
+inter::types
+auto::ops
+auto::pmc
+auto::alignptrs
+auto::headers
+auto::sizes
+auto::byteorder
+auto::va_ptr
+auto::format
+auto::isreg
+auto::arch
+auto::jit
+auto::cpu
+auto::funcptr
+auto::cgoto
+auto::inline
+auto::gc
+auto::memalign
+auto::signal
+auto::socklen_t
+auto::env
+auto::aio
+auto::gmp
+auto::readline
+auto::gdbm
+auto::pcre
+auto::opengl
+auto::crypto
+auto::gettext
+auto::snprintf
+# auto::perldoc
+auto::ctags
+auto::revision
+auto::icu
+gen::config_h
+gen::core_pmcs
+gen::crypto
+gen::parrot_include
+gen::opengl
+gen::call_list
+gen::languages
+gen::makefiles
+gen::platform
+gen::config_pm
+