Home > Net >  How do you test your Perl module to check if Makefile.PL declares all dependencies?
How do you test your Perl module to check if Makefile.PL declares all dependencies?

Time:08-09

I would like to write a t/00-check-deps.t module to find all dependencies in MyModule.pm and make sure they exist in Makefile.PL before release.

This way when I do make test before distributing to CPAN I will know that nothing was forgotten prior to publishing. I've looked at the ExtUtils suite, but I've not seen anything obvious that already solves this. It seems like a common issue people would want to solve.

How would you do this?

CodePudding user response:

Here is how I would do it. Thanks @ikegami for the scandeps hint:

find lib -name '*.pm' | xargs scandeps.pl -R | \
  perl -MJSON -le '
    undef $/; 
    %d=eval(<STDIN>);
    $j=JSON::from_json(`cat MYMETA.json`); 
    foreach (keys(%d)) {
      warn "Missing: $_ => $d{$_}\n" if !defined($j->{prereqs}{runtime}{requires}{$_}) 
    }
    '

prints:

Missing: Carp => 1.42
Missing: PDL::Constants => 0.02
Missing: Exporter => 5.72
Missing: constant => 1.33
Missing: PDL => 2.080
Missing: PDL::LinearAlgebra => 0.35
Missing: PDL::Ops => undef
  • Related