Guest User

Untitled

a guest
Feb 19th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.42 KB | None | 0 0
  1.  
  2. #!/usr/bin/perl -w
  3. use strict;
  4. use CGI qw/:standard *table start_ul/;
  5. use CGI::Carp qw(fatalsToBrowser);
  6. use POSIX qw(strftime);
  7.  
  8. use lib ".";
  9. use Autobuilder;
  10.  
  11. my @branches = ();
  12. my %revs = ();
  13.  
  14.  
  15. sub load_revcache()
  16. {
  17. open my $fh, "<revcache"
  18. or return; # try to survive without it, then
  19. my $branch;
  20. my @list;
  21. while (<$fh>) {
  22. chomp;
  23. if (/^\:(\S+)/) {
  24. my $newbranch = $1;
  25. if ($branch) {
  26. $revs{$branch} = join("\n", @list);
  27. }
  28. push @branches, $newbranch;
  29. $branch = $newbranch;
  30. @list = ();
  31. } else {
  32. push @list, $_;
  33. }
  34. }
  35. if ($branch) {
  36. $revs{$branch} = join("\n", @list);
  37. }
  38. close $fh;
  39. }
  40. load_revcache();
  41.  
  42. my $currently_doing = (-f '.doing') && stripwhite(catfile(".doing")) || "";
  43.  
  44. sub run_cmd(@)
  45. {
  46. my @cmdline = @_;
  47.  
  48. open(my $fh, "-|", @cmdline)
  49. or die("Can't run $cmdline[0]: $!\n");
  50. my @out = <$fh>;
  51. chomp @out;
  52. close $fh;
  53. return @out;
  54. }
  55.  
  56. sub revs_for_branch($)
  57. {
  58. my $branch = shift;
  59. if (-x '../revlist.sh') {
  60. return run_cmd("../revlist.sh", $branch);
  61. } else {
  62. return split("\n", $revs{$branch});
  63. }
  64. }
  65.  
  66. sub list_branches()
  67. {
  68. if (-x '../branches.sh') {
  69. return run_cmd("../branches.sh");
  70. } else {
  71. return @branches;
  72. }
  73. }
  74.  
  75. print header, start_html(
  76. -title => "Autobuilder results",
  77. -style => {-src => "index.css"}
  78. );
  79.  
  80. print Link({-rel=>"alternate", -title=>"Autobuilder results",
  81. -href=>"rss.cgi", -type=>"application/rss+xml"});
  82.  
  83. print h1("Autobuilder results");
  84.  
  85. print start_table();
  86. print Tr(th("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"),
  87. th("Result"), th("Commit"), th("Details"));
  88.  
  89. for my $branch (list_branches()) {
  90. my $branchprint = $branch;
  91.  
  92. our $last_was_pending = 0;
  93. our $print_pending = 1;
  94.  
  95. sub do_pending_dots()
  96. {
  97. if ($last_was_pending > $print_pending) {
  98. $last_was_pending -= $print_pending;
  99. $print_pending = 0;
  100. print Tr(td($branchprint),
  101. td("...$last_was_pending..."), td(""), td(""));
  102. $branchprint = "";
  103. }
  104. $last_was_pending = 0;
  105. }
  106.  
  107. foreach my $rev (revs_for_branch($branch)) {
  108. my ($commit, $comment) = split(" ", $rev, 2);
  109.  
  110. my $filename;
  111. my $failed;
  112. my $logcgi = "log.cgi?log=$commit";
  113.  
  114. if (-f "pass/$commit") {
  115. $filename = "pass/$commit";
  116. $failed = 0;
  117. } elsif (-f "fail/$commit") {
  118. $filename = "fail/$commit";
  119. $failed = 1;
  120. } elsif ($commit eq $currently_doing) {
  121. do_pending_dots();
  122. print Tr(td($branchprint),
  123. td({bgcolor=>'#ffff66'}, "BUILDING"),
  124. td(shorten($commit, 7)),
  125. td($comment));
  126. $branchprint = "";
  127. next;
  128. } elsif ($last_was_pending == 0 && $print_pending) {
  129. print Tr(td($branchprint),
  130. td("(Pending)"),
  131. td(shorten($commit, 7)),
  132. td($comment));
  133. $last_was_pending = 1;
  134. $branchprint = "";
  135. next;
  136. } else {
  137. $last_was_pending++;
  138. next;
  139. }
  140.  
  141. do_pending_dots();
  142.  
  143. my $codestr = ($failed ? "Errors" :
  144. (find_errors($filename) ? "Warnings" : "ok"));
  145. print Tr(td($branchprint),
  146. td({bgcolor=>($failed ? "#ff6666" : "#66ff66")},
  147. $failed ? b("FAIL") : "ok"),
  148. td(shorten($commit, 7)),
  149. td(a({-href=>$logcgi}, "$codestr") . " $comment"));
  150. $branchprint = "";
  151. }
  152.  
  153. do_pending_dots();
  154.  
  155. if (!$branchprint) {
  156. print Tr(td({colspan=>4}, hr));
  157. }
  158. }
  159.  
  160. print end_table();
  161. exit 0;
Add Comment
Please, Sign In to add comment