From e01ff7f9c01afb03cb784256313970441d2c05cc Mon Sep 17 00:00:00 2001 From: Ryan Voots Date: Mon, 27 Mar 2017 20:27:39 -0400 Subject: [PATCH] Prelim options, and readme --- README.md | 13 ++++++++++++ test.pl => run.pl | 53 +++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 57 insertions(+), 9 deletions(-) create mode 100644 README.md rename test.pl => run.pl (68%) diff --git a/README.md b/README.md new file mode 100644 index 0000000..46f1fc8 --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +This is a simple hacky script that uses perlbrew and cpanm to test modules against ```perl $ENV{PERL_USE_UNSAFE_INC}``` to see if they fail. It does this by re-implementing the dependency search for the modules. + +This script is inteded to be used to test if your current project or module needs '.' in @INC. I've built it towards that goal for perlbot and it's eval so I can file bugs with all relavent modules. + +To test, i recommend installing blead via perlbrew. ```perlbrew install blead``` + +it will litter some files: + modcache.stor + logs/*.log + +these can be removed after you're done, but keeping the .stor file means that it won't re-fetch dependency lists off cpan. + +The logs are failure logs, *_incfailure.log are ones that failed due to @INC, and *_genfailure.log are ones that failed due to some other kind of problem (missing library, etc.) diff --git a/test.pl b/run.pl similarity index 68% rename from test.pl rename to run.pl index 7ddbfc5..3a48153 100755 --- a/test.pl +++ b/run.pl @@ -74,12 +74,33 @@ sub print_deps { } } +package main; use strict; use autodie; use warnings; use Data::Dumper; use List::Util qw/uniq/; use IPC::Run qw/run/; +use Getopt::Long; + +our $opt_perlbrew_env='blead'; +our $opt_module; +our $opt_cpanfile; +our $opt_help; + +GetOptions ("module=s" => \$opt_module, + "cpanfile=s" => \$opt_cpanfile, # string + "perlbrew_env=s" => \$opt_perlbrew_env, + "help" => \$opt_help); # flagV + +if ((!$opt_module && !$opt_cpanfile) || ($opt_module && $opt_cpanfile) || $opt_help) { + usage(); exit(1); +} + +sub usage { + print "Call with either --cpanfile xor --module to specify what to test.\n", + "Use --perlbrew_env to specify which perl install to use, defaults to blead\n"; +} sub dep_order { my $module = shift; @@ -100,7 +121,7 @@ sub run_cpanm { my ($module, $incstatus) = @_; $ENV{PERL_USE_UNSAFE_INC} = !!$incstatus; - my @cmd = (qw/perlbrew exec --with perlbot-inctest cpanm --reinstall --verbose/, $module); + my @cmd = (qw/perlbrew exec --with/, $opt_perlbrew_env, qw/cpanm --reinstall --verbose/, $module); my $out; run \@cmd, '>&', \$out; @@ -130,15 +151,29 @@ sub test_module { } } -$|++; -print "Init\n"; +sub main { + $|++; -my $foo = Module->new_module('Moose'); + my @mods_to_test = ($opt_module); -print "Building dep list\n"; -my @modules = map {$_->name} uniq dep_order($foo); + if ($opt_cpanfile) { + # TODO read cpanfile, via do/require + } -for my $mod (@modules) { - print "Testing $mod\n"; - test_module($mod); + my @modules; + + print "Building dep list sorry, this'll take a while\n"; + for my $mtt (@mods_to_test) { + my $mod = Module->new_module($mtt); + push @modules, map {$_->name} uniq dep_order($mod); + } + + @modules = uniq(@modules); + + for my $mod (@modules) { + print "Testing $mod\n"; + test_module($mod); + } } + +main();