Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Once one of your modules on CPAN is used/required by another module on CPAN not under your own control, it might be a good idea to test all those modules with your new code to verify you didn't break anything.

The first thing you want to check is the fact that your module actually is used by something else. We are in luck here, as that is already done for us. For this example, I'll continue with a short and simple module (Data::Peek) as the logs are much shorter, but the process is exactly the same as for a module that is used widely, as DBI or Text::CSV_XS, for which I wrote this to begin with.

Before you want to check other modules, of course you check your own suite:

$ perl Makefile.PL $ make test : All tests successful. : Result: PASS $ make distcheck

So the module passes, but does it still pass in the modules that require it? To test that, we first need to see what that lists consists of. CPANTS has that list readily available for each module on CPAN. We can use the internals of CPAN to fetch and test that list.

$ cat sandbox/ #!/usr/bin/perl use 5.16.2; use warnings; use LWP; use LWP::UserAgent; use HTML::TreeBuilder; use CPAN; use Capture::Tiny qw( :all ); use Test::More; my $tm = "Data-Peek"; # The module I want to check my %tm = map { $_ => 1 } qw( ); $| = 1; $ENV{AUTOMATED_TESTING} = 1; # Skip all dists that # - are FAIL but not due to Data::Peek # - that require interaction (not dealt with in distroprefs) # - are not proper dists (cannot use CPAN's ->test) # - require external connections or special devices my %skip = map { $_ => 1 } qw( GSM-Gnokii ); my $url = "$tm/used_by"; my $ua = LWP::UserAgent->new (agent => "Opera/12.15"); my $rsp = $ua->request (HTTP::Request->new (GET => $url)); $rsp->is_success or die "get failed: ", $rsp->status_line, "\n" +; my $tree = HTML::TreeBuilder->new; $tree->parse_content ($rsp->content); foreach my $a ($tree->look_down (_tag => "a", href => qr{/dist/})) { (my $h = $a->attr ("href")) =~ s{.*dist/}{}; exists $skip{$h} || $h =~ m{^( $tm (?: $ | / ) | Task- )\b}x and n +ext; (my $m = $h) =~ s/-/::/g; $tm{$m} = 1; } my %rslt; foreach my $m (sort keys %tm) { my $mod = CPAN::Shell->expand ("Module", "/$m/") or next; # diag "$m ... "; $rslt{$m} = [ [], capture { $mod->test } ]; $rslt{$m}[0] = [ $?, $!, $@ ]; is ($?, 0, $m); } done_testing;

That fetches the list of modules that require Data::Peek, check if any of those is recognized by CPAN, for each makes a call to CPAN's test function/method, catches all the output with Capture::Tiny (and ignores all output for now) and use the return code available in $? to decide FAIL or success:

$ prove -vwb sandbox/ sandbox/ .. Reading '/home/merijn/.cpan/Metadata' Database was generated on Mon, 03 Mar 2014 14:17:02 GMT CPAN: YAML loaded ok (v0.90) Reading 3 yaml files from /home/merijn/.cpan/build/ ..........................DONE Restored the state of 1 (in 0.0431 secs) ok 1 - App::tkiv ok 2 - Geo::KML ok 3 - Spreadsheet::Read 1..3 ok All tests successful. Files=1, Tests=3, 13 wallclock secs ( 0.02 usr 0.00 sys + 10.29 cusr + 0.60 csys = 10.91 CPU) Result: PASS $

Running this for Text::CSV_XS resulted in 4 RT tickets with patches on other modules that failed depending on Text::CSV_XS where they did either something wrong or were not yet up to date with new(er) code.

If I find myself not forgetting to run this before I release a new module, I think I will prevent a lot of complaints later :)

Enjoy, Have FUN! H.Merijn

In reply to Will I break CPAN? by Tux

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (7)
    As of 2016-05-06 09:56 GMT
    Find Nodes?
      Voting Booth?