File: test_extract

package info (click to toggle)
spamassassin 4.0.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 25,724 kB
  • sloc: perl: 89,143; ansic: 5,193; sh: 3,737; javascript: 339; sql: 295; makefile: 209; python: 49
file content (40 lines) | stat: -rwxr-xr-x 713 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/perl -w

# Duncan Findlay

# Remove regression tests from the rules to a separate file, so they
# aren't included with the default config (somewhat useless!)

my $num_tests = 0;

my @files = <./*.cf>;

open (TESTS, ">> regression_tests.cf");

foreach my $file (@files) {
    if ($file =~ /regression_tests\.cf/) {
	next;
    }

    rename "$file", "$file.bak" or die "Can't rename: $!";
    open IN, "$file.bak";
    open OUT, ">>$file";
    
    while (<IN>) {
	if (/^test/) {
	    print TESTS $_;
	    $num_tests++;
	} else {
	    print OUT $_;
	}
    };
    close IN;
    close OUT;
    unlink "$file.bak" or die "Can't delete: $!";
        
}

close TESTS;

print "All done! $num_tests moved.\n";