new ticket from slaven
[andk-cpan-tools.git] / bin / dir-to-jifty.pl
blob0ad8ab464bf7e9c1bca22cd78aa62341d26a6536
1 #!/home/src/perl/repoperls/installed-perls/perl/pI3NUai/perl-5.8.0@32147/bin/perl
3 use strict;
4 use warnings;
5 use Cwd;
6 use File::Spec;
8 my $WD;
10 BEGIN {
11 $WD = Cwd::cwd;
12 chdir "/home/k/sources/pocpoc/SVN" or die "Could not chdir: $!"
15 use UNIVERSAL::require;
16 use Jifty::ClassLoader ();
17 BEGIN {
18 Jifty::Util->require or die $UNIVERSAL::require::ERROR;
19 my $root = Jifty::Util->app_root;
20 unshift @INC, "$root/lib" if ($root);
22 use Jifty;
23 my $cl = Jifty::ClassLoader->new (base => "Pocpoc");
24 $cl->require;
25 my $j = new Jifty; # sets up database connection and other stuff
27 # use FindBin ();
28 use XML::LibXML;
30 my $logdir = shift || die; # "$FindBin::Bin/../logs";
31 $logdir = "$WD/$logdir" unless File::Spec->file_name_is_absolute($logdir);
32 opendir my $dh, "$logdir" or die "cannot opendir '$logdir': $!";
34 my $p = XML::LibXML->new;
35 my $i = 0;
36 $|=1;
37 SESSION: for my $dirent (sort { $b cmp $a } readdir $dh) {
38 next if $dirent =~ /^\./;
39 my $abs = "$logdir/$dirent";
40 next unless $abs =~ /(?:^|\/)megainstall\.(\d+T\d+)\.d(?:\/|$)/;
41 my $starttime = $1;
42 opendir my $dh2, $abs or die "cannot opendir: '$abs': $!";
43 my($total,$failed);
44 $total = 0;
45 $failed = 0;
46 my @readdir2 = sort grep { /\.xml$/ } readdir $dh2;
47 print "\@";
48 my $s = Pocpoc::Model::Session->new(handle => Jifty->handle);
49 TESTRUN: for my $i (0..$#readdir2) {
50 my $dirent2 = $readdir2[$i];
51 my $xfile = "$abs/$dirent2";
52 my $xml = $p->parse_file($xfile);
53 my($ok,$seq,$perl,$distro,$branch,$patchlevel);
54 $ok = $xml->findvalue("/distro/\@ok");
55 $seq = $xml->findvalue("/distro/\@seq") || 0;
56 $perl = $xml->findvalue("/distro/\@perl");
57 $distro = $xml->findvalue("/distro/\@distro");
58 my $d = Pocpoc::Model::Distro->new(handle => Jifty->handle);
59 ($branch,$patchlevel) = $perl =~ m|/installed-perls/(.*?)/p.*?/perl-5.*?@(\d+)|;
60 $total++;
61 $failed++ unless $ok eq "OK";
62 $s->load_or_create(
63 starttime => $starttime,
64 perl => $perl,
65 branch => $branch,
66 patchlevel => $patchlevel,
68 $d->load_or_create(
69 name => $distro,
71 if ($i == 0) {
72 my $total = $s->total || 0;
73 if ( $total == @readdir2 ) {
74 print "_";
75 next SESSION;
76 } else {
77 print "($dirent)";
80 print "+";
81 unless ($i % 64){
82 my $left = @readdir2 - $total;
83 print "($total/$left)";
85 my $t = Pocpoc::Model::Testrun->new(handle => Jifty->handle);
86 $t->load_or_create(
87 distro => $d,
88 testsession => $s,
90 $t->set_seq($seq);
91 $t->set_testresult($ok);
93 $s->set_failed($failed);
94 $s->set_total($total);
95 my $vtotal = $s->total;
96 unless ($vtotal == $total) {
97 die "Sanity check broke: total[$total]vtotal[$vtotal]";
99 my $vfailed = $s->failed;
100 unless ($vfailed == $failed) {
101 die "Sanity check broke: failed[$failed]vfailed[$vfailed]";
106 =pod
108 /usr/bin/perl -le 'use DBI; my $db = shift or die;my $dbh = DBI->connect("dbi:SQLite:dbname=$db","","") or die;my $sth = $dbh->prepare("select * from testruns");$sth->execute;while (my @row = $sth->fetchrow){ print "row[@row]";}' poce | head
109 row[1 /home/src/perl/cpan-sql-stuff/CPAN-SQLite/. 1 0 OK]
110 row[2 /home/src/perl/tk/SVN/. 1 0 OK]
111 row[3 ABH/XML-RSS-1.22.tar.gz 1 0 OK]
112 row[4 ABIGAIL/Regexp-Common-2.120.tar.gz 1 0 OK]
113 row[5 ABW/Class-Singleton-1.03.tar.gz 1 0 OK]
114 row[6 ACALPINI/Lingua-Stem-It-0.01.tar.gz 1 0 OK]
115 row[7 ADAMK/Algorithm-Dependency-1.102.tar.gz 1 0 OK]
116 row[8 ADAMK/AppConfig-1.64.tar.gz 1 0 OK]
117 row[9 ADAMK/Archive-Zip-1.18.tar.gz 1 0 OK]
118 row[10 ADAMK/CPAN-Inject-0.05.tar.gz 1 0 NOT OK]
120 ==cut