Re: Untested libraries update

2001-09-24 Thread Philip Newton

On Mon, 24 Sep 2001 14:49:08 +0100, [EMAIL PROTECTED] (Nicholas Clark)
wrote:

> /perl -Ilib -MTest::More -e 'plan(3); ok(1)'
> Undefined subroutine &Test::More::plan called at -e line 1.

Should be

/perl -Ilib -MTest::More=tests,3 -e 'ok(1)'

IMO.

Cheers,
Philip



Re: [PATCH] AutoSplit.t (was Re: Untested libraries update)

2001-09-24 Thread Michael G Schwern

Could you explain a bit about what this test is doing?

It may help to put sample files to split against in t/lib somewhere
rather than smashing them all after the __END__ block.


On Tue, Sep 25, 2001 at 12:37:40AM +0100, Nicholas Clark wrote:
> +  # There may be a way to capture STDOUT without spawning a child process

tie STDOUT.  Spawning introduces all sorts of nasty cross platform
issues.



-- 

Michael G. Schwern   <[EMAIL PROTECTED]>http://www.pobox.com/~schwern/
Perl6 Quality Assurance <[EMAIL PROTECTED]>   Kwalitee Is Job One
sort God kill 9, @ARGV;



Re: Untested libraries update

2001-09-24 Thread Michael G Schwern

On Mon, Sep 24, 2001 at 02:49:08PM +0100, Nicholas Clark wrote:
> Fair enough. But:
> 
> ./perl -Ilib -MTest::More -e 'plan(3); ok(1)'
> Undefined subroutine &Test::More::plan called at -e line 1.
> 
> Can't I use the module early, and then figure out how many tests I'm planning
> to run at run time? If "no", I'm going to have to do my figuring-out in a
> BEGIN block. This was with Test::More::VERSION '0.19'

Working on it, it's in the middle of an internals overhaul.

Meantime, consider using SKIP blocks instead.  If that can't work, use
this:

require Test::More;
Test::More->import( tests => $tests );

Sorry for the inconvenience.

-- 

Michael G. Schwern   <[EMAIL PROTECTED]>http://www.pobox.com/~schwern/
Perl6 Quality Assurance <[EMAIL PROTECTED]>   Kwalitee Is Job One
BOFH excuse #399:

We are a 100% Microsoft Shop.



Re: Untested libraries update

2001-09-24 Thread John Peacock

Nicholas Clark wrote:
> 
> Can't I use the module early, and then figure out how many tests I'm planning
> to run at run time? If "no", I'm going to have to do my figuring-out in a
> BEGIN block. This was with Test::More::VERSION '0.19'

You can look at what I did in t/op/ver.t as well, vis:

$tests = [whatever] ? 47 : 44;

require Test::More;
Test::More->import( tests => $tests );

which works as well.  I think the SKIP method is better, though.

John

-- 
John Peacock
Director of Information Research and Technology
Rowman & Littlefield Publishing Group
4720 Boston Way
Lanham, MD 20706
301-459-3366 x.5010
fax 301-429-5747



Re: [PATCH] Test::More isa_ok function

2001-09-24 Thread Dave Rolsky

On Mon, 24 Sep 2001, Michael G Schwern wrote:

> On Mon, Sep 24, 2001 at 06:23:58PM -0500, Dave Rolsky wrote:
> > The patch below allows you to supply your own test name for the isa_ok
> > function (I find the default insufficiently descriptive).  I'd like to do
> > the same for can_ok but I don't think that could be done without breaking
> > backwards compatibility.
>
> What sort of names do you tend to throw in there?

Just something more descriptive than what it generates by default.
Something like "Check that object X isa Blah".  The key being that I want
to say _what_ object I'm checking.

-dave

/*==
www.urth.org
We await the New Sun
==*/




Re: [PATCH] More Test::More stuff

2001-09-24 Thread Dave Rolsky

On Mon, 24 Sep 2001, Michael G Schwern wrote:

> On Mon, Sep 24, 2001 at 06:42:55PM -0500, Dave Rolsky wrote:
> > +sub eval_ok (&$) {
> > +my ($code, $name) = @_;
> > +
> > +eval { $code->() };
> > +if ($@) {
> > +   ok( 0, "$name - $@" );
> > +} else {
> > +   ok( 1, $name );
> > +}
> > +}
>
> The unfortunate problem is this has adverse effects on any code in the
> block that uses caller().  I don't want tests to introduce
> side-effects.  Unfortunately, Sub::Uplevel doesn't work on anything
> before 5.6.0.
>
> However, you're not the first person that's wanted this.
>
> Maybe we can get rid of this problem with documentation.  I tend to
> use this idiom.
>
> eval { ...code... };
> is( $@, '' );

