On Tue Sep 04 05:20:44 2007, [EMAIL PROTECTED] wrote:

> 
> Thanks for your feedback.  Assuming no one else speaks up for it, I  
> will delete it in 1-2 days.
> 


This patch deletes the antiquated code -- but also does a bit more
refactoring to eliminate the last patches of code uncovered by test
suite and testable on one OS at a time.  (See
http://thenceforward.net/parrot/coverage/configure-build/config-inter-progs-pm.html)


Patch contains 2 new files:  t/configure/107-inter_progs.03.t and 04.t.
 Please review.  Thank you very much.

kid51

Index: MANIFEST
===================================================================
--- MANIFEST    (revision 21102)
+++ MANIFEST    (working copy)
@@ -1,7 +1,7 @@
 # ex: set ro:
 # $Id$
 #
-# generated by tools/dev/mk_manifest_and_skip.pl Wed Sep  5 18:15:42 2007 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Thu Sep  6 02:33:23 2007 UT
 #
 # See tools/dev/install_files.pl for documentation on the
 # format of this file.
@@ -2926,6 +2926,8 @@
 t/configure/106-init_headers.t                              []
 t/configure/107-inter_progs.01.t                            []
 t/configure/107-inter_progs.02.t                            []
+t/configure/107-inter_progs.03.t                            []
+t/configure/107-inter_progs.04.t                            []
 t/configure/testlib/Make_VERSION_File.pm                    []
 t/configure/testlib/Tie/Filehandle/Preempt/Stdin.pm         []
 t/configure/testlib/init/alpha.pm                           []
Index: t/configure/107-inter_progs.03.t
===================================================================
--- t/configure/107-inter_progs.03.t    (revision 0)
+++ t/configure/107-inter_progs.03.t    (revision 0)
@@ -0,0 +1,135 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+# 107-inter_progs.03.t
+
+use strict;
+use warnings;
+# Please leave as 'no_plan'; see 'BUG' in POD.
+use Test::More qw(no_plan); # tests => 23;
+use Carp;
+use lib qw( lib t/configure/testlib );
+use_ok('config::init::defaults');
+use_ok('config::init::install');
+use_ok('config::init::hints');
+use_ok('config::inter::progs');
+use Parrot::Configure;
+use Parrot::Configure::Options qw( process_options );
+use Parrot::Configure::Test qw( test_step_thru_runstep);
+use Tie::Filehandle::Preempt::Stdin;
+
+=for hints_for_testing Testing and refactoring of inter::progs should
+entail understanding of issues discussed in the following RT tickets:
+http://rt.perl.org/rt3/Ticket/Display.html?id=43174;
+http://rt.perl.org/rt3/Ticket/Display.html?id=43173; and
+http://rt.perl.org/rt3/Ticket/Display.html?id=41168.  You will have to
+determine a way to test a user response to a prompt.
+
+=cut
+
+my $args = process_options( {
+    argv            => [ q{--ask} ],
+    mode            => q{configure},
+} );
+
+my $conf = Parrot::Configure->new;
+
+test_step_thru_runstep($conf, q{init::defaults}, $args);
+test_step_thru_runstep($conf, q{init::install}, $args);
+test_step_thru_runstep($conf, q{init::hints}, $args);
+
+my ($task, $step_name, @step_params, $step, $ret);
+my $pkg = q{inter::progs};
+
+$conf->add_steps($pkg);
+$conf->options->set(%{$args});
+
+$task = $conf->steps->[3];
+$step_name   = $task->step;
[EMAIL PROTECTED] = @{ $task->params };
+
+$step = $step_name->new();
+ok(defined $step, "$step_name constructor returned defined value");
+isa_ok($step, $step_name);
+ok($step->description(), "$step_name has description");
+
+my (@prompts, $object);
+foreach my $p ( qw|
+        cc
+        link
+        ld
+        ccflags
+        linkflags
+        ldflags
+        libs
+        cxx
+    | ) {
+    push @prompts, $conf->data->get($p);
+}
+push @prompts, q{n};
+
+$object = tie *STDIN, 'Tie::Filehandle::Preempt::Stdin', @prompts;
+can_ok('Tie::Filehandle::Preempt::Stdin', ('READLINE'));
+isa_ok($object, 'Tie::Filehandle::Preempt::Stdin');
+
+{
+    open STDOUT, '>', "/dev/null" or croak "Unable to open to myout";
+    $ret = $step->runstep($conf);
+    close STDOUT or croak "Unable to close after myout";
+    ok(defined $ret, "$step_name runstep() returned defined value");
+}
+
+$object = undef;
+untie *STDIN;
+
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+107-inter_progs.03.t - test config::inter::progs
+
+=head1 SYNOPSIS
+
+    % prove t/configure/107-inter_progs.03.t
+
+=head1 DESCRIPTION
+
+The files in this directory test functionality used by F<Configure.pl>.
+
+The tests in this file test subroutines exported by config::inter::progs.
+
+=head1 BUG
+
+This file tests the case where the C<--ask> option is specified and,
+hence, the user must respond to a prompt.  The response to the prompt is
+supplied automatically via Tie::Filehandle::Preempt::Stdin.  But that
+response is made via C<STDOUT>.  A user generally would not like to see
+that output when running this test, say, via C<prove -v>.  So the data
+written to C<STDOUT> must be captured rather than displayed.
+
+In other test files we can do that with Parrot::IO::Capture::Mini.  We
+cannot do that here because there is extensive manipulation of C<STDOUT>
+deep inside the code being tested.  The solution employed in this test
+successfully disposes of information printed to C<STDOUT>, but it
+confuses Test::Harness's count of tests run.  This would cause the file
+as a whole to be reported as having failed, when in fact every single
+test passed.  As a compromise, we run the file with C<no_plan>.
+
+=head1 AUTHOR
+
+James E Keenan
+
+=head1 SEE ALSO
+
+config::inter::progs, F<Configure.pl>.
+
+=cut
+
+# Local Variables:
+#   mode: cperl
+#   cperl-indent-level: 4
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:

Property changes on: t/configure/107-inter_progs.03.t
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Index: t/configure/107-inter_progs.04.t
===================================================================
--- t/configure/107-inter_progs.04.t    (revision 0)
+++ t/configure/107-inter_progs.04.t    (revision 0)
@@ -0,0 +1,135 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+# 107-inter_progs.04.t
+
+use strict;
+use warnings;
+# Please leave as 'no_plan'; see 'BUG' in POD.
+use Test::More qw(no_plan); # tests => 23;
+use Carp;
+use lib qw( lib t/configure/testlib );
+use_ok('config::init::defaults');
+use_ok('config::init::install');
+use_ok('config::init::hints');
+use_ok('config::inter::progs');
+use Parrot::Configure;
+use Parrot::Configure::Options qw( process_options );
+use Parrot::Configure::Test qw( test_step_thru_runstep);
+use Tie::Filehandle::Preempt::Stdin;
+
+=for hints_for_testing Testing and refactoring of inter::progs should
+entail understanding of issues discussed in the following RT tickets:
+http://rt.perl.org/rt3/Ticket/Display.html?id=43174;
+http://rt.perl.org/rt3/Ticket/Display.html?id=43173; and
+http://rt.perl.org/rt3/Ticket/Display.html?id=41168.  You will have to
+determine a way to test a user response to a prompt.
+
+=cut
+
+my $args = process_options( {
+    argv            => [ q{--ask} ],
+    mode            => q{configure},
+} );
+
+my $conf = Parrot::Configure->new;
+
+test_step_thru_runstep($conf, q{init::defaults}, $args);
+test_step_thru_runstep($conf, q{init::install}, $args);
+test_step_thru_runstep($conf, q{init::hints}, $args);
+
+my ($task, $step_name, @step_params, $step, $ret);
+my $pkg = q{inter::progs};
+
+$conf->add_steps($pkg);
+$conf->options->set(%{$args});
+
+$task = $conf->steps->[3];
+$step_name   = $task->step;
[EMAIL PROTECTED] = @{ $task->params };
+
+$step = $step_name->new();
+ok(defined $step, "$step_name constructor returned defined value");
+isa_ok($step, $step_name);
+ok($step->description(), "$step_name has description");
+
+my (@prompts, $object);
+foreach my $p ( qw|
+        cc
+        link
+        ld
+        ccflags
+        linkflags
+        ldflags
+        libs
+        cxx
+    | ) {
+    push @prompts, $conf->data->get($p);
+}
+push @prompts, q{0};
+
+$object = tie *STDIN, 'Tie::Filehandle::Preempt::Stdin', @prompts;
+can_ok('Tie::Filehandle::Preempt::Stdin', ('READLINE'));
+isa_ok($object, 'Tie::Filehandle::Preempt::Stdin');
+
+{
+    open STDOUT, '>', "/dev/null" or croak "Unable to open to myout";
+    $ret = $step->runstep($conf);
+    close STDOUT or croak "Unable to close after myout";
+    ok(! defined $ret, "$step_name runstep() returned defined value");
+}
+
+$object = undef;
+untie *STDIN;
+
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+107-inter_progs.04.t - test config::inter::progs
+
+=head1 SYNOPSIS
+
+    % prove t/configure/107-inter_progs.04.t
+
+=head1 DESCRIPTION
+
+The files in this directory test functionality used by F<Configure.pl>.
+
+The tests in this file test subroutines exported by config::inter::progs.
+
+=head1 BUG
+
+This file tests the case where the C<--ask> option is specified and,
+hence, the user must respond to a prompt.  The response to the prompt is
+supplied automatically via Tie::Filehandle::Preempt::Stdin.  But that
+response is made via C<STDOUT>.  A user generally would not like to see
+that output when running this test, say, via C<prove -v>.  So the data
+written to C<STDOUT> must be captured rather than displayed.
+
+In other test files we can do that with Parrot::IO::Capture::Mini.  We
+cannot do that here because there is extensive manipulation of C<STDOUT>
+deep inside the code being tested.  The solution employed in this test
+successfully disposes of information printed to C<STDOUT>, but it
+confuses Test::Harness's count of tests run.  This would cause the file
+as a whole to be reported as having failed, when in fact every single
+test passed.  As a compromise, we run the file with C<no_plan>.
+
+=head1 AUTHOR
+
+James E Keenan
+
+=head1 SEE ALSO
+
+config::inter::progs, F<Configure.pl>.
+
+=cut
+
+# Local Variables:
+#   mode: cperl
+#   cperl-indent-level: 4
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:

Property changes on: t/configure/107-inter_progs.04.t
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Index: config/inter/progs.pm
===================================================================
--- config/inter/progs.pm       (revision 21102)
+++ config/inter/progs.pm       (working copy)
@@ -33,19 +33,6 @@
 
     my ( $cc, $cxx, $link, $ld, $ccflags, $ccwarn, $linkflags, $ldflags, 
$libs, $lex, $yacc );
 
-    # Find a working version of a program:
-    # Try each alternative, until one works.
-    # If none work, then set to null command.
-    # RT#43173 need config support for a null command.
-    my $null          = 'echo';
-    my $first_working = sub {
-        foreach (@_) {
-            `$_ -h 2>&1`;
-            return $_ if not $?;
-        }
-        return $null;
-    };
-
     my $ask = $conf->options->get('ask');
     if ($ask) {
         print <<'END';
@@ -115,8 +102,11 @@
     $debug = 'y' if $conf->options->get('debugging');
     $debug = prompt( "Do you want a debugging build of Parrot?", $debug )
         if $ask;
+    unless ($debug =~ /^[yn]$/i) {
+        return;
+    }
 
-    if ( !$debug || $debug =~ /n/i ) {
+    if ( $debug =~ /n/i ) {
         $conf->data->set(
             cc_debug   => '',
             link_debug => '',

Reply via email to