Job storage and restoration

This commit is contained in:
Ryan Voots 2017-03-30 01:33:35 -04:00
parent d532aba267
commit c7afd53f81
3 changed files with 47 additions and 18 deletions

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
cache.stor
*.swp
logs/*.log
*.stor

View file

@ -50,12 +50,18 @@ sub test_module {
print ">>>>Module $module failed to build without UNSAFE INC\n";
open(my $fh, ">", "logs/${module}_incfailure.log");
print $fh $noincout;
return "inc failed";
} else {
print "<<<<Module $module fails to build entirely\n";
open(my $fh, ">", "logs/${module}_genfailure.log");
print $fh $incout;
return "gen failed";
}
}
return "success";
}

58
run.pl
View file

@ -10,18 +10,21 @@ use warnings;
use Data::Dumper;
use Getopt::Long;
use List::Util qw/uniq/;
use Storable;
use Module;
use CpanFile;
use TestCpanInc;
our $opt_cpanfile;
our $opt_module;
our $opt_help;
my $opt_cpanfile;
my $opt_module;
my $opt_help;
my $opt_jobstor='';
GetOptions ("module=s" => \$opt_module,
"cpanfile=s" => \$opt_cpanfile, # string
"perlbrew_env=s" => \$TestCpanInc::perlbrew_env,
"jobstor=s" => \$opt_jobstor,
"help" => \$opt_help); # flagV
if ((!$opt_module && !$opt_cpanfile) || ($opt_module && $opt_cpanfile) || $opt_help) {
@ -32,26 +35,45 @@ if ((!$opt_module && !$opt_cpanfile) || ($opt_module && $opt_cpanfile) || $opt_h
$|++;
my @mods_to_test = ($opt_module);
if ($opt_cpanfile) {
# TODO read cpanfile, via do/require
cpanfile::__parse_file($opt_cpanfile);
@mods_to_test = @cpanfile::mods;
}
my @modules;
my %jobstatus;
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 TestCpanInc::dep_order($mod);
if (!-e $opt_jobstor) {
my @mods_to_test = ($opt_module);
if ($opt_cpanfile) {
# TODO read cpanfile, via do/require
cpanfile::__parse_file($opt_cpanfile);
@mods_to_test = @cpanfile::mods;
}
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 TestCpanInc::dep_order($mod);
}
print "\n";
@modules = uniq(@modules);
} else {
my $data = retrieve($opt_jobstor);
@modules = $data->{modules}->@*;
%jobstatus = $data->{jobstatus}->%*;
}
print "\n";
@modules = uniq(@modules);
sub __save_cache {
if ($opt_jobstor) {
store {modules => \@modules, jobstatus => \%jobstatus}, $opt_jobstor;
}
};
END {__save_cache};
for my $mod (@modules) {
print "Testing $mod\n";
TestCpanInc::test_module($mod);
unless ($jobstatus{$mod}{tested}) {
my $status = TestCpanInc::test_module($mod);
$jobstatus{$mod}{tested} = 1;
$jobstatus{$mod}{status} = $status;
__save_cache;
}
}