#!/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";

