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 cache.stor
*.swp *.swp
logs/*.log logs/*.log
*.stor

View file

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

58
run.pl
View file

@ -10,18 +10,21 @@ use warnings;
use Data::Dumper; use Data::Dumper;
use Getopt::Long; use Getopt::Long;
use List::Util qw/uniq/; use List::Util qw/uniq/;
use Storable;
use Module; use Module;
use CpanFile; use CpanFile;
use TestCpanInc; use TestCpanInc;
our $opt_cpanfile; my $opt_cpanfile;
our $opt_module; my $opt_module;
our $opt_help; my $opt_help;
my $opt_jobstor='';
GetOptions ("module=s" => \$opt_module, GetOptions ("module=s" => \$opt_module,
"cpanfile=s" => \$opt_cpanfile, # string "cpanfile=s" => \$opt_cpanfile, # string
"perlbrew_env=s" => \$TestCpanInc::perlbrew_env, "perlbrew_env=s" => \$TestCpanInc::perlbrew_env,
"jobstor=s" => \$opt_jobstor,
"help" => \$opt_help); # flagV "help" => \$opt_help); # flagV
if ((!$opt_module && !$opt_cpanfile) || ($opt_module && $opt_cpanfile) || $opt_help) { 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 @modules;
my %jobstatus;
print "Building dep list sorry, this'll take a while\n"; if (!-e $opt_jobstor) {
for my $mtt (@mods_to_test) { my @mods_to_test = ($opt_module);
my $mod = Module->new_module($mtt);
push @modules, map {$_->name} uniq TestCpanInc::dep_order($mod); 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"; sub __save_cache {
@modules = uniq(@modules); if ($opt_jobstor) {
store {modules => \@modules, jobstatus => \%jobstatus}, $opt_jobstor;
}
};
END {__save_cache};
for my $mod (@modules) { for my $mod (@modules) {
print "Testing $mod\n"; 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;
}
} }