Changeset 28114
- Timestamp:
- 2013-08-21T19:58:39+12:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
other-projects/nightly-tasks/diffcol/trunk/task.pl
r28106 r28114 95 95 #parse arguments 96 96 my $action = "all"; 97 if(scalar(@ARGV) > 1) { 98 &printusage(); 99 exit 0; 97 my $subaction = ""; # run_test can take subactions: --just_diff and --no_svn 98 my @collections = (); 99 100 if(scalar(@ARGV) > 1 && $ARGV[0] ne "run_test") { 101 &printusage(); 102 exit -1; 100 103 } 101 104 … … 105 108 else { 106 109 switch ($ARGV[0]) { 107 case qr/^(-h|- help|help)$/i { &printusage; exit 0; }110 case qr/^(-h|--?help|help)$/i { &printusage; exit 0; } 108 111 case qr/^(setup_greenstone|run_test|summarise|upload|all)$/ { $action=$ARGV[0]; } 109 112 else { … … 113 116 } 114 117 } 115 } 118 119 # run_test action can take a subaction: nosvn|justdiff. 120 # nosvn: uses the model-collect as static and copies it over to collect, rebuilding what's currently in model-collect instead of copying 121 # it out from the svn model-collect again. 122 # justdiff: same as nosvn, but doesn't copy over model-collection to collect, and doesn't rebuild either of them. Just does the diff part. 123 if($action eq "run_test" && scalar(@ARGV) >= 2) { 124 push(@collections, @ARGV); 125 shift @collections; # remove action from array 126 127 if($ARGV[1] =~ m@^--@) { 128 shift @collections; # remove subaction from array 129 130 $subaction = $ARGV[1]; 131 if($subaction eq "--justdiff") { 132 $use_local_rebuild = $use_static_model = 1; 133 } elsif ($subaction eq "--nosvn") { 134 $use_static_model = 1; 135 } else { 136 print STDERR "Bad subaction.\n"; 137 &printusage; 138 exit -1; 139 } 140 } 141 142 # foreach my $col (@collections) { 143 # print STDERR "Collection: $col\n"; 144 # } 145 } 146 } 147 116 148 117 149 #check key environment vars are set … … 206 238 sub printusage 207 239 { 208 print STDERR "Run as: $0 (help|setup_greenstone|run_test |summarise|upload|all)\n";240 print STDERR "Run as: $0 (help|setup_greenstone|run_test <--justdiff|--nosvn> <col1 col2 ...> |summarise|upload|all)\n"; 209 241 } 210 242 … … 422 454 # http://stackoverflow.com/questions/3377879/how-do-i-receive-command-output-immediately 423 455 sub run_test 424 { 456 { 457 my $num_cols = scalar(@collections); # remember the empty case 458 459 if($num_cols == 0) { # deal with all collections 460 push (@collections, ""); 461 # putting the empty string in the array so that the "all colleections" case 462 # can be handled similarl to how the case of user-specified collections is handled 463 464 } else { # deal with user specified set of collections 465 # prefix the directory separator to each collection name 466 @collections = map { $sep.$_ } @collections; 467 } 468 425 469 my $pdfbox = &filename_concat($greenstone_home, "ext", "pdf-box"); 426 470 if(!-d $pdfbox) { … … 433 477 print $xml_fh "<test time=\"$dateid\" id=\"$dateid\">\n"; 434 478 435 my $cmd;479 my ($cmd, $status); 436 480 # make sure that diffcol/model-collect is up to date before copying it over to greenstone-home 437 481 438 482 if(!$use_local_rebuild) { 439 483 print $xml_fh "Updating $ENV{'TASK_HOME'}/model-collect:\n"; 440 $cmd = "svn up $ENV{'TASK_HOME'}/model-collect"; #chdir("$ENV{'TASK_HOME'}/model-collect"); 441 my $status = system "$cmd"; 484 for my $col (@collections) { 485 $cmd = "svn up $ENV{'TASK_HOME'}/model-collect$col"; #chdir("$ENV{'TASK_HOME'}/model-collect"); 486 $status = system "$cmd"; 487 } 442 488 } 443 489 … … 452 498 print STDERR "done\n"; 453 499 454 #make two copies of the model-collect directory in gsdl 455 #one to be rebuilt and one as the basis for comparison 456 #strip both of all .svn directories 457 458 #copy the model collections to the collect folder to be rebuilt 459 print STDERR "installing test collections and model collections to new $gsdl installation... "; 460 461 if(!$use_local_rebuild) { 500 if(!$use_local_rebuild) { 501 502 #make two copies of the model-collect directory in gsdl 503 #one to be rebuilt and one as the basis for comparison 504 #strip both of all .svn directories 505 506 #copy the model collections to the collect folder to be rebuilt 507 print STDERR "installing test collections and model collections to new $gsdl installation... "; 508 462 509 #clean up 463 510 if(-d "collect") { 464 &File::Path::remove_tree("collect") || die "Error could not delete collect: $!"; 511 for my $col (@collections) { 512 &File::Path::remove_tree("collect$col") || die "Error could not delete collect: $!"; 513 } 465 514 } 466 515 467 516 if($use_static_model) { 468 #copy to collect and strip .svn subfolders 469 &File::Path::make_path("collect"); # create the collect folder and copy contents from static model-collection across 470 ©_recursively("model-collect", "collect", ".svn"); 517 for my $col (@collections) { 518 #copy to collect and strip .svn subfolders 519 &File::Path::make_path("collect$col"); # create the collect folder and copy contents from static model-collection across 520 ©_recursively("model-collect$col", "collect$col", ".svn"); 521 } 471 522 472 523 } else { # the default situation: where we check out the model-collect from svn 473 &File::Path::remove_tree("model-collect"); 474 475 #copy to collect and strip .svn subfolders 476 &File::Path::make_path("collect"); # create the folder and copy contents across 477 ©_recursively(&filename_concat("$ENV{'TASK_HOME'}","model-collect"), "collect", ".svn"); 478 479 #make the model copy 480 &File::Path::make_path("model-collect"); 481 ©_recursively("collect", "model-collect"); # copy contents across 524 for my $col (@collections) { 525 &File::Path::remove_tree("model-collect$col"); 526 527 #copy to collect and strip .svn subfolders 528 &File::Path::make_path("collect$col"); # create the folder and copy contents across 529 ©_recursively(&filename_concat("$ENV{'TASK_HOME'}","model-collect$col"), "collect$col", ".svn"); 530 531 #make the model copy 532 &File::Path::make_path("model-collect$col"); 533 ©_recursively("collect$col", "model-collect$col"); # copy contents across 534 } 482 535 } 483 536 … … 485 538 } 486 539 487 #for each collection, import, build and diff with its model counterpart 488 opendir my($collect_handle), "collect" or die "Could not open dir $greenstone_home/collect: $!"; 489 for my $collection (readdir $collect_handle) { 490 next if ($collection eq "." || $collection eq ".."); 491 next if ($collection eq "modelcol"); 492 # next if ($collection ne "Section-Tagging"); ## TEMPORARY, FOR TESTING THIS SCRIPT 493 # next if ($collection !~ m/MARC/); ## TEMPORARY, FOR TESTING THIS SCRIPT 540 #for each collection, import, build and diff with its model counterpart 541 542 # if working with all collections, read the list of collections from the folders in collect 543 if($num_cols == 0) { 544 @collections = (); # get rid of the empty string put in the array to represent "all collections" 545 546 opendir my($collect_handle), "collect" or die "Could not open dir $greenstone_home/collect: $!"; 547 548 for my $collection (readdir $collect_handle) { 549 next if ($collection eq "." || $collection eq ".."); 550 next if ($collection eq "modelcol"); 551 push(@collections, $collection); 552 } 553 closedir $collect_handle; # close handle to collect dir 554 } 555 556 for my $collection (@collections) { 557 558 # next if ($collection ne "Demo-Lucene"); ## TEMPORARY, FOR TESTING THIS SCRIPT 559 # next if ($collection !~ m/OAI|METS|DSpace|MGPP|Lucene/); ## TEMPORARY, FOR TESTING THIS SCRIPT 494 560 495 561 #escape the filename (in case of space) 496 562 $collection =~ s@ @\\ @g; 497 563 #getting just the basename of the collection would have been necessary had we not cd-ed into $gsdl 498 564 565 $collection =~ s@^[\\/]@@g; # take the dir-sep prefix away again for user-specified collection names 566 567 if (! -d "collect$sep$collection") { 568 print STDERR "Collection $collection does not exist\n"; 569 next; 570 } 571 499 572 print STDERR "*** Found collection $collection\n"; 500 573 print $xml_fh "<collection-test name=\"$collection\">\n"; … … 538 611 print $xml_fh "</collection-test>\n"; 539 612 } 540 closedir $collect_handle; # close handle to collect dir541 613 542 614 print $xml_fh "</test>\n";
Note:
See TracChangeset
for help on using the changeset viewer.