- Timestamp:
- 2013-06-12T18:43:04+12:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
other-projects/nightly-tasks/diffcol/trunk/diffcol/diffcol.pl
r27579 r27604 285 285 VobPrint ("\n",$intLevel); 286 286 287 # Testing database 288 289 my $strModelGdb = &FileUtils::filenameConcatenate($strModelCol,"index","text","$strColName.ldb"); 290 my $strTestGdb = &FileUtils::filenameConcatenate($strTestCol,"index","text","$strColName.ldb"); 291 292 if(-e $strModelGdb && -e $strTestGdb) 293 { 294 my $strGdbError = gdbdiff::test_gdb($strModelGdb, $strTestGdb); 295 if($strGdbError ne "") 296 { 297 if( $strOutputFormat eq "xml" ) { 298 print "<database succeeded=\"no\"><message>"; 299 } else { 300 AlignPrint("Database Comparsion Result","Failed",$intLevel); 301 } 302 VobPrint ("$strGdbError\n",$intLevel); 303 304 if( $strOutputFormat eq "xml" ) { 305 print "</message></database>"; 306 } 307 308 $strGdbError = "$strGdbError"; 309 $strGdbError = "Difference Found at Database Comparsion\n".$strGdbError."\n"; 310 push(@Errors,$strGdbError); 311 } 312 else 313 { 314 if( $strOutputFormat eq "xml" ) { 315 print "<database succeeded=\"yes\"/>"; 316 } else { 317 AlignPrint("Database Comparsion Result","Succeed",$intLevel); 318 } 319 } 320 } 321 else 322 { 323 my $strErrorColName; 324 my $strGdbError; 325 326 if(!(-e $strModelGdb)){ $strErrorColName = $strErrorColName."(Model Collection)";} 327 if(!(-e $strTestGdb)){ $strErrorColName = $strErrorColName."(Test Collection)";} 328 287 # Testing databases 288 289 # index 290 my $strModelGdb = &FileUtils::filenameConcatenate($strModelCol,"index","text","$strColName.gdb"); 291 my $strTestGdb = &FileUtils::filenameConcatenate($strTestCol,"index","text","$strColName.gdb"); 292 my $strGdbError = &GdbDiff($strModelGdb,$strTestGdb,$strOutputFormat,$intLevel,$strColName); # returns 0 if no error 293 if($strGdbError) { 294 push(@Errors,$strGdbError); 295 } 296 297 # archives 298 $strModelGdb = &FileUtils::filenameConcatenate($strModelCol,"archives","archiveinf-doc.gdb"); 299 $strTestGdb = &FileUtils::filenameConcatenate($strTestCol,"archives","archiveinf-doc.gdb"); 300 $strGdbError = &GdbDiff($strModelGdb,$strTestGdb,$strOutputFormat,$intLevel,$strColName); 301 if($strGdbError) { 302 push(@Errors,$strGdbError); 303 } 304 305 $strModelGdb = &FileUtils::filenameConcatenate($strModelCol,"archives","archiveinf-src.gdb"); 306 $strTestGdb = &FileUtils::filenameConcatenate($strTestCol,"archives","archiveinf-src.gdb"); 307 $strGdbError = &GdbDiff($strModelGdb,$strTestGdb,$strOutputFormat,$intLevel,$strColName); 308 if($strGdbError) { 309 push(@Errors,$strGdbError); 310 } 311 312 VobPrint ("\n",$intLevel); 313 314 return @Errors; 315 } 316 317 318 # At present handles gdbm - need to expand to allow for jdbm and other db types 319 sub GdbDiff 320 { 321 my ($strModelGdb,$strTestGdb,$strOutputFormat,$intLevel,$strColName) = @_; 322 323 my $strGdbError = 0; 324 325 if(-e $strModelGdb && -e $strTestGdb) 326 { 327 #my $strGdbError = gdbdiff::test_gdb($strModelGdb, $strTestGdb); 328 $strGdbError = gdbdiff::test_gdb($strModelGdb, $strTestGdb,$strColName); 329 if($strGdbError ne "") 330 { 331 if( $strOutputFormat eq "xml" ) { 332 print "<database succeeded=\"no\" location=\"$strModelGdb\"><message>"; 333 } else { 329 334 AlignPrint("Database Comparsion Result","Failed",$intLevel); 330 331 $strGdbError = "Difference Report: No Database files found in $strErrorColName"; 332 VobPrint ("$strGdbError\n",$intLevel); 333 334 $strGdbError = "Difference Found at Database Comparison\n".$strGdbError."\n"; 335 336 push(@Errors,$strGdbError); 337 } 338 339 VobPrint ("\n",$intLevel); 340 341 return @Errors; 335 } 336 VobPrint ("$strGdbError\n",$intLevel); 337 338 if( $strOutputFormat eq "xml" ) { 339 print "</message></database>"; 340 } 341 342 $strGdbError = "$strGdbError"; 343 $strGdbError = "Difference Found at Database Comparsion\n".$strGdbError."\n"; 344 #push(@Errors,$strGdbError); 345 } 346 else 347 { 348 if( $strOutputFormat eq "xml" ) { 349 print "<database succeeded=\"yes\" location=\"$strModelGdb\"/>"; 350 } else { 351 AlignPrint("Database Comparsion Result","Succeed",$intLevel); 352 } 353 } 354 } 355 else 356 { 357 my $strErrorColName; 358 359 if(!(-e $strModelGdb)){ $strErrorColName = $strErrorColName."(Model Collection)";} 360 if(!(-e $strTestGdb)){ $strErrorColName = $strErrorColName."(Test Collection)";} 361 362 AlignPrint("Database Comparsion Result","Failed",$intLevel); 363 364 $strGdbError = "Difference Report: No Database files found in $strErrorColName"; 365 VobPrint ("$strGdbError\n",$intLevel); 366 367 $strGdbError = "Difference Found at Database Comparison\n".$strGdbError."\n"; 368 369 } 370 371 return $strGdbError; 342 372 } 343 373 … … 527 557 my $strNewModel = &FileUtils::filenameConcatenate($strModel,$strEachFile); 528 558 my $strNewTest = &FileUtils::filenameConcatenate($strTest,$strEachFile); 529 if(!($strEachFile eq "log" || $strEachFile =~ m/\.cfg$/g || $strEachFile =~ m/\.(l|b)db$/g)) 559 # now additionally ignoring the earliestDatestamp file and the index/idx/*.idh binary file when diffing file 560 if(!($strEachFile eq "log" || $strEachFile eq "earliestDatestamp" || $strEachFile =~ m/\.cfg$/g || $strEachFile =~ m/\.((g|j|l|b)db|idh)$/g)) 530 561 { 531 562 push(@Errors,TestEach($strNewModel,$strNewTest,$intLevel)); … … 547 578 my $strNewModel = &FileUtils::filenameConcatenate($strModel,$strEachFile); 548 579 my $strNewTest = &FileUtils::filenameConcatenate($strTest,$strEachFile); 549 if(!($strEachFile eq "log" || $strEachFile =~ m/\.cfg$/g || $strEachFile =~ m/\.(l|b)db$/g))580 if(!($strEachFile eq "log" || $strEachFile eq "earliestDatestamp" || $strEachFile =~ m/\.cfg$/g || $strEachFile =~ m/\.((g|j|l|b)db|idh)$/g)) 550 581 { 551 582 push(@Errors,TestEach($strNewModel,$strNewTest,$intLevel)); … … 561 592 else 562 593 { 563 my $strResult = diff $strModel, $strTest, { STYLE => "OldStyle" }; 564 $strResult = &diffutil::GenerateOutput($strResult,"^<Metadata name=\"(lastmodified|lastmodifieddate|oailastmodified|oailastmodifieddate)\">.*</Metadata>\$"); 594 my $ignore_line_re = "<Metadata name=\"(lastmodified|lastmodifieddate|oailastmodified|oailastmodifieddate)\">.*</Metadata>\\s*\\n*"; 595 my $strResult; 596 597 # for doc.xml files, need to ignore many date fields. Filter these out before diffing, 598 # in case these don't appear in the same order between collections, since 599 # diffutil::GenerateOutput only handles the ignore_regex after a diff has been done 600 # when they can show up as unnecessary diff 'errors' 601 if($strModel =~ m/doc\.xml$/) { 602 my ($model_contents, $test_contents); 603 open(FIN,"<$strModel") or die "Unable to open $strModel...ERROR: $!\n"; 604 sysread(FIN, $model_contents, -s FIN); 605 close(FIN); 606 open(FIN,"<$strTest") or die "Unable to open $strTest...ERROR: $!\n"; 607 sysread(FIN, $test_contents, -s FIN); 608 close(FIN); 609 610 $model_contents =~ s/$ignore_line_re//g; 611 $test_contents =~ s/$ignore_line_re//g; 612 613 $strResult = diff \$model_contents, \$test_contents, { STYLE => "OldStyle" }; 614 615 } else { 616 $strResult = diff $strModel, $strTest, { STYLE => "OldStyle" }; 617 } 618 619 # The following tries to apply a regex to exclude fields after diffing. This is now no longer necessary since we filter 620 # these fields out now before the diff, but leaving it in in case different regexes at this point helps with single line diffs 621 $strResult = &diffutil::GenerateOutput($strResult,"^\\s*<Metadata name=\"(lastmodified|lastmodifieddate|oailastmodified|oailastmodifieddate)\">.*</Metadata>\\s*\$"); 622 565 623 #$strResult = GeneralOutput($strResult); 566 624 if ( $strOutputFormat eq "xml" ) {
Note:
See TracChangeset
for help on using the changeset viewer.