[PATCH lib/Net/Config.pm, MANIFEST, t/lib/Mock/Socket.pm, lib/Net/Config.t] Add Tests for Net::Config

Here's a test suite for Net::Config.  In the process of writing this, I've
fixed an apparent bug that prevented single values from becoming array
references when necessary.  I think it's right, but perhaps Graham should weigh
in on this.

In the process, with some advice from perl-qa, I've added a mock object so the
test could control the output of Socket::inet_ntoa() and Socket::inet_aton().
t/lib/Mock/ seemed like as good a place as any.

I'm happy to rework this patch if it personally offends anyone whose opinion
matters.  :)

-- c

--- lib/Net/~Config.pm	Sat Oct 20 01:23:46 2001
+++ lib/Net/Config.pm	Sat Oct 20 01:23:54 2001
@@ -13,7 +13,7 @@
 
 @EXPORT  = qw(%NetConfig);
 @ISA     = qw(Net::LocalCfg Exporter);
-$VERSION = "1.05"; # $Id: //depot/libnet/Net/Config.pm#9 $
+$VERSION = "1.06"; # $Id: //depot/libnet/Net/Config.pm#9 $
 
 eval { local $SIG{__DIE__}; require Net::LocalCfg };
 
@@ -54,11 +54,11 @@
 }
 my ($k,$v);
 while(($k,$v) = each %NetConfig) {
-    $v = [ $v ]
-	if($k =~ /_hosts$/ && !ref($v));
+	$NetConfig{$k} = [ $v ]
+		if($k =~ /_hosts$/ && !ref($v));
 }
 
-# Take a hostname and determine if it is inside te firewall
+# Take a hostname and determine if it is inside the firewall
 
 sub requires_firewall {
     shift; # ignore package
--- ~MANIFEST	Sat Oct 20 01:24:04 2001
+++ MANIFEST	Sat Oct 20 01:24:42 2001
@@ -1065,6 +1065,7 @@
 lib/Net/Cmd.pm			libnet
 lib/Net/Config.eg		libnet
 lib/Net/Config.pm		libnet
+lib/Net/Config.pm		libnet (see if Net::Config works)
 lib/Net/demos/ftp		libnet
 lib/Net/demos/inetd		libnet
 lib/Net/demos/nntp		libnet
--- /dev/null	Thu Aug 30 03:54:37 2001
+++ t/lib/Mock/Socket.pm	Sat Oct 20 00:02:49 2001
@@ -0,0 +1,31 @@
+package Mock::Socket;
+
+# this is not the package you're looking for
+
+package Socket;
+
+$INC{'Socket.pm'} = 1;
+
+use Exporter;
+@Socket::ISA = ( 'Exporter' );
+@EXPORT = qw( &inet_aton &inet_ntoa );
+
+my (%aton, %ntoa);
+
+sub set_dns {
+	while (my ($name, $number) = splice(@_, 0, 2)) {
+		my $packed = unpack( "N", pack("C*", split(/\./, $number)));
+		$aton{$name} = $packed;
+		$ntoa{$packed} = $number;
+	}
+}
+
+sub inet_aton {
+	return $aton{$_[0]};
+}
+
+sub inet_ntoa {
+	return $ntoa{$_[0]};
+}
+
+1;
--- /dev/null	Thu Aug 30 03:54:37 2001
+++ lib/Net/Config.t	Sat Oct 20 01:18:50 2001
@@ -0,0 +1,85 @@
+#!./perl
+
+BEGIN {
+	chdir 't' if -d 't';
+	@INC = ( 'lib', '../lib' );
+}
+
+# lots of magic, see t/lib/Mock/Socket
+use Mock::Socket;
+use Test::More tests => 14;
+
+use_ok( 'Net::Config' );
+ok( keys %NetConfig, '%NetConfig should be imported' );
+
+undef $NetConfig{'ftp_firewall'};
+is( Net::Config->requires_firewall, 0, 
+	'requires_firewall() should return 0 without ftp_firewall defined' );
+
+# this calls inet_aton in the mock Socket, so it *may* not be portable
+$NetConfig{'ftp_firewall'} = 1;
+is( Net::Config->requires_firewall, -1,
+	'... should return -1 without a valid hostname' );
+
+# use the mock Socket to resolve addresses our way
+Socket::set_dns( localhost => '127.0.0.1', remotehost => '192.168.10.0' );
+delete $NetConfig{'local_netmask'};
+is( Net::Config->requires_firewall('localhost'), 0,
+	'... should return 0 without local_netmask defined' );
+
+# 
+$NetConfig{'local_netmask'} = '127.0.0.1/24';
+is( Net::Config->requires_firewall('localhost'), 0,
+	'... should return false if host is within netmask' );
+is( Net::Config->requires_firewall('remotehost'), 1,
+	'... should return true if host is outside netmask' );
+
+# now try more netmasks
+Socket::set_dns( otherlocal => '10.10.255.254' );
+$NetConfig{'local_netmask'} = [ '127.0.0.1/24', '10.0.0.0/8' ];
+is( Net::Config->requires_firewall('otherlocal'), 0,
+	'... should find success with mutiple local netmasks' );
+is( Net::Config->requires_firewall('remotehost'), 1,
+	'... should handle failure with multiple local netmasks' );
+
+# now fool Perl into compiling this again.  HEY, LOOK OVER THERE!
+my $path = $INC{'Net/Config.pm'};
+delete $INC{'Net/Config.pm'};
+
+# Net::Config populates %NetConfig from 'libnet.cfg', if possible
+my $wrote_file = 0;
+
+(my $cfgfile = $path) =~ s/Config.pm/libnet.cfg/;
+if (open(OUT, '>' . $cfgfile)) {
+	use Data::Dumper;
+	print OUT Dumper({
+		some_hosts => [ 1, 2, 3 ],
+		time_hosts => 'abc',
+		some_value => 11,
+	});
+	close OUT;
+	$wrote_file = 1;
+}
+
+SKIP: {
+	skip('could not write cfg file', 4) unless $wrote_file;
+
+	# and here comes Net::Config, again!  no import() necessary
+	require $path;
+
+	is( $NetConfig{some_value}, 11, 
+		'Net::Config should populate %NetConfig from libnet.cfg file' );
+	is( scalar @{ $NetConfig{time_hosts} }, 1, 
+		'... should turn _hosts keys into array references' );
+	is( scalar @{ $NetConfig{some_hosts} }, 3, 
+		'... should not mangle existing array references' );
+	is( $NetConfig{some_hosts}[0], 1,
+		'... and one last check for multivalues' );
+}
+
+is( \&Net::Config::is_external, \&Net::Config::requires_firewall,
+	'is_external() should be an alias for requires_firewall()' );
+
+END {
+	1 while unlink ($cfgfile);
+}
0
chromatic
10/20/2001 7:32:01 AM
perl.qa 2166 articles. 0 followers. Follow

18 Replies
5033 Views

Similar Articles

[PageSpeed] 32

> Here's a test suite for Net::Config.  In the process of writing
> this, I've fixed an apparent bug that prevented single values from
> becoming array references when necessary.  I think it's right, but
> perhaps Graham should weigh in on this.
>
> In the process, with some advice from perl-qa, I've added a mock
> object so the test could control the output of Socket::inet_ntoa()
> and Socket::inet_aton().  t/lib/Mock/ seemed like as good a place as
> any.

I'm not convinced.  By setting up mock-ups you are not testing the
real thing: you are testing mock-ups.  It's real emptying shotguns
at decoys and concluding that yup, we are eating duck tonight.

Testing that the netconfig file works right with the %Netconfig
is nice I think somewhat beside the point.  The format of the
file is irrelevant for the *outward* functionality of libnet.

FWIW, I'm happy with leaving libnet essentially untested because
I think by its very nature it is untestable across all the possible
network configurations.  Try some time using ftp from behind sadistic
firewalls, for example.  Situations like this *can* be configured
to work, most of the time, but it requires a lot of off-line head
scratching, bribing the keepers of the firewalls, things like that.
Things a test suite cannot do unless we make Perl pass the Turing test.

QA incendiary: I think rabidly trying to strap a test harness on
everything that moves is counterproductive.  Not all APIs have been
planned to be tested.  Of course the documentation should tell what
are the public interfaces, but if in doubt, *ask* the author.
Testing for internal not-meant-to-be-seen bits is plain silly.

-- 
$jhi++; # http://www.iki.fi/jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen
0
jhi
10/20/2001 4:13:31 PM
In article <20011020191331.J9942@alpha.hut.fi>, "Jarkko Hietaniemi" <jhi@iki.fi>
wrote:

>> In the process, with some advice from perl-qa, I've added a mock object so
>> the test could control the output of Socket::inet_ntoa() and
>> Socket::inet_aton().  t/lib/Mock/ seemed like as good a place as any.
 
> I'm not convinced.  By setting up mock-ups you are not testing the real thing:
> you are testing mock-ups.  It's real emptying shotguns at decoys and
> concluding that yup, we are eating duck tonight.

I see it as isolating the point of failure.  If the Socket module fails, its
own test should say so.  Trying to write a test that takes into account all of
the possible network variations is an exercise in madness.  (It's probably akin
to being a pumpking :).

Mock objects aren't a lot different than  mock input.  They just seem weird
because they have a different shape.  They help separate the things that change
(underlying network differences) from the things that stay the same (the module
being tested).

Net::Config doesn't care *how* inet_ntoa and inet_aton do their job.  It just
cares that it gets data in the right format.  Tying STDIN and feeding fake
input to Term::Complete is, in a weird sense, much the same thing.  (Maybe
that's not the right test to mention... )
 
> FWIW, I'm happy with leaving libnet essentially untested because I think by
> its very nature it is untestable across all the possible network
> configurations.  Try some time using ftp from behind sadistic firewalls, for
> example.  Situations like this *can* be configured to work, most of the time,
> but it requires a lot of off-line head scratching, bribing the keepers of the
> firewalls, things like that. Things a test suite cannot do unless we make Perl
> pass the Turing test.

It sounds like we have different ideas as to what a test suite is supposed to
prove.  To me, it's a near-guarantee that as far as p5p can control, the code
appears to do what it says on your platform.  There's definitely a range of
things that cannot be tested, but it's smaller than most people would think.
We also can't mathematically *prove* that everything works in every
configuration.

The best we can do is establish a baseline of behavior that ought to work on
all platforms.  If it throws up red flags and makes someone *think* about
changes to existing code, so much the better.  I'm all for an 80% solution, as
long as we realize that there's 20% still out there.  80% is better than 70% or
50% or 0%.
 
> QA incendiary: I think rabidly trying to strap a test harness on everything
> that moves is counterproductive.  Not all APIs have been planned to be tested.
>  Of course the documentation should tell what are the public interfaces, but
> if in doubt, *ask* the author. Testing for internal not-meant-to-be-seen bits
> is plain silly.
 
You're right -- some things shouldn't be tested (accessors!).  Still, the
finer-grained the tests, the easier it is to find an error.  I'd rather spend
my time fixing a dozen bugs, if I can pinpoint them to within five lines, than
tracking down one.

Of course, my opinions might change, if I have to write tests for CPAN.pm or
the debugger.  Yikes.

-- c
0
chromatic
10/20/2001 5:33:17 PM
> Net::Config doesn't care *how* inet_ntoa and inet_aton do their job.
> It just cares that it gets data in the right format.  Tying STDIN

So why is this tested using a mock-up by Net::Config?  Sounds like
a job the Socket should be testing (and it is).

> and feeding fake input to Term::Complete is, in a weird sense, much
> the same thing.  (Maybe that's not the right test to mention... )

:-)

> It sounds like we have different ideas as to what a test suite is
> supposed to prove.  To me, it's a near-guarantee that as far as p5p
> can control, the code appears to do what it says on your platform.

I think the key is here: "on your platform".  I think that for many
things there's simply too much outside of our control to write any
meaningful tests.  A beatiful thought, but painful to execute.

As an example: the Term:: tests.  They practically assume a very
UNIX-like environment.  So if you are writing tests, you are really
testing whether the environment is UNIX-like.  And I do not think that
is helping much.  Yes, it will find the limits of UNIX compatibility:
but that is the task of the documentation to tell about (thou shalt
not try this unless you are UNIX).

That the tests tells us "tests 3, 17, 18, and 22 were skipped because
you do not seem to have an environment the test expects" is a nice
tidbit for the installer to know, but will that help the users if the
matter is not permanently documented?  If the detailed test results
were *recorded* somewhere in the installation, they would be much more
useful: "Note that feature blartz does not work in GoofOS, because ..."

I think that the of %Config and $^O tests in a test should be a
warning flag-- what are we *really* testing?

> There's definitely a range of things that cannot be tested, but it's
> smaller than most people would think.  We also can't mathematically
> *prove* that everything works in every configuration.
>
> The best we can do is establish a baseline of behavior that ought to work on
> all platforms.  If it throws up red flags and makes someone *think* about

I hope you have noticed that the baseline is rather low.

-- 
$jhi++; # http://www.iki.fi/jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen
0
jhi
10/20/2001 5:54:02 PM
On Saturday 20 October 2001 11:54, you wrote:

> So why is this tested using a mock-up by Net::Config?  Sounds like
> a job the Socket should be testing (and it is).

Oh, no!  It's not.  Mock::Socket is just a dummy object with the same 
interface as Socket.  It lets the test control the data sent back to 
Net::Config.  The test doesn't care whether or not Socket works.  That's 
*way* out of the scope of Net::Config.  The real Socket.pm should never be 
loaded.

(The test also doesn't care whether or not t/op/var.t fails, for example.  So 
it's not as bad as it sounds.  If most everything is properly tested in 
isolation, it's *much* easier to find the one broken thing.)

> That the tests tells us "tests 3, 17, 18, and 22 were skipped because
> you do not seem to have an environment the test expects" is a nice
> tidbit for the installer to know, but will that help the users if the
> matter is not permanently documented?  If the detailed test results
> were *recorded* somewhere in the installation, they would be much more
> useful: "Note that feature blartz does not work in GoofOS, because ..."

Perhaps Test::Harness should capture skip messages and append them to a POD 
somewhere?  I'm happy to work on this if it's a good idea.

"You appear to be running $^O.  The following tests were skipped.  This does 
not guarantee the modules will not run on your system, but it is a pretty 
good indication that you are on your own."

> > The best we can do is establish a baseline of behavior that ought to work
> > on all platforms.  If it throws up red flags and makes someone *think*
> > about
>
> I hope you have noticed that the baseline is rather low.

As long as it's marked...  :)

-- c
0
chromatic
10/20/2001 6:04:49 PM
On Saturday 20 October 2001 11:54, you wrote:

> So why is this tested using a mock-up by Net::Config?  Sounds like
> a job the Socket should be testing (and it is).

Oh, no!  It's not.  Mock::Socket is just a dummy object with the same 
interface as Socket.  It lets the test control the data sent back to 
Net::Config.  The test doesn't care whether or not Socket works.  That's 
*way* out of the scope of Net::Config.  The real Socket.pm should never be 
loaded.

(The test also doesn't care whether or not t/op/var.t fails, for example.  So 
it's not as bad as it sounds.  If most everything is properly tested in 
isolation, it's *much* easier to find the one broken thing.)

> That the tests tells us "tests 3, 17, 18, and 22 were skipped because
> you do not seem to have an environment the test expects" is a nice
> tidbit for the installer to know, but will that help the users if the
> matter is not permanently documented?  If the detailed test results
> were *recorded* somewhere in the installation, they would be much more
> useful: "Note that feature blartz does not work in GoofOS, because ..."

Perhaps Test::Harness should capture skip messages and append them to a POD 
somewhere?  I'm happy to work on this if it's a good idea.

"You appear to be running $^O.  The following tests were skipped.  This does 
not guarantee the modules will not run on your system, but it is a pretty 
good indication that you are on your own."

> > The best we can do is establish a baseline of behavior that ought to work
> > on all platforms.  If it throws up red flags and makes someone *think*
> > about
>
> I hope you have noticed that the baseline is rather low.

As long as it's marked...  :)

-- c
0
chromatic
10/20/2001 6:04:49 PM
On Sat, Oct 20, 2001 at 12:04:49PM -0600, chromatic wrote:
> On Saturday 20 October 2001 11:54, you wrote:
> 
> > So why is this tested using a mock-up by Net::Config?  Sounds like
> > a job the Socket should be testing (and it is).
> 
> Oh, no!  It's not.  Mock::Socket is just a dummy object with the same 
> interface as Socket.  It lets the test control the data sent back to 
> Net::Config.  The test doesn't care whether or not Socket works.  That's 
> *way* out of the scope of Net::Config.  The real Socket.pm should never be 
> loaded.

Hmmm.  That sounds a little bit better.

> > I hope you have noticed that the baseline is rather low.
> 
> As long as it's marked...  :)

As I tried to explain, it's currently not marked anywhere else than in
short-lived emissions of photons as the poorly explained test failures
whizz by the eyes of the person doing the build.

> -- c

-- 
$jhi++; # http://www.iki.fi/jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen
0
jhi
10/20/2001 6:23:49 PM
Any patches to modules from libnet, and test additions, should be
against the latest libnet on CPAN, I do not want the core to diverge.
So if a test depends on a module in the core it should check that
the module is avaliable, so that the test is skipped with older
perl releases.

Graham.

On Sat, Oct 20, 2001 at 01:32:01AM -0600, chromatic wrote:
> Here's a test suite for Net::Config.  In the process of writing this, I've
> fixed an apparent bug that prevented single values from becoming array
> references when necessary.  I think it's right, but perhaps Graham should weigh
> in on this.
> 
> In the process, with some advice from perl-qa, I've added a mock object so the
> test could control the output of Socket::inet_ntoa() and Socket::inet_aton().
> t/lib/Mock/ seemed like as good a place as any.
> 
> I'm happy to rework this patch if it personally offends anyone whose opinion
> matters.  :)
> 
> -- c
> 
> --- lib/Net/~Config.pm	Sat Oct 20 01:23:46 2001
> +++ lib/Net/Config.pm	Sat Oct 20 01:23:54 2001
> @@ -13,7 +13,7 @@
>  
>  @EXPORT  = qw(%NetConfig);
>  @ISA     = qw(Net::LocalCfg Exporter);
> -$VERSION = "1.05"; # $Id: //depot/libnet/Net/Config.pm#9 $
> +$VERSION = "1.06"; # $Id: //depot/libnet/Net/Config.pm#9 $
>  
>  eval { local $SIG{__DIE__}; require Net::LocalCfg };
>  
> @@ -54,11 +54,11 @@
>  }
>  my ($k,$v);
>  while(($k,$v) = each %NetConfig) {
> -    $v = [ $v ]
> -	if($k =~ /_hosts$/ && !ref($v));
> +	$NetConfig{$k} = [ $v ]
> +		if($k =~ /_hosts$/ && !ref($v));
>  }
>  
> -# Take a hostname and determine if it is inside te firewall
> +# Take a hostname and determine if it is inside the firewall
>  
>  sub requires_firewall {
>      shift; # ignore package
> --- ~MANIFEST	Sat Oct 20 01:24:04 2001
> +++ MANIFEST	Sat Oct 20 01:24:42 2001
> @@ -1065,6 +1065,7 @@
>  lib/Net/Cmd.pm			libnet
>  lib/Net/Config.eg		libnet
>  lib/Net/Config.pm		libnet
> +lib/Net/Config.pm		libnet (see if Net::Config works)
>  lib/Net/demos/ftp		libnet
>  lib/Net/demos/inetd		libnet
>  lib/Net/demos/nntp		libnet
> --- /dev/null	Thu Aug 30 03:54:37 2001
> +++ t/lib/Mock/Socket.pm	Sat Oct 20 00:02:49 2001
> @@ -0,0 +1,31 @@
> +package Mock::Socket;
> +
> +# this is not the package you're looking for
> +
> +package Socket;
> +
> +$INC{'Socket.pm'} = 1;
> +
> +use Exporter;
> +@Socket::ISA = ( 'Exporter' );
> +@EXPORT = qw( &inet_aton &inet_ntoa );
> +
> +my (%aton, %ntoa);
> +
> +sub set_dns {
> +	while (my ($name, $number) = splice(@_, 0, 2)) {
> +		my $packed = unpack( "N", pack("C*", split(/\./, $number)));
> +		$aton{$name} = $packed;
> +		$ntoa{$packed} = $number;
> +	}
> +}
> +
> +sub inet_aton {
> +	return $aton{$_[0]};
> +}
> +
> +sub inet_ntoa {
> +	return $ntoa{$_[0]};
> +}
> +
> +1;
> --- /dev/null	Thu Aug 30 03:54:37 2001
> +++ lib/Net/Config.t	Sat Oct 20 01:18:50 2001
> @@ -0,0 +1,85 @@
> +#!./perl
> +
> +BEGIN {
> +	chdir 't' if -d 't';
> +	@INC = ( 'lib', '../lib' );
> +}
> +
> +# lots of magic, see t/lib/Mock/Socket
> +use Mock::Socket;
> +use Test::More tests => 14;
> +
> +use_ok( 'Net::Config' );
> +ok( keys %NetConfig, '%NetConfig should be imported' );
> +
> +undef $NetConfig{'ftp_firewall'};
> +is( Net::Config->requires_firewall, 0, 
> +	'requires_firewall() should return 0 without ftp_firewall defined' );
> +
> +# this calls inet_aton in the mock Socket, so it *may* not be portable
> +$NetConfig{'ftp_firewall'} = 1;
> +is( Net::Config->requires_firewall, -1,
> +	'... should return -1 without a valid hostname' );
> +
> +# use the mock Socket to resolve addresses our way
> +Socket::set_dns( localhost => '127.0.0.1', remotehost => '192.168.10.0' );
> +delete $NetConfig{'local_netmask'};
> +is( Net::Config->requires_firewall('localhost'), 0,
> +	'... should return 0 without local_netmask defined' );
> +
> +# 
> +$NetConfig{'local_netmask'} = '127.0.0.1/24';
> +is( Net::Config->requires_firewall('localhost'), 0,
> +	'... should return false if host is within netmask' );
> +is( Net::Config->requires_firewall('remotehost'), 1,
> +	'... should return true if host is outside netmask' );
> +
> +# now try more netmasks
> +Socket::set_dns( otherlocal => '10.10.255.254' );
> +$NetConfig{'local_netmask'} = [ '127.0.0.1/24', '10.0.0.0/8' ];
> +is( Net::Config->requires_firewall('otherlocal'), 0,
> +	'... should find success with mutiple local netmasks' );
> +is( Net::Config->requires_firewall('remotehost'), 1,
> +	'... should handle failure with multiple local netmasks' );
> +
> +# now fool Perl into compiling this again.  HEY, LOOK OVER THERE!
> +my $path = $INC{'Net/Config.pm'};
> +delete $INC{'Net/Config.pm'};
> +
> +# Net::Config populates %NetConfig from 'libnet.cfg', if possible
> +my $wrote_file = 0;
> +
> +(my $cfgfile = $path) =~ s/Config.pm/libnet.cfg/;
> +if (open(OUT, '>' . $cfgfile)) {
> +	use Data::Dumper;
> +	print OUT Dumper({
> +		some_hosts => [ 1, 2, 3 ],
> +		time_hosts => 'abc',
> +		some_value => 11,
> +	});
> +	close OUT;
> +	$wrote_file = 1;
> +}
> +
> +SKIP: {
> +	skip('could not write cfg file', 4) unless $wrote_file;
> +
> +	# and here comes Net::Config, again!  no import() necessary
> +	require $path;
> +
> +	is( $NetConfig{some_value}, 11, 
> +		'Net::Config should populate %NetConfig from libnet.cfg file' );
> +	is( scalar @{ $NetConfig{time_hosts} }, 1, 
> +		'... should turn _hosts keys into array references' );
> +	is( scalar @{ $NetConfig{some_hosts} }, 3, 
> +		'... should not mangle existing array references' );
> +	is( $NetConfig{some_hosts}[0], 1,
> +		'... and one last check for multivalues' );
> +}
> +
> +is( \&Net::Config::is_external, \&Net::Config::requires_firewall,
> +	'is_external() should be an alias for requires_firewall()' );
> +
> +END {
> +	1 while unlink ($cfgfile);
> +}
0
gbarr
10/22/2001 12:44:32 PM
On Monday 22 October 2001 14:10, Michael G Schwern wrote:

> I can understand this.  We should be patching the CPAN libnet.

In progress.

> > So if a test depends on a module in the core it should check that
> > the module is avaliable, so that the test is skipped with older
> > perl releases.
> But this is a little funny.  How are these new tests going to wind up
> on old perl and libnet versions?

I understood that as Graham being unsure about using Test::More in the tests.

-- c
0
chromatic
10/22/2001 8:08:05 PM
On Monday 22 October 2001 14:10, Michael G Schwern wrote:

> I can understand this.  We should be patching the CPAN libnet.

In progress.

> > So if a test depends on a module in the core it should check that
> > the module is avaliable, so that the test is skipped with older
> > perl releases.
> But this is a little funny.  How are these new tests going to wind up
> on old perl and libnet versions?

I understood that as Graham being unsure about using Test::More in the tests.

-- c
0
chromatic
10/22/2001 8:08:05 PM
On Mon, Oct 22, 2001 at 01:44:32PM +0100, Graham Barr wrote:
> Any patches to modules from libnet, and test additions, should be
> against the latest libnet on CPAN, I do not want the core to diverge.

I can understand this.  We should be patching the CPAN libnet.


> So if a test depends on a module in the core it should check that
> the module is avaliable, so that the test is skipped with older
> perl releases.

But this is a little funny.  How are these new tests going to wind up
on old perl and libnet versions?


-- 

Michael G. Schwern   <schwern@pobox.com>    http://www.pobox.com/~schwern/
Perl6 Quality Assurance     <perl-qa@perl.org>	     Kwalitee Is Job One
I'm not actually Kevin Lenzo, but I play him on TV.
0
schwern
10/22/2001 8:10:06 PM
On Mon, Oct 22, 2001 at 04:10:06PM -0400, Michael G Schwern wrote:
> On Mon, Oct 22, 2001 at 01:44:32PM +0100, Graham Barr wrote:
> > Any patches to modules from libnet, and test additions, should be
> > against the latest libnet on CPAN, I do not want the core to diverge.
> 
> I can understand this.  We should be patching the CPAN libnet.
> 
> 
> > So if a test depends on a module in the core it should check that
> > the module is avaliable, so that the test is skipped with older
> > perl releases.
> 
> But this is a little funny.  How are these new tests going to wind up
> on old perl and libnet versions?

Because the new tests should be added to libnet, not the core.

And libnet runs on older versions

Graham.
0
gbarr
10/22/2001 8:12:42 PM
On Mon, Oct 22, 2001 at 02:08:05PM -0600, chromatic wrote:
> On Monday 22 October 2001 14:10, Michael G Schwern wrote:
> 
> > I can understand this.  We should be patching the CPAN libnet.
> 
> In progress.
> 
> > > So if a test depends on a module in the core it should check that
> > > the module is avaliable, so that the test is skipped with older
> > > perl releases.
> > But this is a little funny.  How are these new tests going to wind up
> > on old perl and libnet versions?
> 
> I understood that as Graham being unsure about using Test::More in the tests.

Actually I was refering to Mock::Socket

Graham.
0
gbarr
10/22/2001 8:13:18 PM
On Monday 22 October 2001 14:13, Graham Barr wrote:

> > I understood that as Graham being unsure about using Test::More in the
> > tests.

> Actually I was refering to Mock::Socket

Would you be amenable to a patch that moves that into the .t file?

There's no technical reason it has to be a module.  I just wrote it that way, 
thinking it might be expandable and reusable.  That could be considered 
jumping several guns.  :)

-- c
0
chromatic
10/22/2001 8:14:43 PM
On Monday 22 October 2001 14:13, Graham Barr wrote:

> > I understood that as Graham being unsure about using Test::More in the
> > tests.

> Actually I was refering to Mock::Socket

Would you be amenable to a patch that moves that into the .t file?

There's no technical reason it has to be a module.  I just wrote it that way, 
thinking it might be expandable and reusable.  That could be considered 
jumping several guns.  :)

-- c
0
chromatic
10/22/2001 8:14:43 PM
On Mon, Oct 22, 2001 at 02:14:43PM -0600, chromatic wrote:
> On Monday 22 October 2001 14:13, Graham Barr wrote:
> 
> > > I understood that as Graham being unsure about using Test::More in the
> > > tests.
> 
> > Actually I was refering to Mock::Socket
> 
> Would you be amenable to a patch that moves that into the .t file?

That would be OK. Although if you intend other tests to use it I would
place it into t/common.pl and require it in the test

> There's no technical reason it has to be a module.  I just wrote it that way, 
> thinking it might be expandable and reusable.  That could be considered 
> jumping several guns.  :)

Sure, I was just suggesting that test could test for the existance of
the module and skip otherwise

Graham.
0
gbarr
10/22/2001 8:19:34 PM
On Mon, Oct 22, 2001 at 04:27:51PM -0400, Michael G Schwern wrote:
> On Mon, Oct 22, 2001 at 02:08:05PM -0600, chromatic wrote:
> > > > So if a test depends on a module in the core it should check that
> > > > the module is avaliable, so that the test is skipped with older
> > > > perl releases.
> > > But this is a little funny.  How are these new tests going to wind up
> > > on old perl and libnet versions?
> > 
> > I understood that as Graham being unsure about using Test::More in the tests.
> 
> Oh, we can fix that.  Just distribute Test::More with libnet, a la
> CGI.pm.

You can forget that idea.

Graham.

0
gbarr
10/22/2001 8:25:24 PM
On Mon, Oct 22, 2001 at 02:08:05PM -0600, chromatic wrote:
> > > So if a test depends on a module in the core it should check that
> > > the module is avaliable, so that the test is skipped with older
> > > perl releases.
> > But this is a little funny.  How are these new tests going to wind up
> > on old perl and libnet versions?
> 
> I understood that as Graham being unsure about using Test::More in the tests.

Oh, we can fix that.  Just distribute Test::More with libnet, a la
CGI.pm.

I'll just go summon my Army of Test::More Octopi to assimilate libnet.


-- 

Michael G. Schwern   <schwern@pobox.com>    http://www.pobox.com/~schwern/
Perl6 Quality Assurance     <perl-qa@perl.org>	     Kwalitee Is Job One
no paste enema
lycos is taught about it
my ass is sealed
	-- Schwern
0
schwern
10/22/2001 8:27:51 PM
On Mon, Oct 22, 2001 at 09:25:24PM +0100, Graham Barr wrote:
> On Mon, Oct 22, 2001 at 04:27:51PM -0400, Michael G Schwern wrote:
> > On Mon, Oct 22, 2001 at 02:08:05PM -0600, chromatic wrote:
> > > > > So if a test depends on a module in the core it should check that
> > > > > the module is avaliable, so that the test is skipped with older
> > > > > perl releases.
> > > > But this is a little funny.  How are these new tests going to wind up
> > > > on old perl and libnet versions?
> > > 
> > > I understood that as Graham being unsure about using Test::More in the tests.
> > 
> > Oh, we can fix that.  Just distribute Test::More with libnet, a la
> > CGI.pm.
> 
> You can forget that idea.
> 
> Graham.

The owner of the module has spoken and therefore I strongly advise
the discussion about the matter to end right now.

