File: test_extract

package info (click to toggle)
spamassassin 3.1.7-2
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 5,376 kB
  • ctags: 2,123
  • sloc: perl: 39,706; ansic: 3,133; sh: 1,344; sql: 170; makefile: 168
file content (40 lines) | stat: -rwxr-xr-x 713 bytes parent folder | download | duplicates (3)
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";