Yeah, except that doesn't print out $@ in case of failure.  If I'm
checking that no exception occurs I want to know what the exception is
when it happens.

I don't know that the caller() issue is a big deal.  Document it and then
for code where that's an issue (a small fraction at best, I'd think)
people will know not to use it.  Just cause it doesn't work for all
possible uses doesn't make it useless.


-dave

/*==
www.urth.org
We await the New Sun
==*/




Re: [PATCH] More Test::More stuff

2001-09-24 Thread Kirrily Robert

In perl.qa, you wrote:
>>
>> eval { ...code... };
>> is( $@, '' );
>
>Yeah, except that doesn't print out $@ in case of failure.  If I'm
>checking that no exception occurs I want to know what the exception is
>when it happens.

But it does!  It says something like:

not ok 23
# Failed test 1 (eval.t at line 69)
#  got: 'blah blah blah'
# expected: ''


K.

-- 
Kirrily 'Skud' Robert - [EMAIL PROTECTED] - http://infotrope.net/
"There are three degrees of being weird. There are: 1) Salvageably weird. 
2) Weird. 3) Irrevocably weird."  -- Carrie Fisher



Re: [PATCH] More Test::More stuff

2001-09-24 Thread Dave Rolsky

On Tue, 25 Sep 2001, Kirrily Robert wrote:

> But it does!  It says something like:
>
> not ok 23
> # Failed test 1 (eval.t at line 69)
> #  got: 'blah blah blah'
> # expected: ''

Oops, that's what I get for not actually trying it out.

I guess that's good enough, though I still like the eval_ok thing.  I
guess I can implement it easily enough just for the Alzabo tests.


-dave

/*==
www.urth.org
We await the New Sun
==*/




Re: %ENV not tainted! (was Re: What tests are failing on VMS?)

2001-09-24 Thread Craig A. Berry

At 11:59 AM 9/24/2001 -0400, Dan Sugalski wrote:
>At 11:23 PM 9/23/2001 -0500, Craig A. Berry wrote:
>>Basically we're pre-loading a hash when you use "keys" or "values" on
>>%ENV, and if I understand this right, hash elements are not
>>full-blown scalars and thus do not have tainting bits.  Getting an
>>individual element from %ENV, on the other hand, never involves a
>>real hash since we just call getenv() or moral equivalent and return
>>a single (tainted) scalar value.  The code where this is implemented
>>in vms/vms.c is pretty twisty stuff and I don't quite have a good
>>enough grasp of it yet to be sure this is right or know what to do
>>about it.
>
>I think the ultimate issue is that %ENV elements fetched from trusted 
>sources (Like the SYSTEM or CLUSTER mode logicals) are considered untainted, 
>while the process-level stuff is tainted. Seemed that way the last time I 
>dove through the twisty mazes, but I might've misread things.

Well, my previous theory is full of it since there is code in hv.c to taint 
keys and values retrieved from the pre-loaded %ENV hash.  Here's an example 
from hv_fetch():

#ifdef DYNAMIC_ENV_FETCH  /* %ENV lookup?  If so, try to fetch the value now */
if (SvRMAGICAL((SV*)hv) && mg_find((SV*)hv, PERL_MAGIC_env)) {
unsigned long len;
char *env = PerlEnv_ENVgetenv_len(key,&len);
if (env) {
sv = newSVpvn(env,len);
SvTAINTED_on(sv);
if (key != keysave)
Safefree(key);
return hv_store(hv,key,klen,sv,hash);
}
}
#endif

I think Dan may be onto something though.  It seems that not any arbitrary 
element of the keys or values of %ENV is guaranteed to be tainted since some 
of them are and some of them aren't, and that's by design.  However, this 
does not mean all is well.  On the same system with the same environment, I 
see this with Perl 5.5.3:

$  perl -"Twle" "my $foo = (values %ENV)[-1];  open(FILE, qq{>$foo})"
Name "main::FILE" used only once: possible typo at -e line 1.
Insecure dependency in open while running with -T switch at -e line 1.
%SYSTEM-F-ABORT, abort

but with 5.6.1 there is no taint warning running the identical code.  Sigh.  
More dredging in the code and the archives to figure out how this is 
supposed to work and what got broken.






Re: %ENV not tainted! (was Re: What tests are failing on VMS?)

2001-09-24 Thread Craig A. Berry