-- 
$jhi++; # http://www.iki.fi/jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen
0
jhi
10/22/2001 8:33:23 PM
Reply:

Similar Artilces:

[PATCH lib/DB.pm MANIFEST lib/DB.t] Add Tests for DB.pm
Here's a bunch of tests for DB.pm. Some bits aren't easily testable, and there's room for someone more knowledgeable or clever to come along to improve them even more. In the process of writing these tests, I patched one little thing in DB.pm, per the comment. With the patch, all pass. -- c --- lib/~DB.pm Fri Nov 23 14:04:53 2001 +++ lib/DB.pm Fri Nov 23 14:48:12 2001 @@ -406,8 +406,7 @@ $name = "main" . $name if substr($name,0,2) eq "::"; my($fname, $from, $to) = ($DB::sub{$name} =~ /^(.*):(\d+)-(\d+)$/); if ($from) { - # XXX t...

[PATCH MANIFEST lib/Dumpvalue.t lib/Dumpvalue.pm] Add tests for Dumpvalue.pm
This patch adds tests for Dumpvalue. In addition, it makes Dumpvalue::scalarUsage() handle references correctly. This allows complex data structures to be dumped fairly sensibly, and improves the *Usage() functions for complex data structures. In addition, some of the documentation had incorrectly cased options. There's also some additional information on quoteHighBits and usageOnly. The version number has been incremented appropriately. Everything passes wonderfully. -- c --- ~MANIFEST Fri Sep 21 21:35:55 2001 +++ MANIFEST Fri Sep 21 21:36:11 2001 @@ -862,6 +862,7 @...

