Changeset 27629 for other-projects/nightly-tasks/diffcol
- Timestamp:
- 2013-06-14T20:17:29+12:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
other-projects/nightly-tasks/diffcol/trunk/task.pl
r27628 r27629 66 66 #check key environment vars are set 67 67 if(!defined $ENV{'UPLOAD_DIR'}) { 68 print STD OUT"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"; 69 69 #return 1; 70 70 } 71 71 if(!defined $ENV{'DATA_DIR'}) { 72 print STD OUT"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"; 73 73 #return 1; 74 74 } 75 75 if(!defined $ENV{'MONITOR_EMAIL'}) { 76 print STD OUT"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"; 77 77 #return 1; 78 78 } 79 79 80 80 if($ENV{'DATA_DIR'} eq "/") { 81 print STD OUT"DATA_DIR should not be the fs root\n";81 print STDERR "DATA_DIR should not be the fs root\n"; 82 82 #return 1; 83 83 } 84 84 85 print STD OUT"DATA_DIR: ".$ENV{'DATA_DIR'}."\n";86 print STD OUT"UPLOAD_DIR: ".$ENV{'UPLOAD_DIR'}."\n";85 print STDERR "DATA_DIR: ".$ENV{'DATA_DIR'}."\n"; 86 print STDERR "UPLOAD_DIR: ".$ENV{'UPLOAD_DIR'}."\n"; 87 87 88 88 #create an id for this test … … 94 94 my $dateid="$year-$mon-$mday"; #my $dateid=($year+1900)."-".($mon+1)."-$mday"; 95 95 96 print STD OUT"Starting test '$dateid'\n";96 print STDERR "Starting test '$dateid'\n"; 97 97 98 98 … … 100 100 $ENV{'CLASSPATH'} = ""; 101 101 my $jar_lib_path = $ENV{'TASK_HOME'}.$sep."lib"; 102 ##print STDERR "@@@ $jar_lib_path\n";103 102 my @files = <$jar_lib_path/*.jar>; # /full/path/to/diffcol/lib/*jar 104 103 foreach my $file (@files) { … … 122 121 123 122 if(defined $ENV{'GSDL3SRCHOME'} || defined $ENV{'GSDLHOME'}) { 124 print STD OUT"Found existing Greenstone home, will use that instead\n";123 print STDERR "Found existing Greenstone home, will use that instead\n"; 125 124 $greenstone_home=$ENV{'GSDLHOME'}; 126 125 } else { … … 172 171 173 172 # http://perldoc.perl.org/File/Path.html 174 print STD OUT"cleaning up previous tests\n";173 print STDERR "cleaning up previous tests\n"; 175 174 &File::Path::remove_tree($ENV{'DATA_DIR'}); 176 175 177 print STD OUT"creating the data dir\n";176 print STDERR "creating the data dir\n"; 178 177 &File::Path::make_path($ENV{'DATA_DIR'}); # works like mkdir -p 179 178 … … 182 181 # use existing compiled-up greenstone installation, if a GSDLHOME set 183 182 if(defined $ENV{'GSDL3SRCHOME'} || defined $ENV{'GSDLHOME'}) { 184 print STD OUT"Found existing Greenstone home, will use that instead";183 print STDERR "Found existing Greenstone home, will use that instead"; 185 184 return; 186 185 } … … 189 188 190 189 #svn checkout of main gsdl directory 191 print STD OUT"checkout $gsdl:\n";190 print STDERR "checkout $gsdl:\n"; 192 191 my $cmd = "svn co ".$ENV{'SVN_OPT_REV'}." http://svn.greenstone.org/main/trunk/greenstone2 $gsdl"; 193 192 ##print STDERR "Checkout CMD: $cmd\n"; … … 196 195 # http://stackoverflow.com/questions/758611/how-to-flush-output-in-backticks-in-perl?rq=1 197 196 my $status = system "$cmd"; #my $status = `$cmd`; 198 print STD OUT"done\n";197 print STDERR "done\n"; 199 198 200 199 ##print STDERR "$ENV{'DATA_DIR'}$sep$gsdl\n"; … … 207 206 if(!$isWin) { 208 207 209 print STD OUT"setting up gnome-lib-minimal for compilation\n";208 print STDERR "setting up gnome-lib-minimal for compilation\n"; 210 209 211 210 # To get gnome-lib, need to determine bit architecture of the linux/darwin … … 241 240 # http://ubuntuforums.org/showthread.php?t=1932504 linking /bin/sh to bash instead of dash 242 241 243 # $cmd = "/bin/bash \"source devel.bash && cd ../.. && ./configure --enable-apache httpd && make && make install\"";244 242 # $cmd = "bash -c \"source ./devel.bash && cd ../.. && ./configure --enable-apache-httpd && make && make install\""; 245 246 243 $cmd = "bash -c \""; 247 244 … … 297 294 298 295 # get svn info 299 print STD OUT"getting svn info: $xmlout\n";296 print STDERR "getting svn info: $xmlout\n"; 300 297 print $xml_fh "<svn-info>\n"; 301 298 run_and_print_cmd("svn info", $xml_fh); 302 299 print $xml_fh "</svn-info>\n"; 303 print STD OUT"done\n";300 print STDERR "done\n"; 304 301 305 302 #make two copies of the model-collect directory in gsdl … … 308 305 309 306 #copy the model collections to the collect folder to be rebuilt 310 print STD OUT"installing test collections and model collections to new $gsdl installation... ";307 print STDERR "installing test collections and model collections to new $gsdl installation... "; 311 308 312 309 #clean up … … 324 321 ©_recursively("collect", "model-collect"); # copy contents across 325 322 326 print STD OUT"done\n";323 print STDERR "done\n"; 327 324 328 325 … … 331 328 for my $collection (readdir $collect_handle) { 332 329 next if ($collection eq "." || $collection eq ".."); 333 next if ($collection ne "Small-HTML"); ## TEMPORARY, FOR TESTING THIS SCRIPT330 #next if ($collection ne "Small-HTML"); ## TEMPORARY, FOR TESTING THIS SCRIPT 334 331 335 332 #escape the filename (in case of space) … … 345 342 # although it means that duplicate documents contained in the collection are 346 343 # no longer detected automatically." 347 print STD OUT"$collection - Importing:\n";344 print STDERR "$collection - Importing:\n"; 348 345 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"); 353 347 print $xml_fh "</import>\n"; 354 print STD OUT"done\n";348 print STDERR "done\n"; 355 349 356 350 #build 357 print STD OUT"$collection - Building:\n";351 print STDERR "$collection - Building:\n"; 358 352 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"); 363 354 print $xml_fh "</build>\n"; 364 print STD OUT"done\n";355 print STDERR "done\n"; 365 356 366 357 #rename the intermediate 'building' directory 'index' 367 print STD OUT"$collection - Move \"building\" to \"index\"... ";358 print STDERR "$collection - Move \"building\" to \"index\"... "; 368 359 my $index = &filename_concat("collect", $collection, "index"); 369 360 my $building = &filename_concat("collect", $collection, "building"); … … 371 362 # Renaming Directories, http://www.perlmonks.org/?node_id=177421 372 363 move($building, $index) or die "copy failed: $!"; # File::Copy::move 373 print STD OUT"done\n";364 print STDERR "done\n"; 374 365 375 366 #diffcol 376 print STD OUT"$collection - Diffing:\n";367 print STDERR "$collection - Diffing:\n"; 377 368 my $diffcol_dir = &filename_concat($ENV{'TASK_HOME'},"diffcol"); 378 369 $cmd = "./diffcol.pl -output xml -verbosity 10 $collection"; … … 380 371 381 372 chdir($greenstone_home); # this is actually where we are 382 print STD OUT"done\n";373 print STDERR "done\n"; 383 374 print $xml_fh "</collection-test>\n"; 384 375 } … … 388 379 close($xml_fh); 389 380 390 print STD OUT"done\n";381 print STDERR "done\n"; 391 382 } 392 383 … … 421 412 } 422 413 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 424 416 } 425 417 … … 497 489 498 490 # make a summarised Xml report 499 print STD OUT"Summarizing the xml report... ";491 print STDERR "Summarizing the xml report... "; 500 492 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"; 501 493 my $status = system($cmd); 502 print STD OUT"done\n";494 print STDERR "done\n"; 503 495 504 496 # make a summarised HTMl report 505 print STD OUT"Creating an html summary report... ";497 print STDERR "Creating an html summary report... "; 506 498 $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"; 507 499 $status = system($cmd); 508 print STD OUT"done\n";500 print STDERR "done\n"; 509 501 } 510 502 … … 524 516 closedir $dh; 525 517 526 print STD OUT"Finished uploading\n";518 print STDERR "Finished uploading\n"; 527 519 } 528 520 … … 533 525 { 534 526 # email out with report attached, if the tests failed 535 print STD OUT"Checking if successful... \n";527 print STDERR "Checking if successful... \n"; 536 528 my $cmd = "java org.apache.xalan.xslt.Process -IN $xmlout -XSL $ENV{'TASK_HOME'}/xsl/passed-or-not.xsl"; 537 529 #my $result = system($cmd); 538 530 my $result = `$cmd`; 539 531 540 print STD OUT"result: $result\n";532 print STDERR "result: $result\n"; 541 533 542 534 if($result ne "yes") { … … 570 562 system($cmd); # &run_and_print_cmd($cmd); 571 563 572 print STD OUT"Sent mail with report attached.\n";564 print STDERR "Sent mail with report attached.\n"; 573 565 } else { 574 566 print STDERR "********************************************\n"; 575 print STD OUT"Tests were successful. Not sending mail.\n";567 print STDERR "Tests were successful. Not sending mail.\n"; 576 568 print STDERR "********************************************\n"; 577 569 }
Note:
See TracChangeset
for help on using the changeset viewer.