[Codestriker-commits] CVS update: codestriker/test/testtopictexts perforce-diff14.txt
Brought to you by:
sits
From: <si...@us...> - 2008-08-29 11:48:32
|
User: sits Date: 08/08/29 04:48:30 Modified: lib/Codestriker/FileParser PerforceDescribe.pm UnidiffUtils.pm . CHANGELOG Added: t/FileParser perforce.t test/testtopictexts perforce-diff14.txt Log: * Fixed an issue where some Perforce describe diffs were not being parsed correctly as reported by sha...@gm.... This has now been fixed. Index: perforce.t =================================================================== RCS file: perforce.t diff -N perforce.t --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ perforce.t 29 Aug 2008 11:48:26 -0000 1.1 @@ -0,0 +1,139 @@ +# Tests to ensure that perforce patches are handled correctly. + +use strict; +use Fatal qw / open close /; +use Test::More tests => 6; +use Test::Differences; + +use lib '../../lib'; +use Codestriker; +use Codestriker::FileParser::PerforceDescribe; + +# Parse the test perforce describe file. +my $fh; +open( $fh, '<', '../../test/testtopictexts/perforce-diff14.txt' ); +my @deltas = Codestriker::FileParser::PerforceDescribe->parse($fh); +close($fh); + +# Set what the expected output should be. +my @expected; +push @expected, make_delta( + filename => '//depot/autobuild/Build.pm', + revision => '12', + old_linenumber => '499', + new_linenumber => '499', + text => <<'END_DELTA', + + if ($state eq "start") { + print SENDMAIL "\t\tBuild started for release $rel. Build log could be found at:\n"; +- print SENDMAIL "http://172.20.1.120/build_log/$bldlog\n"; ++ print SENDMAIL "http://172.20.1.251/build_log/$bldlog\n"; + print SENDMAIL "\n You would be notified once build is done.\n"; + print SENDMAIL "\n\n\nHappy Building... :)"; + } +END_DELTA +); + +push @expected, make_delta( + filename => '//depot/autobuild/Build.pm', + revision => '12', + old_linenumber => '507', + new_linenumber => '507', + text => <<'END_DELTA', + + print SENDMAIL "\t\tBuild for release $rel finished successfully. Here is details:\n"; + print SENDMAIL "\nImage location: $stage_rel_link\n"; +- print SENDMAIL "Alternate location: http://172.20.1.120/images/$stage_rel_dir\n"; +- print SENDMAIL "Build Log: http://172.20.1.120/build_log/$bldlog\n"; +- print SENDMAIL "Sync Log: http://172.20.1.120/synclog/$synclog\n"; ++ print SENDMAIL "Alternate location: http://172.20.1.251/images/$stage_rel_dir\n"; ++ print SENDMAIL "Build Log: http://172.20.1.251/build_log/$bldlog\n"; ++ print SENDMAIL "Sync Log: http://172.20.1.251/synclog/$synclog\n"; + } + elsif ($state eq "failed") { + +END_DELTA +); + +push @expected, make_delta( + filename => '//depot/autobuild/Build.pm', + revision => '12', + old_linenumber => '519', + new_linenumber => '519', + text => <<'END_DELTA', + push (@error_msgs, @error_msg); + print SENDMAIL "\n @error_msgs\n"; + print SENDMAIL "\n\nSee build log for full details: "; +- print SENDMAIL "Build Log: http://172.20.1.120/build_log/$bldlog\n"; +- print SENDMAIL "Sync Log: http://172.20.1.120/synclog/$synclog\n"; ++ print SENDMAIL "Build Log: http://172.20.1.251/build_log/$bldlog\n"; ++ print SENDMAIL "Sync Log: http://172.20.1.251/synclog/$synclog\n"; + print SENDMAIL "\nPlease fix the issue and resubmit the build request."; + } + close (SENDMAIL); +END_DELTA +); + +push @expected, make_delta( + filename => '//depot/autobuild/buildserver.pl', + revision => '3', + old_linenumber => '10', + new_linenumber => '10', + text => <<'END_DELTA', + my $syncdir = "/opt/LOG/synclog"; + my $stage_dir = "/mars/UPLOAD/BUILD/AUTO_BUILD/"; + my $stage_linkdir = '\\\\mars\\Remote\\UPLOAD\\BUILD\\AUTO_BUILD\\'; ++my $db_stage_linkdir = '\\\\\\\\mars\\\\Remote\\\\UPLOAD\\\\BUILD\\\\AUTO_BUILD\\\\'; + my $image_dir = "/opt/Build/IMAGES/"; + my $script_dir = "/var/www/cgi-bin/build/BUILD_SCRIPTS/"; + my $buildlog_dir = "/opt/LOG/BUILD_LOG/"; +END_DELTA +); + +push @expected, make_delta( + filename => '//depot/autobuild/buildserver.pl', + revision => '3', + old_linenumber => '282', + new_linenumber => '283', + text => <<'END_DELTA', + my $alt_stage_dir = $prod_rel[0] . "/" . $rel; + my $stage_rel_link = $stage_linkdir . "$prod_rel[0]" . "\\" . "$prod_rel[1]" . "\\" . "$rel"; + Build->build_status_mail($bld_usr,$rel,$log_name,"pass", $stage_rel_link, $alt_stage_dir); ++ ++ my $db_stage_rel_link = $db_stage_linkdir . "$prod_rel[0]" . "\\\\" . "$prod_rel[1]" . "\\\\" . "$rel"; ++ my $stage_int_sql = "UPDATE releases SET internal_stage=\'$db_stage_rel_link\' ++ where releases.release=\'$rel\'"; ++ Build->run_sql_query($stage_int_sql, ";"); ++ + } + } + else { +END_DELTA +); + +# Check that the extracted deltas match what is expected. +is( @deltas, @expected, "Number of deltas in perforce patch 1" ); +for ( my $index = 0; $index < @deltas; $index++ ) { + eq_or_diff( $deltas[$index], $expected[$index], + "Delta $index in perforce patch 1" ); +} + +# Convenience function for creating a delta object. +sub make_delta { + + # Set constant properties for all git deltas. + my $delta = {}; + $delta->{binary} = 0; + $delta->{repmatch} = 1; + $delta->{description} = ''; + + # Apply the passed in arguments. + my %arg = @_; + $delta->{filename} = $arg{filename}; + $delta->{old_linenumber} = $arg{old_linenumber}; + $delta->{new_linenumber} = $arg{new_linenumber}; + $delta->{text} = $arg{text}; + $delta->{revision} = $arg{revision}; + + return $delta; +} Index: PerforceDescribe.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/FileParser/PerforceDescribe.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- PerforceDescribe.pm 25 Aug 2007 09:11:07 -0000 1.6 +++ PerforceDescribe.pm 29 Aug 2008 11:48:26 -0000 1.7 @@ -148,6 +148,9 @@ # Skip the next blank line before the next chunk. $line = <$fh>; + while (defined $line && $line =~ /^\s*$/) { + $line = <$fh>; + } } # Finally, add any remaining TOC netries that are unaccounted for. Index: UnidiffUtils.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/FileParser/UnidiffUtils.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- UnidiffUtils.pm 2 Aug 2008 04:47:40 -0000 1.7 +++ UnidiffUtils.pm 29 Aug 2008 11:48:27 -0000 1.8 @@ -48,14 +48,10 @@ if ($line !~ /^[\\]/o) { # Check if the diff block with the trailing context has been - # read. Note Perforce diffs can contain empty lines. + # read. if ($num_matched_old_lines >= $number_old_lines && $num_matched_new_lines >= $number_new_lines) { - last unless $line =~ /^\s*$/o; - - # Consume excessive blank lines. - $line = <$fh>; - next; + last; } else { if ($line =~ /^\-/o) { Index: CHANGELOG =================================================================== RCS file: /cvsroot/codestriker/codestriker/CHANGELOG,v retrieving revision 1.262 retrieving revision 1.263 diff -u -r1.262 -r1.263 --- CHANGELOG 27 Aug 2008 09:51:45 -0000 1.262 +++ CHANGELOG 29 Aug 2008 11:48:29 -0000 1.263 @@ -15,6 +15,10 @@ depot did not work if the depot was on a different machine to the web-server. This has now been fixed. +* Fixed an issue where some Perforce describe diffs were not being + parsed correctly as reported by sha...@gm.... This has + now been fixed. + * Added a drop-down on the topic create page where the initial topic state can be set. By default, this is set to "Open", however in situations where a review has already been performed but needs to Index: perforce-diff14.txt =================================================================== RCS file: perforce-diff14.txt diff -N perforce-diff14.txt --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ perforce-diff14.txt 29 Aug 2008 11:48:29 -0000 1.1 @@ -0,0 +1,75 @@ + + + + +Change 156 by shambhu@shambhu_build_test on 2008/08/12 20:55:51 + + Minor build related fixes, updated IP address, internal_stage location in table "releases" after build done and posted. Update "end" column in releases once a release is released. + +Affected files ... + +... //depot/autobuild/Build.pm#12 edit +... //depot/autobuild/buildserver.pl#3 edit + +Differences ... + +==== //depot/autobuild/Build.pm#12 (text) ==== + +@@ -499,7 +499,7 @@ + + if ($state eq "start") { + print SENDMAIL "\t\tBuild started for release $rel. Build log could be found at:\n"; +- print SENDMAIL "http://172.20.1.120/build_log/$bldlog\n"; ++ print SENDMAIL "http://172.20.1.251/build_log/$bldlog\n"; + print SENDMAIL "\n You would be notified once build is done.\n"; + print SENDMAIL "\n\n\nHappy Building... :)"; + } +@@ -507,9 +507,9 @@ + + print SENDMAIL "\t\tBuild for release $rel finished successfully. Here is details:\n"; + print SENDMAIL "\nImage location: $stage_rel_link\n"; +- print SENDMAIL "Alternate location: http://172.20.1.120/images/$stage_rel_dir\n"; +- print SENDMAIL "Build Log: http://172.20.1.120/build_log/$bldlog\n"; +- print SENDMAIL "Sync Log: http://172.20.1.120/synclog/$synclog\n"; ++ print SENDMAIL "Alternate location: http://172.20.1.251/images/$stage_rel_dir\n"; ++ print SENDMAIL "Build Log: http://172.20.1.251/build_log/$bldlog\n"; ++ print SENDMAIL "Sync Log: http://172.20.1.251/synclog/$synclog\n"; + } + elsif ($state eq "failed") { + +@@ -519,8 +519,8 @@ + push (@error_msgs, @error_msg); + print SENDMAIL "\n @error_msgs\n"; + print SENDMAIL "\n\nSee build log for full details: "; +- print SENDMAIL "Build Log: http://172.20.1.120/build_log/$bldlog\n"; +- print SENDMAIL "Sync Log: http://172.20.1.120/synclog/$synclog\n"; ++ print SENDMAIL "Build Log: http://172.20.1.251/build_log/$bldlog\n"; ++ print SENDMAIL "Sync Log: http://172.20.1.251/synclog/$synclog\n"; + print SENDMAIL "\nPlease fix the issue and resubmit the build request."; + } + close (SENDMAIL); + +==== //depot/autobuild/buildserver.pl#3 (xtext) ==== + +@@ -10,6 +10,7 @@ + my $syncdir = "/opt/LOG/synclog"; + my $stage_dir = "/mars/UPLOAD/BUILD/AUTO_BUILD/"; + my $stage_linkdir = '\\\\mars\\Remote\\UPLOAD\\BUILD\\AUTO_BUILD\\'; ++my $db_stage_linkdir = '\\\\\\\\mars\\\\Remote\\\\UPLOAD\\\\BUILD\\\\AUTO_BUILD\\\\'; + my $image_dir = "/opt/Build/IMAGES/"; + my $script_dir = "/var/www/cgi-bin/build/BUILD_SCRIPTS/"; + my $buildlog_dir = "/opt/LOG/BUILD_LOG/"; +@@ -282,6 +283,12 @@ + my $alt_stage_dir = $prod_rel[0] . "/" . $rel; + my $stage_rel_link = $stage_linkdir . "$prod_rel[0]" . "\\" . "$prod_rel[1]" . "\\" . "$rel"; + Build->build_status_mail($bld_usr,$rel,$log_name,"pass", $stage_rel_link, $alt_stage_dir); ++ ++ my $db_stage_rel_link = $db_stage_linkdir . "$prod_rel[0]" . "\\\\" . "$prod_rel[1]" . "\\\\" . "$rel"; ++ my $stage_int_sql = "UPDATE releases SET internal_stage=\'$db_stage_rel_link\' ++ where releases.release=\'$rel\'"; ++ Build->run_sql_query($stage_int_sql, ";"); ++ + } + } + else { + |