hi all... I've been working on something a bit and wanted to run it by people here to see if folks think it's a project worthy of persuing. basically the below bit from the README kinda sums it up for me - locally wrapping lots of routines is getting quite tedious (specifically sockets at the moment) and from the docs Hook::Lexwrap just seems to be way too much for testing.
so, the proposal is Test-Locally, which would provide something like this - a base class for people that wanted to wrap their own single subroutines (or groups of subroutines) simply and without a lot of fuss - some tools that make overriding subroutines easier, like a base READ implementation everyone can use - knowledge of some standard yet complex modules in the core distribution so that they didn't need to be wrapped by everyone who ends up wrapping them. and so on. at the moment, the implementation is pretty incomplete (only the base class is documented and only IO:: is implemented and tested) which is why I bring it up here - if people like the idea I'll tidy it up and probably put it on sourceforge so people can contribute implementations for their (least) favorite classes. if nobody cares I'll forget about CPAN. anyway, constructive feedback welcome. you can get the (incomplete) tarball here: http://perl.apache.org/~geoff/Test-Locally-0.01.tar.gz --Geoff from the README: "...here is an example drawn from real life... suppose you have a subroutine that opens a socket connection with a client, sends it some data, receives a response, and validates the response (all within the same Perl subroutine). overriding all the calls to the point where you can effectively fake the read so that it uses your test data you would need to do something like this { no warnings qw(redefine); local *IO::Socket::INET::new = sub { bless {}, 'IO::Socket' }; local *IO::Socket::connected = sub { 1 }; local *IO::Handle::syswrite = sub { }; local *IO::Handle::close = sub { }; local *IO::Handle::sysread = sub { generic READ of $data }; ... testing stuff ... } yucko. with Test::Locally that can be reduced to { my $local = Test::Locally::IO::Socket::INET->override ->new ->connected ->syswrite ->sysread($data) ->close; ... testing stuff ... } # IO::Socket::INET methods are restored when $local is destroyed or even less if you subclass Test::Locally::IO::Socket::INET and add, say, a C<fake_reads()> method that suits your specific purposes." http://perl.apache.org/~geoff/Test-Locally-0.01.tar.gz