Ignore:
Timestamp:
2013-06-14T20:17:29+12:00 (11 years ago)
Author:
ak19
Message:

Build scripts run via function again, as the function now calls system() instead of the run_and_print_cmd subroutine which called open() (since open() wasn't working with commands chained with bash -c). Also replaced STDOUT with STDERR for output to be seen as it is generated without buffering

File:
1 edited

Legend:

Unmodified
Added
Removed
  • other-projects/nightly-tasks/diffcol/trunk/task.pl

    r27628 r27629  
    6666#check key environment vars are set
    6767if(!defined $ENV{'UPLOAD_DIR'}) {
    68     print STDOUT "Please set a UPLOAD_DIR for the test in an environment.sh file\n";
     68    print STDERR "Please set a UPLOAD_DIR for the test in an environment.sh file\n";
    6969    #return 1;
    7070}
    7171if(!defined $ENV{'DATA_DIR'}) {
    72     print STDOUT "Please set a DATA_DIR for the test in an environment.sh file\n";
     72    print STDERR "Please set a DATA_DIR for the test in an environment.sh file\n";
    7373    #return 1;
    7474}
    7575if(!defined $ENV{'MONITOR_EMAIL'}) {
    76     print STDOUT "Please set a MONITOR_EMAIL for the test in an environment.sh file\n";
     76    print STDERR "Please set a MONITOR_EMAIL for the test in an environment.sh file\n";
    7777    #return 1;
    7878}
    7979
    8080if($ENV{'DATA_DIR'} eq "/") {
    81     print STDOUT "DATA_DIR should not be the fs root\n";
     81    print STDERR "DATA_DIR should not be the fs root\n";
    8282    #return 1;
    8383}
    8484
    85 print STDOUT "DATA_DIR: ".$ENV{'DATA_DIR'}."\n";
    86 print STDOUT "UPLOAD_DIR: ".$ENV{'UPLOAD_DIR'}."\n";
     85print STDERR "DATA_DIR: ".$ENV{'DATA_DIR'}."\n";
     86print STDERR "UPLOAD_DIR: ".$ENV{'UPLOAD_DIR'}."\n";
    8787
    8888#create an id for this test
     
    9494my $dateid="$year-$mon-$mday"; #my $dateid=($year+1900)."-".($mon+1)."-$mday";
    9595
    96 print STDOUT "Starting test '$dateid'\n";
     96print STDERR "Starting test '$dateid'\n";
    9797
    9898
     
    100100$ENV{'CLASSPATH'} = "";
    101101my $jar_lib_path = $ENV{'TASK_HOME'}.$sep."lib";
    102 ##print STDERR "@@@ $jar_lib_path\n";
    103102my @files = <$jar_lib_path/*.jar>; # /full/path/to/diffcol/lib/*jar
    104103foreach my $file (@files) {
     
    122121
    123122if(defined $ENV{'GSDL3SRCHOME'} || defined $ENV{'GSDLHOME'}) {
    124     print STDOUT "Found existing Greenstone home, will use that instead\n";
     123    print STDERR "Found existing Greenstone home, will use that instead\n";
    125124    $greenstone_home=$ENV{'GSDLHOME'};
    126125} else {
     
    172171
    173172    # http://perldoc.perl.org/File/Path.html
    174     print STDOUT "cleaning up previous tests\n";
     173    print STDERR "cleaning up previous tests\n";
    175174    &File::Path::remove_tree($ENV{'DATA_DIR'});
    176175
    177     print STDOUT "creating the data dir\n";
     176    print STDERR "creating the data dir\n";
    178177    &File::Path::make_path($ENV{'DATA_DIR'}); # works like mkdir -p
    179178
     
    182181    # use existing compiled-up greenstone installation, if a GSDLHOME set
    183182    if(defined $ENV{'GSDL3SRCHOME'} || defined $ENV{'GSDLHOME'}) {
    184     print STDOUT "Found existing Greenstone home, will use that instead";
     183    print STDERR "Found existing Greenstone home, will use that instead";
    185184    return;
    186185    }
     
    189188
    190189    #svn checkout of main gsdl directory                                       
    191     print STDOUT "checkout $gsdl:\n";
     190    print STDERR "checkout $gsdl:\n";
    192191    my $cmd = "svn co ".$ENV{'SVN_OPT_REV'}." http://svn.greenstone.org/main/trunk/greenstone2 $gsdl";
    193192    ##print STDERR "Checkout CMD: $cmd\n";
     
    196195    # http://stackoverflow.com/questions/758611/how-to-flush-output-in-backticks-in-perl?rq=1
    197196    my $status = system "$cmd"; #my $status = `$cmd`;
    198     print STDOUT "done\n";
     197    print STDERR "done\n";
    199198
    200199    ##print STDERR "$ENV{'DATA_DIR'}$sep$gsdl\n";
     
    207206    if(!$isWin) {
    208207
    209     print STDOUT "setting up gnome-lib-minimal for compilation\n";
     208    print STDERR "setting up gnome-lib-minimal for compilation\n";
    210209
    211210    # To get gnome-lib, need to determine bit architecture of the linux/darwin
     
    241240    # http://ubuntuforums.org/showthread.php?t=1932504 linking /bin/sh to bash instead of dash
    242241   
    243 #   $cmd = "/bin/bash \"source devel.bash && cd ../.. && ./configure --enable-apache httpd && make && make install\"";
    244242#   $cmd = "bash -c \"source ./devel.bash && cd ../.. && ./configure --enable-apache-httpd && make && make install\"";
    245 
    246243    $cmd = "bash -c \"";   
    247244
     
    297294
    298295    # get svn info
    299     print STDOUT "getting svn info: $xmlout\n";
     296    print STDERR "getting svn info: $xmlout\n";
    300297    print $xml_fh "<svn-info>\n";
    301298    run_and_print_cmd("svn info", $xml_fh);
    302299    print $xml_fh "</svn-info>\n";
    303     print STDOUT "done\n";
     300    print STDERR "done\n";
    304301
    305302    #make two copies of the model-collect directory in gsdl
     
    308305   
    309306    #copy the model collections to the collect folder to be rebuilt
    310     print STDOUT "installing test collections and model collections to new $gsdl installation... ";
     307    print STDERR "installing test collections and model collections to new $gsdl installation... ";
    311308   
    312309    #clean up
     
    324321    &copy_recursively("collect", "model-collect"); # copy contents across
    325322   
    326     print STDOUT "done\n";   
     323    print STDERR "done\n";   
    327324   
    328325
     
    331328    for my $collection (readdir $collect_handle) {
    332329    next if ($collection eq "." || $collection eq "..");
    333     next if ($collection ne "Small-HTML"); ## TEMPORARY, FOR TESTING THIS SCRIPT
     330    #next if ($collection ne "Small-HTML"); ## TEMPORARY, FOR TESTING THIS SCRIPT
    334331
    335332    #escape the filename (in case of space)
     
    345342# although it means that duplicate documents contained in the collection are
    346343# no longer detected automatically."
    347     print STDOUT "$collection - Importing:\n";
     344    print STDERR "$collection - Importing:\n";
    348345    print $xml_fh "<import>\n";
    349 #   $cmd = "import.pl -OIDtype hash_on_full_filename $collection -removeold";
    350 #   &run_build_script($cmd);
    351     $cmd = "bash -c \"export GSDLHOME=&& source $setup_script.bash && import.pl -OIDtype hash_on_full_filename -removeold $collection\"";
    352     system($cmd);
     346    &run_build_script("import.pl -OIDtype hash_on_full_filename $collection -removeold");
    353347    print $xml_fh "</import>\n";
    354     print STDOUT "done\n"; 
     348    print STDERR "done\n"; 
    355349
    356350    #build
    357     print STDOUT "$collection - Building:\n";
     351    print STDERR "$collection - Building:\n";
    358352    print $xml_fh "<build>\n";
    359 #   $cmd = "buildcol.pl $collection -removeold";
    360 #   &run_build_script($cmd);
    361     $cmd = "bash -c \"export GSDLHOME=&& source $setup_script.bash && buildcol.pl -removeold $collection\"";
    362     system($cmd);
     353    &run_build_script("buildcol.pl $collection -removeold");
    363354    print $xml_fh "</build>\n";
    364     print STDOUT "done\n";
     355    print STDERR "done\n";
    365356   
    366357    #rename the intermediate 'building' directory 'index'
    367     print STDOUT "$collection - Move \"building\" to \"index\"... ";
     358    print STDERR "$collection - Move \"building\" to \"index\"... ";
    368359    my $index = &filename_concat("collect", $collection, "index");
    369360    my $building = &filename_concat("collect", $collection, "building");
     
    371362    # Renaming Directories, http://www.perlmonks.org/?node_id=177421
    372363    move($building, $index) or die "copy failed: $!"; # File::Copy::move
    373     print STDOUT "done\n";
     364    print STDERR "done\n";
    374365
    375366    #diffcol
    376     print STDOUT "$collection - Diffing:\n";
     367    print STDERR "$collection - Diffing:\n";
    377368    my $diffcol_dir = &filename_concat($ENV{'TASK_HOME'},"diffcol");
    378369    $cmd = "./diffcol.pl -output xml -verbosity 10 $collection";   
     
    380371
    381372    chdir($greenstone_home); # this is actually where we are
    382     print STDOUT "done\n";
     373    print STDERR "done\n";
    383374    print $xml_fh "</collection-test>\n";
    384375    }
     
    388379    close($xml_fh);
    389380
    390     print STDOUT "done\n";
     381    print STDERR "done\n";
    391382}
    392383
     
    421412    }
    422413
    423     return &run_and_print_cmd($cmd, $fh);
     414    return system($cmd);
     415    #return &run_and_print_cmd($cmd, $fh); # doesn't work on cmds chained with bash -c
    424416}
    425417
     
    497489
    498490    # make a summarised Xml report
    499     print STDOUT "Summarizing the xml report... ";
     491    print STDERR "Summarizing the xml report... ";
    500492    my $cmd = "java org.apache.xalan.xslt.Process -IN $xmlout -XSL $ENV{'TASK_HOME'}/xsl/xml-report.xsl -OUT $ENV{'DATA_DIR'}/report-$dateid.xml";
    501493    my $status = system($cmd);
    502     print STDOUT "done\n";
     494    print STDERR "done\n";
    503495
    504496    # make a summarised HTMl report
    505     print STDOUT "Creating an html summary report... ";
     497    print STDERR "Creating an html summary report... ";
    506498    $cmd = "java org.apache.xalan.xslt.Process -IN $ENV{'DATA_DIR'}/report-$dateid.xml -XSL $ENV{'TASK_HOME'}/xsl/html-report.xsl -OUT $ENV{'DATA_DIR'}/report-$dateid.html";
    507499    $status = system($cmd);
    508     print STDOUT "done\n";
     500    print STDERR "done\n";
    509501}
    510502
     
    524516    closedir $dh;
    525517
    526     print STDOUT "Finished uploading\n";
     518    print STDERR "Finished uploading\n";
    527519}
    528520
     
    533525{
    534526    # email out with report attached, if the tests failed                                                     
    535     print STDOUT "Checking if successful... \n";
     527    print STDERR "Checking if successful... \n";
    536528    my $cmd = "java org.apache.xalan.xslt.Process -IN $xmlout -XSL $ENV{'TASK_HOME'}/xsl/passed-or-not.xsl";
    537529    #my $result = system($cmd);
    538530    my $result = `$cmd`;
    539531
    540     print STDOUT "result: $result\n";
     532    print STDERR "result: $result\n";
    541533
    542534    if($result ne "yes") {
     
    570562    system($cmd); # &run_and_print_cmd($cmd);
    571563
    572     print STDOUT "Sent mail with report attached.\n";
     564    print STDERR "Sent mail with report attached.\n";
    573565    } else {
    574566    print STDERR "********************************************\n";
    575     print STDOUT "Tests were successful. Not sending mail.\n";
     567    print STDERR "Tests were successful. Not sending mail.\n";
    576568    print STDERR "********************************************\n";
    577569    }
Note: See TracChangeset for help on using the changeset viewer.