develooper Front page | perl.par | Postings from September 2008

RFC: Devel::TraceDeps

From:
Eric Wilhelm
Date:
September 14, 2008 02:29
Subject:
RFC: Devel::TraceDeps
Message ID:
200809140229.20155.ewilhelm@cpan.org
Hi all,

I finally got Devel::TraceDeps out onto CPAN with basic support for 
saving the results of a full test run and currently just the .pm files 
(not the XSLoader/DynaLoader bits.)

The idea for this came when I was a heavy PAR user and I realized that I 
was always running the test suite and *then* scanning all of the code 
that I had just run, yet still missing the runtime effects.

Note:  This is very much not a DWIM functionality like 'pp', but is 
intended to be just one step in an automated build process.

So, the basic scheme here is to hook into Perl's require()/use()/do() 
mechanisms and log anything that comes through.  Assuming that your 
test suite provides good coverage, this means you'll have a record of 
everything that your code actually runs:

  perl -MDevel::TraceDeps=tree -S prove -l -r t/
  ls tracedeps/

Those files have a log of each require per package, along with the file 
and line number from which the require originated (and whether it 
failed (e.g. from eval {require Something::Optional}.)

The analysis of the requirements tree can then take whatever form you 
like.  The tricky part about the scanning is that it cannot depend on 
any modules unless it is going to jump through hoops to remove the 
effect of those modules on the output (the classic metering problem of 
the meter messing with the results.)

You currently need to remove the 'tracedeps' directory manually if 
running a second time.

I could use some feedback on on the Devel::TraceDeps::Scan API (I still 
need to add a load method for an entire tree), as well as finding out 
where this falls down and fleshing-out the tests a bit.  Automated 
tests for the scan itself is a bit tricky, but the data format and 
the ::Scan API are decoupled enough that this could conceivably be a 
frontend for static scanning -- possibly even a replacement for 
Module::ScanDeps?

I think the DynaLoader and XSLoader bits are going to be a fairly 
straightforward hook into the watcher's destructor if anyone is feeling 
patchy ;-)

And yes, it has been a long time since I originally mentioned this, and 
no, I don't currently have a pressing need for it.  But now it is 
largely functional and on CPAN instead of halfway between my head and 
svn.

Thanks,
Eric
-- 
But as soon as you hear the Doppler shift dropping in pitch, you know
that they're probably going to miss your house, because if they were on
a collision course with your house, the pitch would stay the same until
impact. As I said, that one's subtle.
--Larry Wall
---------------------------------------------------
    http://scratchcomputing.com
---------------------------------------------------



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About