At 5:04 PM -0700 9/24/01, Brad Hughes wrote:
>"Craig A. Berry" wrote:
>[...]
> > $  perl -"Twle" "my $foo = (values %ENV)[-1];  open(FILE, qq{>$foo})"
>> Name "main::FILE" used only once: possible typo at -e line 1.
>> Insecure dependency in open while running with -T switch at -e line 1.
>> %SYSTEM-F-ABORT, abort
>>
>> but with 5.6.1 there is no taint warning running the identical code.  Sigh.
>> More dredging in the code and the archives to figure out how this is
>> supposed to work and what got broken.
>
>Are both PERLSHR.EXEs on the same machine?  And if so, might
>one be INSTALLed with privs?

Interesting thought, but no, nothing's installed as a known image.
I've also reproduced the same behavior on a different machine.
-- 

Craig A. Berry  
mailto:[EMAIL PROTECTED]

"Literary critics usually know what they're
talking about. Even if they're wrong."
-- Perl creator Larry Wall



Re: %ENV not tainted! (was Re: What tests are failing on VMS?)

2001-09-24 Thread Brad Hughes

"Craig A. Berry" wrote:
[...]
> $  perl -"Twle" "my $foo = (values %ENV)[-1];  open(FILE, qq{>$foo})"
> Name "main::FILE" used only once: possible typo at -e line 1.
> Insecure dependency in open while running with -T switch at -e line 1.
> %SYSTEM-F-ABORT, abort
> 
> but with 5.6.1 there is no taint warning running the identical code.  Sigh.
> More dredging in the code and the archives to figure out how this is
> supposed to work and what got broken.

Are both PERLSHR.EXEs on the same machine?  And if so, might
one be INSTALLed with privs?

Brad



Re: %ENV not tainted! (was Re: What tests are failing on VMS?)

2001-09-24 Thread Dan Sugalski

At 11:23 PM 9/23/2001 -0500, Craig A. Berry wrote:
>Basically we're pre-loading a hash when you use "keys" or "values" on
>%ENV, and if I understand this right, hash elements are not
>full-blown scalars and thus do not have tainting bits.  Getting an
>individual element from %ENV, on the other hand, never involves a
>real hash since we just call getenv() or moral equivalent and return
>a single (tainted) scalar value.  The code where this is implemented
>in vms/vms.c is pretty twisty stuff and I don't quite have a good
>enough grasp of it yet to be sure this is right or know what to do
>about it.

I think the ultimate issue is that %ENV elements fetched from trusted 
sources (Like the SYSTEM or CLUSTER mode logicals) are considered 
untainted, while the process-level stuff is tainted. Seemed that way the 
last time I dove through the twisty mazes, but I might've misread things.

Dan

--"it's like this"---
Dan Sugalski  even samurai
[EMAIL PROTECTED] have teddy bears and even
  teddy bears get drunk




Re: The problem of test.pl

2001-09-24 Thread Tim Jenness

On Sun, 23 Sep 2001, Michael G Schwern wrote:

>
> Alter h2xs and ExtUtils::ModuleMaker to make the stub test be t/Foo.t
> instead of test.pl.
>

I believe h2xs does this already in bleadperl.

-- 
Tim Jenness
JAC software
http://www.jach.hawaii.edu/~timj





CPAN::Test

2001-09-24 Thread Tony Bowden


I've raised this problem with cpan-testers before, to exactly zero
response, but if we're going to start blasting them with lots and lots
of automated messages, it's probably time to again:

cpan-testers does not currently list a PASS/FAIL against a given version
of perl on search.cpan.org - it only lists platforms...

I suspect, (with zero evidence beyond personal), that this is the only
place that the vast majority of people see these results.

Especially with the way Schwern is running his against quite a
few versions at a time, this really needs to be more apparent from
search.cpan.org...

Tony










Re: Untested libraries update

2001-09-24 Thread H . Merijn Brand

On Sat 22 Sep 2001 00:50, Michael G Schwern <[EMAIL PROTECTED]> wrote:
> However, that's a big job to get right and we'll do it later.  Right
> now, stick to the cleanups and adding coverage.  It also wouldn't hurt
> to start going through old open perlbug entries.

A lead to find bugs that are already solved is searching for threads that have
"Thanks, applied" in there (notably from Jarkko)

