#!/usr/bin/perl -w
#run weekly by cron

#define directories with TAP tests
my @testDirs = ('psLib', 'psModules', 'Nebulous-Server', 'Nebulous');

#delete modules with tap tests
system `rm -rf /data/ipp001.0/ippTests/tap/ipp/Nebulous`;

#delete Nebulous binaries
system `rm -rf /data/ipp001.0/ippTests/tap/usr/*`;

#check out new versions, build the tests
#run the tests and save output to file
#parse the output and mail the results to IPP-DEV
my $dir;
foreach $dir (@testDirs) {
    system `svn co http://svn.pan-starrs.ifa.hawaii.edu/repo/ipp/trunk/$dir /data/ipp001.0/ippTests/tap/ipp/$dir`;
    chdir "/data/ipp001.0/ippTests/tap/ipp/$dir";
    
    if ($dir =~ m/^Nebulous-Server$/) {
        system ("perl Build.PL --prefix=/data/ipp001.0/ippTests/tap/usr");
        system ("Build install");
        system ("Build test > /data/ipp001.0/ippTests/tap/summary");
        system ("/data/ipp001.0/ippTests/tap/mailTestResults.pl $dir");
        
    } elsif ($dir =~ m/^Nebulous$/) {
        chdir "/data/ipp001.0/ippTests/tap/ipp/$dir/nebclient";
        system ("autogen.sh --prefix=/data/ipp001.0/ippTests/tap/usr");
        system ("/usr/bin/make");
        chdir "/data/ipp001.0/ippTests/tap/ipp/$dir";
        system ("perl Build.PL --prefix=/data/ipp001.0/ippTests/tap/usr");
        system ("Build install");
        system ("Build test > /data/ipp001.0/ippTests/tap/summary");
        system ("/data/ipp001.0/ippTests/tap/mailTestResults.pl $dir");
        
    } else {
        system ("autogen.sh --enable-tests");
        system ("make");
        chdir "/data/ipp001.0/ippTests/tap/ipp/$dir/test";
        system ("./test.pl > /data/ipp001.0/ippTests/tap/out");
        system ("/data/ipp001.0/ippTests/tap/proveParser.pl");
        system ("/data/ipp001.0/ippTests/tap/mailTestResults.pl $dir");
    }
}

