On Mon, 17 Sep 2001, Doug MacEachern wrote:
> On Mon, 17 Sep 2001, Stas Bekman wrote:
>
> > > - use better API naming s/warn/warn_type/. it's not clear what 'warn' is.
> >
> > I still don't like the use of raw numbers 1, 2 for
> > Apache::TestConfig::genwarning. We try to make the code self-documenting,
> > so let's do that.
> >
> > May I add:
> >
> > use constant WARN_STYLE_NONE => 0;
> > use constant WARN_STYLE_PERL => 1;
> > use constant WARN_STYLE_C => 2;
>
> that would be fine.
here goes:
Index: Apache-Test/lib/Apache/TestConfig.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfig.pm,v
retrieving revision 1.62
diff -u -r1.62 TestConfig.pm
--- Apache-Test/lib/Apache/TestConfig.pm 2001/09/18 01:59:19 1.62
+++ Apache-Test/lib/Apache/TestConfig.pm 2001/09/18 02:22:31
@@ -8,6 +8,10 @@
use constant NETWARE => $^O eq 'NetWare';
use constant WINFU => WIN32 || CYGWIN || NETWARE;
+use constant WARN_STYLE_NONE => 0;
+use constant WARN_STYLE_PERL => 1;
+use constant WARN_STYLE_C => 2;
+
use File::Copy ();
use File::Find qw(finddepth);
use File::Basename qw(dirname);
@@ -513,13 +517,15 @@
#generate files and directories
+# warning types:
+# WARN_STYLE_NONE => no warning returned
+# WARN_STYLE_PERL => # warning
+# WARN_STYLE_C => /* warning */
sub genwarning {
my($self, $type) = @_;
return unless $type;
my $warning = "#WARNING: this file is generated, do not edit\n" .
calls_trace();
- #1 => # warning
- #2 => /* warning */
return $type > 1 ? "/*\n$warning*/\n" : $warning;
}
@@ -729,7 +735,7 @@
unless ($self->{inherit_config}->{TypesConfig}) {
my $types = catfile $self->{vars}->{t_conf}, 'mime.types';
unless (-e $types) {
- my $fh = $self->genfile($types, 1);
+ my $fh = $self->genfile($types, WARN_STYLE_PERL);
print $fh $self->types_config_template;
close $fh;
}
@@ -768,7 +774,7 @@
open(my $in, $file) or next;
- my $out = $self->genfile($generated, 1);
+ my $out = $self->genfile($generated, WARN_STYLE_PERL);
$self->replace_vars($in, $out);
close $in;
@@ -832,7 +838,7 @@
my $in = $self->httpd_conf_template($conf_file_in);
- my $out = $self->genfile($conf_file, 1);
+ my $out = $self->genfile($conf_file, WARN_STYLE_PERL);
$self->preamble_run($out);
@@ -1000,7 +1006,7 @@
my $name = 'apache_test_config';
my $file = catfile $self->{vars}->{t_conf}, "$name.pm";
- my $fh = $self->genfile($file, 1);
+ my $fh = $self->genfile($file, WARN_STYLE_PERL);
$self->trace("saving config data to $name.pm");
@@ -1053,12 +1059,16 @@
useful for navigating through autogenerated files.
The returned warnings are enclosed into a suitable for Perl or C
-comment style, if the C<$warn_type> variable:
-
- 1 => # Perl warning
- 2 => /* # C warning */
+comment style. The following constants accessible from other packages
+define the following values for the C<$warn_type> variable:
-If C<$warn_type> is FALSE, no warning string will be returned.
+ WARN_STYLE_NONE => no warning returned
+ WARN_STYLE_PERL => # Perl warning
+ WARN_STYLE_C => /* C warning */
+
+If C<$warn_type> is FALSE, no warning string will be returned. To
+access the constant from a different package, use the fully qualified
+style, e.g. C<Apache::TestConfig::WARN_STYLE_PERL>.
=item genfile()
Index: Apache-Test/lib/Apache/TestConfigC.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfigC.pm,v
retrieving revision 1.13
diff -u -r1.13 TestConfigC.pm
--- Apache-Test/lib/Apache/TestConfigC.pm 2001/09/09 18:27:39 1.13
+++ Apache-Test/lib/Apache/TestConfigC.pm 2001/09/18 02:22:31
@@ -300,7 +300,7 @@
my $self = shift;
my $file = "$self->{cmodules_dir}/apache_httpd_test.h";
- my $fh = $self->genfile($file, 2);
+ my $fh = $self->genfile($file, WARN_STYLE_C);
while (read Apache::TestConfigC::DATA, my $buf, 1024) {
print $fh $buf;
Index: Apache-Test/lib/Apache/TestConfigPerl.pm
===================================================================
RCS file:
/home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfigPerl.pm,v
retrieving revision 1.25
diff -u -r1.25 TestConfigPerl.pm
--- Apache-Test/lib/Apache/TestConfigPerl.pm 2001/09/15 19:29:30 1.25
+++ Apache-Test/lib/Apache/TestConfigPerl.pm 2001/09/18 02:22:31
@@ -64,7 +64,7 @@
return if -e $t;
$self->gendir($dir);
- my $fh = $self->genfile($t, 1);
+ my $fh = $self->genfile($t, WARN_STYLE_PERL);
print $fh <<EOF;
use Apache::TestConfig ();
@@ -98,7 +98,7 @@
#but this will work for both 2.0 and 1.xx
if (my $inc = $self->{inc}) {
my $include_pl = catfile $self->{vars}->{t_conf}, 'modperl_inc.pl';
- my $fh = $self->genfile($include_pl, 1);
+ my $fh = $self->genfile($include_pl, WARN_STYLE_PERL);
for (@$inc) {
print $fh "use lib '$_';\n";
}
@@ -112,7 +112,7 @@
my $startup_pl = catfile $self->{vars}->{t_conf}, 'modperl_startup.pl';
unless (-e $startup_pl) {
- my $fh = $self->genfile($startup_pl, 1);
+ my $fh = $self->genfile($startup_pl, WARN_STYLE_PERL);
print $fh $self->startup_pl_code;
close $fh;
}
Index: Apache-Test/lib/Apache/TestServer.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestServer.pm,v
retrieving revision 1.30
diff -u -r1.30 TestServer.pm
--- Apache-Test/lib/Apache/TestServer.pm 2001/09/08 17:40:43 1.30
+++ Apache-Test/lib/Apache/TestServer.pm 2001/09/18 02:22:31
@@ -122,7 +122,8 @@
my $strace_cmd = $self->strace_cmd($opts->{debugger}, $file);
my $httpd = $config->{vars}->{httpd};
- $config->genfile($file, 1); #just mark for cleanup
+ # just mark for cleanup
+ $config->genfile($file, Apache::TestConfig::WARN_STYLE_PERL);
my $command = "$strace_cmd $httpd $one_process $args";
@@ -141,7 +142,7 @@
my $one_process = $self->version_of(\%one_process);
my $file = catfile $config->{vars}->{serverroot}, '.gdb-test-start';
- my $fh = $config->genfile($file, 1);
+ my $fh = $config->genfile($file, Apache::TestConfig::WARN_STYLE_PERL);
print $fh default_gdbinit();
Index: t/response/TestDirective/perlrequire.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/t/response/TestDirective/perlrequire.pm,v
retrieving revision 1.1
diff -u -r1.1 perlrequire.pm
--- t/response/TestDirective/perlrequire.pm 2001/09/18 02:00:19 1.1
+++ t/response/TestDirective/perlrequire.pm 2001/09/18 02:22:31
@@ -37,7 +37,7 @@
1;
EOF
my $file = catfile $target_dir, $test, 'PerlRequireTest.pm';
- $self->writefile($file, $content, 1);
+ $self->writefile($file, $content, Apache::TestConfig::WARN_STYLE_PERL);
}
}
_____________________________________________________________________
Stas Bekman JAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide http://perl.apache.org/guide
mailto:[EMAIL PROTECTED] http://apachetoday.com http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]