Re: Some upcoming changes to Test::Builder

2002-10-15 Thread Michael G Schwern

On Tue, Oct 15, 2002 at 10:34:26AM +0100, Nicholas Clark wrote:
 On Mon, Oct 14, 2002 at 09:00:42PM -0400, Michael G Schwern wrote:
  5.8.0's threads are giving me serious headaches.  When 5.8.1 comes out I
  might drop support for 5.8.0's threads just so I can remove a large volume
  of work-around code.
 
 Leaving support for 5.005 threads in? I'm confused.

Test::Builder has never supported 5.005 threads.  At least, I haven't done
anything special to make it work.


 Or do you mean dropping all automatic threading support?

What I mean is in order to make Test::Builder work with 5.8.0's ithreads I
had to hack around a whole lot of bugs and write some really awful code.
Most of it having to do with automatic array/hash extensions not being
shared.  For example:

# 5.8.0 threads bug.  Shared arrays will not be auto-extended 
# by a slice.  Worse, we have to fill in every entry else
# we'll get an Invalid value for shared scalar error
for my $idx ($#Test_Results..$Expected_Tests-1) {
my %empty_result = ();
share(%empty_result);
$Test_Results[$idx] = \%empty_result
  unless defined $Test_Results[$idx];
}

That whole block is just a work around for a 5.8.0 ithreads bug.  There's
more like it to make Test::Builder work transparently with ithreads.  Here's
another:

my %result;
share(%result);
%result = (
'ok'  = 1,
actual_ok = 1,
name  = '',
type  = 'skip',
reason= $why,
);
$Test_Results[$Curr_Test-1] = \%result;

which was originally written:

$Test_Results[$Curr_Test-1] = {
'ok'  = 1,
actual_ok = 1,
name  = '',
type  = 'skip',
reason= $why,
};

and could not be written:

$Test_Results[$Curr_Test-1] = share {
'ok'  = 1,
actual_ok = 1,
name  = '',
type  = 'skip',
reason= $why,
};

because threads::shared::share() is broken when threads are disabled.

Really irritating stuff.  Every release since 0.45 has added more ithread
work arounds.

So when 5.8.1 comes out and ithreads work better I plan on dropping support
for 5.8.0's still broken ithreads like a hot potato so I can remove all that
hackery.  5.8.1's less buggy ithreads will be supported, hopefully with a
minimum of hackery.  Users will simply have to upgrade, which they really
should do anyway if they're using threads.


-- 

Michael G. Schwern   [EMAIL PROTECTED]http://www.pobox.com/~schwern/
Perl Quality Assurance  [EMAIL PROTECTED] Kwalitee Is Job One
I'm spanking my yacht.



Some upcoming changes to Test::Builder

2002-10-14 Thread Michael G Schwern

I'm working on Test::Builder 0.48 and here's some relatively major changes
I'm putting in.  Some advance warning and a chance for folks to convince me
otherwise.


* Test::Harness will no longer be optional.

Currently, the tests do not require a Test::Harness upgrade.  They simply
skip over anything that requries T::H 2.0.  This has caused a lot of
problems lately with botched and shadowed T::H installs and people
installing Test::More without realizing T::H wasn't really upgraded and
tests which have 'no_plan' not working.

The real reason I made the T::H upgrade optional was it made it easier to
test against older perls.  I could just run the test suite against, for
example, a clean 5.5.3 without having to dirty the installation by
installing T::H 2.0.  I've figured a way around this with MakeMaker hackery.

A future version of Test::Harness will include a post-install check to make
sure it actually got installed properly and isn't being shadowed, so it will
help the problem from that end.


* threads will no longer be loaded by default.

Currently, Test::Builder loads threads.pm if available.  It was done this
way because otherwise one would have to remember to load threads before
Test::More (or other T::B based module) in order for it to work properly.

Unfortunately, this makes it impossible to test unthreaded code with
Test::More when perl is built with threads as I recently found out while
trying to test threads::shared in its disabled state.  As I'm going for
maximum flexibility, and loading threads.pm by default makes a whole class
of tests impossible, threads.pm will no longer be loaded by default.

5.8.0's threads are giving me serious headaches.  When 5.8.1 comes out I
might drop support for 5.8.0's threads just so I can remove a large volume
of work-around code.


-- 

Michael G. Schwern   [EMAIL PROTECTED]http://www.pobox.com/~schwern/
Perl Quality Assurance  [EMAIL PROTECTED] Kwalitee Is Job One
List context isn't dangerous.  Misquoting Gibson is dangerous.
-- Ziggy