post-bugs-for-retired-tests   [plain text]


#!/usr/bin/perl

# CHANGEME!
my $USER = 'you@somewhere.org';
my $PASS = 'yourpassword';


open (TST, "<tests_to_go") or die "cannot read tests_to_go list";
while (<TST>) {
  chomp; push (@togo, $_);
}
close TST;

open (IN, "<freqs") or die "cannot read freqs";
while (<IN>) {
  chomp; /  (\S+)\s*$/ and $freq{$1} = $_;
}
close IN;

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
use HTTP::Cookies;
$ua = LWP::UserAgent->new;

$ua->cookie_jar(HTTP::Cookies->new(file => "lwpcookies.txt",
                                            autosave => 1));

my $lreq = POST 'http://bugzilla.spamassassin.org/query.cgi',
        [
          GoAheadAndLogIn => '1',
          Bugzilla_login => $USER,
          Bugzilla_password => $PASS,
          GoAheadAndLogIn => 'Login'
          ];
my $result = $ua->request($lreq)->as_string;

if ($result =~ /<a href=relogin.cgi>Log out<.a> \Q$USER\E/ ){
  print "logged in as $USER\n";
} else {
  die "cannot login as $USER";
}

foreach my $test (@togo) {
  my $grep = '';
  open (GREP, "grep $test ../rules/*.cf |");
  while (<GREP>) {
    s/^\S+://g;
    next if /^score/;
    next if /^#/;
    next if (/_$test/ || /${test}_/);
    $grep .= $_;
  }
  close GREP;

  my $DESC = "$test low-performing rule pruned";

  my $LONGDESC = "Removed $test from HEAD cvs.

hit frequencies:

OVERALL%   SPAM% NONSPAM%     S/O    RANK   SCORE  NAME
$freq{$test}

test code from all files in rules dir:

$grep

If you want to re-add this test to SpamAssassin, please follow
up this bug entry, improving the code until the S/O ratio
goes above 0.7 (or below 0.3 for nice tests).

(automated submission)
";

print ("-" x 75);
print "\nDesc: $DESC\n$LONGDESC\n\n";

  my $req = POST 'http://bugzilla.spamassassin.org/post_bug.cgi',
          [ reporter => 'jm@jmason.org',
            product => 'Spamassassin',
            version => 'current-CVS',
            component => 'Rules',
            rep_platform => 'Other',
            op_sys => 'other',
            priority => 'P4',
            bug_severity => 'trivial',
            assigned_to => '',
            bug_file_loc => 'http://',
            short_desc => $DESC,
            comment => $LONGDESC,
            form_name => 'enter_bug'
          ];

$result = $ua->request($req)->as_string;
#$result = "<H2>Bug 0 posted</H2>";

  if ($result =~ /<H2>Bug (\d+) posted<.H2>/) {
    print "created: bug $1\n";
  } else {
    warn "failed to file bug! see file 'failure' for details\n";
    open (O, ">failure"); print O $result; close O;
  }
}