[PROPOSED PATCH MANIFEST lib/Net/Netrc.t] Add Tests for Net::Netrc
[not yet sent to p5p; comments welcome] Is this valuable for anyone? I could probably turn something like this into an article for perl.com or the Perl Journal or even use.perl, if anyone could sweet-talk an editor or thinks gonzo testing ought to be promoted. Schwern thinks it's clever, so it can't be all bad. -- c --- ~MANIFEST Sun Oct 21 14:36:07 2001 +++ MANIFEST Sun Oct 21 14:36:23 2001 @@ -1087,6 +1087,7 @@ lib/Net/netent.pm By-name interface to Perl's builtin getnet* lib/Net/netent.t See if Net::netent works lib/Net/Netrc.pm libnet +lib/Net/Netrc.t...

[PATCH t/TEST lib/Test.pm t/lib/Test/*.t] Syncing with Test-1.17
Here's a patch that brings Test.pm in sync with version 1.17 on CPAN. It needs the deep directory t/TEST patch I posted earlier and does its own TEST patch so it recognizes old-style todo tests. Here's the changes: 2001-05-29 Michael G Schwern <schwern@pobox.com> * Release 1.17 - protected against stray $/ and $, * documented ok() * made the regex diagnostics a bit more obvious * Backported to 5.004 (if you're using the new Test::Harness) * Included the VMS fix for ok() 2001-02-16 Michael G Schwern <schwern@pobox.com> * Release 1.16 * T...

[PATCH MANIFEST lib/Tie/Scalar.pm lib/Tie/Scalar.t] Add tests, clean up Tie::Scalar
Writing tests for Tie::Scalar, I had a terrible time figuring out why it wouldn't call an inherited new() from TIESCALAR() if TIESCALAR() were not overridden. So I patched the module to Do What It Should. The test assumes this patch is in place. I can rewrite the test if the patch is dumb (it's been a long day). There are a couple of tests in other places (t/op/tie.t, t/op/pos.t) that use Tie::Scalar, but nothing comprehensive. -- c --- ~MANIFEST Fri Sep 28 20:43:42 2001 +++ MANIFEST Fri Sep 28 21:04:31 2001 @@ -1225,6 +1225,7 @@ lib/Tie/RefHash.pm Base class for...

[PATCH lib/Test/Harness.pm t/lib/test-harness.t] Syncing with 1.21
This patch brings the core Test::Harness in sync with version 1.21 on CPAN. I left out a couple of tests since they're not adapted to the core (ie. the assume they're being run directly by Test::Harness, not t/TEST). I know I said I was going to provide a cpan2core script, but not this time around. Here's what's changed since I branched. The biggest things are breaking up the monolithic runtests(), expanded docs and allowing the '1..M' to appear at the end of the test script. Ilya's patch isn't in here, instead the 'Status' column name h...

[PATCH MANIFEST lib/warnings/register.t lib/warnings/register.pm] Add Tests for warnings::register, Doc Update
This patch adds tests for warnings::register. In addition, it updates the warnings::register man page to point to L<perllexwarn>, which goes into sufficient detail as to its usage. (The qa person who reported it untested couldn't find any documentation, but I persevered.) -- c --- ~MANIFEST Fri Sep 21 21:35:55 2001 +++ MANIFEST Sat Sep 22 09:40:32 2001 @@ -1576,6 +1576,7 @@ lib/warnings.pm For "use warnings" lib/warnings.t See if warning controls work lib/warnings/register.pm For "use warnings::register" +lib/warnings/register.t See if &...

[PATCH t/test.pl t/op/stat.t lib/Net/hostent.t] Unbail out
Found this sitting in my postponed message queue. Hopefully things haven't drifted meantime. Whoops! I misinterpreted the meaning of "Bail out!" to Test::Harness. It means "stop *ALL* testing". This means once a 'Bail out' is seen no further test programs are run. Not what I thought it ment. All I wanted was a slightly more elegant die. --- t/test.pl 2001/12/10 07:26:59 1.1 +++ t/test.pl 2001/12/10 07:27:10 @@ -260,9 +260,9 @@ } -sub BAILOUT { - print STDOUT "Bail out! @_\n"; - exit; +sub DIE { + print STDO...

[PATCH lib/Config.t] test grandfathered Config variables
Ben noticed that part of my Config patch was broken. The translation of grandfathered variables was coded incorrectly. Since it wasn't tested I didn't notice it. Here's a test. --- lib/Config.t 2002/09/03 05:17:36 1.1 +++ lib/Config.t 2002/09/03 05:22:23 @@ -4,7 +4,7 @@ require "./test.pl"; } -plan tests => 23; +plan tests => 29; use_ok('Config'); @@ -16,6 +16,16 @@ is($Config{PERL_REVISION}, 5, "PERL_REVISION is 5"); +# Check that old config variable names are aliased to their new ones. +my %grandfathers...

[PATCH lib/Net/Config.pm] Fix Some Pod Typos
Just a couple of typos in the documentation. Tests forthcoming, maybe a little refactoring of the module to make it easier. -- c --- lib/Net/~Config.pm Fri Oct 19 22:27:27 2001 +++ lib/Net/Config.pm Fri Oct 19 22:32:47 2001 @@ -107,8 +107,8 @@ distribuion. During installation you will be asked for these values. The configuration data is held globally in a file in the perl installation -tree, but a user may override any of these values by providing thier own. This -can be done by having a C<.libnetrc> file in thier home directory. This file +tree, but a user may overri...

[PATCH MANIFEST, lib/ExtUtils/Command.pm, lib/ExtUtils/Command.t] Fix Pod Typo, Add Test for ExtUtils::Command
The pod for rm_rf() calls it rm_f(). As there's already another function of that name, it's doubly wrong. The first patch fixes that. The rest add some tests. According to the pod, ExtUtils::Command only exists for some Win32 portability. As such, the tests are skipped unless $^O matches Win32. (All of the tests run fine on my Linux box, though.) --- lib/ExtUtils/~Command.pm Sun Sep 9 23:25:30 2001 +++ lib/ExtUtils/Command.pm Mon Sep 10 00:31:55 2001 @@ -71,7 +71,7 @@ utime((stat($src))[8,9],$dst); } -=item rm_f files.... +=item rm_rf files.... Removes d...

[PATCH t/lib/exporter.t lib/Exporter/Heavy.pm] Testing Exporter
Exporter, that rather important module, had no tests. This adds some. They're by no means exhaustive, but its better than nothing. This also exposed a subtle bug in require_version. require_version(0) would always be false, even if $VERSION == 0 or was undefined. Also, if $VERSION is 0 it would report it as undef. These have been fixed and tested. --- MANIFEST 2001/02/04 12:39:35 1.1 +++ MANIFEST 2001/04/14 21:28:39 @@ -1393,6 +1393,7 @@ t/lib/env-array.t See if Env works for arrays t/lib/env.t See if Env works t/lib/errno.t See if Errno works +t/lib/exporter.t ...

[REPATCH lib/DB.pm MANIFEST lib/DB.t] Rework DB.pm tests
Based on Schwern's suggestions that my ideal Test::More::is() does not match reality, here's a version of the DB.pm tests that explicitly tests definedness. I also fixed a couple of bugs in the test. It passes, with the attached DB.pm patch applied. -- c --- lib/~DB.pm Fri Nov 23 14:04:53 2001 +++ lib/DB.pm Fri Nov 23 14:48:12 2001 @@ -406,8 +406,7 @@ $name = "main" . $name if substr($name,0,2) eq "::"; my($fname, $from, $to) = ($DB::sub{$name} =~ /^(.*):(\d+)-(\d+)$/); if ($from) { - # XXX this needs local()-ization of some sort - *D...

[PATCH MANIFEST lib/filetest t/lib/1_compile.t] Add Tests for filetest Pragma
This patch adds tests for the filetest pragma. It doesn't guarantee that it'll *do* anything useful on any platform, but it does check that it attempts to do something useful. It'd be a lot more work to figure out which platforms can use access() under which circumstances. The test just guarantees that, if you can, the pragma appears to function as expected. There's also a patch for t/lib/1_compile.t, which appears correct. I don't understand everything in the t directory, so it's worth double-checking me on this. --- ~MANIFEST Sun Sep 23 11:50:39 2001...

Web resources about - [PATCH lib/Net/Config.pm, MANIFEST, t/lib/Mock/Socket.pm, lib/Net/Config.t] Add Tests for Net::Config - perl.qa

Resources last updated: 12/7/2015 7:02:59 AM