-- 
H.Merijn BrandAmsterdam Perl Mongers (http://www.amsterdam.pm.org/)
using perl-5.6.1, 5.7.1 & 629 on HP-UX 10.20 & 11.00, AIX 4.2, AIX 4.3,
  WinNT 4, Win2K pro & WinCE 2.11.  Smoking perl CORE: [EMAIL PROTECTED]
http:[EMAIL PROTECTED]/   [EMAIL PROTECTED]
send smoke reports to: [EMAIL PROTECTED], QA: http://qa.perl.org




[PATCH] Test::More isa_ok function

2001-09-24 Thread Dave Rolsky

The patch below allows you to supply your own test name for the isa_ok
function (I find the default insufficiently descriptive).  I'd like to do
the same for can_ok but I don't think that could be done without breaking
backwards compatibility.

-dave


--- More.t~ Wed Sep  5 19:23:24 2001
+++ More.t  Mon Sep 24 18:24:15 2001
@@ -1,4 +1,4 @@
-use Test::More tests => 22;
+use Test::More tests => 23;

 use_ok('Text::Soundex');
 require_ok('Test::More');
@@ -20,6 +20,7 @@
can_ok pass fail eq_array eq_hash
eq_set));

 isa_ok(bless([], "Foo"), "Foo");
+isa_ok(bless([], "Foo"), "Foo", "Optional description to isa_ok");


--- More.pm~Tue Sep 18 16:54:50 2001
+++ More.pm Mon Sep 24 18:25:45 2001
@@ -447,7 +447,7 @@

 =item B

-  isa_ok($object, $class);
+  isa_ok($object, $class, $optional_name);

 Checks to see if the given $object->isa($class).  Also checks to make
 sure the object was defined in the first place.  Handy for this sort
@@ -465,11 +465,11 @@

 =cut

-sub isa_ok ($$) {
-my($object, $class) = @_;
+sub isa_ok ($$;$) {
+my($object, $class, $name) = @_;

 my $diag;
-my $name = "object->isa('$class')";
+$name ||= "object->isa('$class')";
 if( !defined $object ) {
 $diag = "The object isn't defined";
 }





Re: [PATCH] Test::More isa_ok function

2001-09-24 Thread Michael G Schwern

On Mon, Sep 24, 2001 at 06:23:58PM -0500, Dave Rolsky wrote:
> The patch below allows you to supply your own test name for the isa_ok
> function (I find the default insufficiently descriptive).  I'd like to do
> the same for can_ok but I don't think that could be done without breaking
> backwards compatibility.

What sort of names do you tend to throw in there?


-- 

Michael G. Schwern   <[EMAIL PROTECTED]>http://www.pobox.com/~schwern/
Perl6 Quality Assurance <[EMAIL PROTECTED]>   Kwalitee Is Job One
"None of our men are "experts."... because no one ever considers
himself expert if he really knows his job."  
-- From Henry Ford Sr., "My Life and Work," p. 86 (1922): 



Re: [PATCH] More Test::More stuff

2001-09-24 Thread Michael G Schwern

On Mon, Sep 24, 2001 at 06:42:55PM -0500, Dave Rolsky wrote:
> +sub eval_ok (&$) {
> +my ($code, $name) = @_;
> +
> +eval { $code->() };
> +if ($@) {
> + ok( 0, "$name - $@" );
> +} else {
> + ok( 1, $name );
> +}
> +}

The unfortunate problem is this has adverse effects on any code in the
block that uses caller().  I don't want tests to introduce
side-effects.  Unfortunately, Sub::Uplevel doesn't work on anything
before 5.6.0.

However, you're not the first person that's wanted this.

Maybe we can get rid of this problem with documentation.  I tend to
use this idiom.

eval { ...code... };
is( $@, '' );


-- 

Michael G. Schwern   <[EMAIL PROTECTED]>http://www.pobox.com/~schwern/
Perl6 Quality Assurance <[EMAIL PROTECTED]>   Kwalitee Is Job One
The eye opening delightful morning taste of expired cheese bits in sour milk!



[PATCH] More Test::More stuff

2001-09-24 Thread Dave Rolsky

Ok, forget the last patch.  This one incorporates that plus more.

This one also adds an eval_ok function.  The idea here is that sometimes
you simply want to try something to see if it works or not.  If it fails
it will append the error ($@) after the name of the test.

The reason for these patches is that I'm trying to use Test::More for
Alzabo and these are some changes that would make it more useful for me.

-dave


--- More.t.old  Mon Sep 24 18:35:39 2001
+++ More.t  Mon Sep 24 18:39:35 2001
@@ -1,4 +1,4 @@
-use Test::More tests => 22;
+use Test::More tests => 25;

 use_ok('Text::Soundex');
 require_ok('Test::More');
@@ -20,7 +20,10 @@
can_ok pass fail eq_array eq_hash
eq_set));

 isa_ok(bless([], "Foo"), "Foo");
