Author: jkeenan
Date: Sun May 6 08:48:34 2007
New Revision: 18436
Added:
branches/reconfigure/t/configure/25-options_test.t
Log:
Adding test for Parrot::Configure::Options::Test methods.
Added: branches/reconfigure/t/configure/25-options_test.t
==============================================================================
--- (empty file)
+++ branches/reconfigure/t/configure/25-options_test.t Sun May 6 08:48:34 2007
@@ -0,0 +1,118 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id: 25-options_test.t 18310 2007-04-24 01:27:22Z jkeenan $
+# 25-options_test.t
+
+use strict;
+use warnings;
+use Carp;
+use Cwd;
+use Data::Dumper;
+use File::Temp qw( tempdir );
+use Test::More tests => 10;
+use lib qw( . lib ../lib ../../lib );
+use_ok('Parrot::IO::Capture::Mini');
+use_ok(
+ 'Parrot::Configure::Options', qw|
+ process_options
+ |
+);
+use_ok("Parrot::Configure::Options::Test");
+
+my ($args, $opttest);
+
+my $parrot_version = '0.4.10';
+my $svnid = '$Id: 25-options_test.t 18310 2007-04-24 01:27:22Z
jkeenan $';
+$args = process_options(
+ {
+ argv => [ q{--test} ],
+ script => $0,
+ parrot_version => $parrot_version,
+ svnid => $svnid,
+ }
+);
+ok( defined $args, "process_options() returned successfully when options were
specified" );
+
+$opttest = Parrot::Configure::Options::Test->new($args);
+ok(defined $opttest, "Constructor returned successfully");
+
+# Running the actual pre- and post-configuration tests would be too
+# time-consuming. So instead, we want to redefine the lists of tests to be
+# run to include only dummy test files found in temporary directories.
+
+my $cwd = cwd();
+
+my $teststring = <<"TEST";
+use Test::More tests => 1;
+{
+ pass("Dummy test passed");
+}
+TEST
+
+{
+ my $tdir = tempdir;
+ ok( (chdir $tdir), "Changed to temporary directory for testing");
+ my $test = q{testfile};
+ open my $T, ">", $test
+ or die "Unable to open dummy test file for writing";
+ print $T $teststring;
+ close $T or die "Unable to close dummy test file after writing";
+
+ my ($tie, $errtie, @lines);
+ no warnings 'once';
+
+ @Parrot::Configure::Options::Test::preconfiguration_tests =
+ ( $test );
+ {
+ $tie = tie *STDOUT, "Parrot::IO::Capture::Mini"
+ or croak "Unable to tie";
+ ok($opttest->run_configure_tests(),
+ "Configuration tests are runnable");
+ }
+
+ @Parrot::Configure::Options::Test::postconfiguration_tests =
+ ( $test );
+ {
+ $tie = tie *STDOUT, "Parrot::IO::Capture::Mini"
+ or croak "Unable to tie";
+ ok($opttest->run_build_tests(),
+ "Build tests are runnable");
+ }
+
+ ok( (chdir $cwd), "Changed back to starting directory after testing");
+}
+
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+25-options_test.t - test Parrot::Configure::Options::Test
+
+=head1 SYNOPSIS
+
+ % prove t/configure/25-options_test.t
+
+=head1 DESCRIPTION
+
+The files in this directory test functionality used by F<Configure.pl>.
+
+The tests in this file test Parrot::Configure::Options::Test methods.
+
+=head1 AUTHOR
+
+James E Keenan
+
+=head1 SEE ALSO
+
+Parrot::Configure::Options, F<Configure.pl>.
+
+=cut
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4: