You are viewing a plain text version of this content. The canonical link for it is here.
Posted to test-cvs@httpd.apache.org by do...@apache.org on 2002/05/15 01:44:22 UTC

cvs commit: httpd-test/perl-framework/Apache-Test/lib/Apache TestConfig.pm TestReport.pm TestRun.pm TestSmoke.pm

dougm       02/05/14 16:44:22

  Modified:    perl-framework/Apache-Test/lib/Apache TestConfig.pm
                        TestReport.pm TestRun.pm TestSmoke.pm
  Log:
  fold more duplication in script generators using new perlscript_header method
  
  Revision  Changes    Path
  1.133     +13 -0     httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfig.pm
  
  Index: TestConfig.pm
  ===================================================================
  RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfig.pm,v
  retrieving revision 1.132
  retrieving revision 1.133
  diff -u -r1.132 -r1.133
  --- TestConfig.pm	14 May 2002 23:42:07 -0000	1.132
  +++ TestConfig.pm	14 May 2002 23:44:22 -0000	1.133
  @@ -726,6 +726,19 @@
       close $fh;
   }
   
  +sub perlscript_header {
  +    return <<'EOF';
  +
  +use strict;
  +use warnings FATAL => 'all';
  +
  +use FindBin;
  +use lib map "$FindBin::Bin/$_",
  +        qw(../Apache-Test/lib ../lib ../../lib);
  +
  +EOF
  +}
  +
   # gen + write executable perl script file
   sub write_perlscript {
       my($self, $file, $content) = @_;
  
  
  
  1.4       +11 -5     httpd-test/perl-framework/Apache-Test/lib/Apache/TestReport.pm
  
  Index: TestReport.pm
  ===================================================================
  RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestReport.pm,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestReport.pm	14 May 2002 23:01:14 -0000	1.3
  +++ TestReport.pm	14 May 2002 23:44:22 -0000	1.4
  @@ -17,7 +17,16 @@
   
       local $/;
       my $content = <DATA>;
  -    $content =~ s/__CLASS__/$class/g;
  +
  +    my %replace = (
  +        class  => $class,
  +        header => Apache::TestConfig->perlscript_header,
  +    );
  +
  +    while (my($key, $val) = each %replace) {
  +        $content =~ s/__\U${key}__/$replace{$key}/g;
  +    }
  +
       Apache::Test::config()->write_perlscript($file, $content);
   
   }
  @@ -27,10 +36,7 @@
   1;
   __DATA__
   
  -use strict;
  -use FindBin qw($Bin);
  -use lib "$Bin/../Apache-Test/lib";
  -use lib 'lib';
  +__HEADER__
   
   use __CLASS__ ();
   
  
  
  
  1.91      +3 -12     httpd-test/perl-framework/Apache-Test/lib/Apache/TestRun.pm
  
  Index: TestRun.pm
  ===================================================================
  RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestRun.pm,v
  retrieving revision 1.90
  retrieving revision 1.91
  diff -u -r1.90 -r1.91
  --- TestRun.pm	14 May 2002 22:48:34 -0000	1.90
  +++ TestRun.pm	14 May 2002 23:44:22 -0000	1.91
  @@ -778,21 +778,12 @@
           $content = "\%Apache::TestConfig::Argv = qw(@Apache::TestMM::Argv);\n";
       }
   
  -    $content .= <<EOM;
  -use strict;
  -use warnings FATAL => 'all';
  +    my $header = Apache::TestConfig->perlscript_header;
   
  -use FindBin;
  -use lib "\$FindBin::Bin/../Apache-Test/lib";
  -use lib 'lib';
  -
  -use $class ();
  -
  -$class->new->run(\@ARGV);
  -EOM
  +    $content .= join "\n",
  +      $header, "use $class ();", "$class->new->run(\@ARGV);";
   
       Apache::Test::config()->write_perlscript($file, $content);
  -
   }
   
   # in idiomatic perl functions return 1 on success 0 on
  
  
  
  1.16      +3 -15     httpd-test/perl-framework/Apache-Test/lib/Apache/TestSmoke.pm
  
  Index: TestSmoke.pm
  ===================================================================
  RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestSmoke.pm,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- TestSmoke.pm	14 May 2002 23:03:11 -0000	1.15
  +++ TestSmoke.pm	14 May 2002 23:44:22 -0000	1.16
  @@ -460,25 +460,13 @@
   
       $file ||= catfile 't', 'SMOKE';
   
  -    my $content = <<EOM;
  -use strict;
  -use warnings FATAL => 'all';
  +    my $header = Apache::TestConfig->perlscript_header;
   
  -use FindBin;
  -use lib "\$FindBin::Bin/../Apache-Test/lib";
  -use lib "\$FindBin::Bin/../lib";
  -use lib 'lib';
  -
  -use $class ();
  -
  -$class->new(\@ARGV)->run;
  -EOM
  +    my $content = join "\n",
  +      $header, "use $class ();", "$class->new(\@ARGV)->run;";
   
       Apache::Test::config()->write_perlscript($file, $content);
  -
   }
  -
  -
   
   1;
   __END__