+isa_ok(bless([], "Foo"), "Foo", "Optional description to isa_ok");

+eval_ok( sub { 1 }, "eval_ok 1" );
+eval_ok { 1 } "eval_ok 2";

 pass('pass() passed');

--- More.pm.old Mon Sep 24 18:35:27 2001
+++ More.pm Mon Sep 24 18:39:14 2001
@@ -25,6 +25,7 @@
  $TODO
  plan
  can_ok  isa_ok
+ eval_ok
 );


@@ -447,7 +448,7 @@

 =item B

-  isa_ok($object, $class);
+  isa_ok($object, $class, $optional_name);

 Checks to see if the given $object->isa($class).  Also checks to make
 sure the object was defined in the first place.  Handy for this sort
@@ -465,11 +466,11 @@

 =cut

-sub isa_ok ($$) {
-my($object, $class) = @_;
+sub isa_ok ($$;$) {
+my($object, $class, $name) = @_;

 my $diag;
-my $name = "object->isa('$class')";
+$name ||= "object->isa('$class')";
 if( !defined $object ) {
 $diag = "The object isn't defined";
 }
@@ -491,6 +492,35 @@
 }
 }

+=item B
+
+  eval_ok( sub { code ... }, $name );
+
+or
+
+  eval_ok { code ... } $name;
+
+Checks to see that a code block can be called in an C without
+throwing an exception.
+
+If it fails it will print the exception after the name as part of the
+test status.
+
+This is useful if you are calling a block of code simply to make sure
+it doesn't die.
+
+=cut
+
+sub eval_ok (&$) {
+my ($code, $name) = @_;
+
+eval { $code->() };
+if ($@) {
+   ok( 0, "$name - $@" );
+} else {
+   ok( 1, $name );
+}
+}




AutoSplit.t Patch (was Re: [PATCH)

2001-09-24 Thread chromatic

In article <[EMAIL PROTECTED]>, "Nicholas Clark"
<[EMAIL PROTECTED]> wrote:

> I hope this patch works. The one without MANIFEST did.
 
Here's a patch to the patch that ties a filehandle and removes the spawning.  I
had to tweak one little regex and add a chomp to get things to work.

p5p's trimmed from this followup.  Saying "REPATCH" seems a little rude.  
That's an impressive test:  AutoSplit is scary.

-- c

--- lib/~AutoSplit.tMon Sep 24 21:05:59 2001
+++ lib/AutoSplit.t Mon Sep 24 21:05:01 2001
@@ -4,19 +4,16 @@
 # work.
 
 my $incdir;
-my $lib = '"-I../lib"'; # ok on unix, nt, The extra \" are for VMS
 BEGIN {
 chdir 't' if -d 't';
 if ($^O eq 'MacOS') {
$incdir = ":auto-$$";
-$lib = '-x -I::lib:'; # -x overcomes MPW $Config{startperl} anomaly
 } else {
$incdir = "auto-$$";
 }
 @INC = $incdir;
 push @INC, '../lib';
 }
-my $runperl = "$^X $lib";
 
 use warnings;
 use strict;
@@ -24,8 +21,7 @@
 use File::Spec;
 use File::Find;
 
-require AutoSplit; # Run time. Check it compiles.
-ok (1, "AutoSplit loaded");
+require_ok('AutoSplit');
 
 END {
 use File::Path;
@@ -45,6 +41,7 @@
   close DATA;
 }
 
+my $out = tie *OUT, 'TieOut';
 sub split_a_file {
   my $contents = shift;
   my $file = $_[0];
@@ -54,15 +51,10 @@
 close FILE or die "Can't close $file: $!";
   }
 
-  # Assumption: no characters in arguments need escaping from the shell or perl
-  my $com = qq($runperl -e "use AutoSplit; autosplit (qw(@_))");
-  print "# $com\n";
-  # There may be a way to capture STDOUT without spawning a child process, but
-  # it's probably worthwhile spawning, as it ensures that nothing in AutoSplit
-  # can load functions from split modules into this perl.
-  my $output = `$com`;
-  warn "Exit status $? from running: >>$com<<" if $?;
-  return $output;
+  my $orig = select(OUT);
+  AutoSplit::autosplit(@_);
+  select($orig);
+  return $out->read();
 }
 
 my $i = 0;
@@ -79,10 +71,10 @@
| \#(?!\#)  # or a # character not followed by #
| (?