@@ -104,23 +104,26 @@ sub check_post
104104 return 0;
105105}
106106
107+ my $timestamp_re = qr / ...._.._.._.._../ ;
108+
107109sub list_logs
108110{
109111 my $list_ref = shift ;
110112 my $dir = shift ;
113+
111114 my $dh = new DirHandle($dir );
112- if (defined $dh ) {
113- while (defined ($_ = $dh -> read )) {
114- if ($_ =~ m / ^(...._.._.._.._..)\. txt/ ) {
115- push @$list_ref , " $dir /$1 " ;
116- }
117- }
118- undef $dh ;
119- return 1;
120- } else {
121- print STDERR " Error: Could not read $dir \n " ;
115+ if (!defined ($dh )) {
116+ print STDERR (" ERROR: Could not read $dir \n " );
122117 return 0;
123118 }
119+
120+ while (defined ($_ = $dh -> read )) {
121+ if ($_ =~ m / ^($timestamp_re )\. txt/ ) {
122+ push (@$list_ref , " $dir /$1 " );
123+ }
124+ }
125+
126+ return 1;
124127}
125128
126129sub delete_old_logs
@@ -134,7 +137,7 @@ sub delete_old_logs
134137 for (my $i = $keep ; $i < $n ; ++$i ) {
135138 my $fb = shift (@$logs_ref );
136139 print " Removing $fb files\n " if ($verbose );
137- unlink ($fb . " .txt " , $fb . " _JUnit.xml " , $fb . " _Full.html " , $fb . " _Brief.html " , $fb . " _Totals.html " , $fb . " _Config.html " );
140+ Prettify::delete_prettify_output ($fb );
138141 }
139142 return ($keep < $n );
140143}
@@ -143,20 +146,22 @@ sub get_latest
143146{
144147 my $build_dir = shift ;
145148 my $file_name = " $build_dir /latest.txt" ;
146- my $latest = " " ;
149+ my $timestamp = undef ;
150+ my $text = undef ;
147151 my $fh = new FileHandle($file_name , ' r' );
148152 if (defined $fh ) {
149153 print " Loading latest from $file_name \n " if ($verbose );
150154 while (<$fh >) {
151- if ($_ =~ m / (...._.._.._.._..) / ) {
152- $latest = " $build_dir /$1 " ;
155+ if ($_ =~ m / ($timestamp_re ) / ) {
156+ $timestamp = " $build_dir /$1 " ;
157+ $text = $_ ;
153158 }
154159 }
155160 undef $fh ;
156161 } else {
157162 print STDERR " Error: Could not find $file_name \n " ;
158163 }
159- return $latest ;
164+ return $timestamp , $text ;
160165}
161166
162167sub set_latest_build_info
@@ -201,34 +206,6 @@ sub set_latest_build_info
201206 }
202207}
203208
204- sub update_latest_build_info
205- {
206- my $dir = shift ;
207- my $buildname = shift ;
208- my $file_name = " $dir /$buildname /latest.txt" ;
209- my $latest ;
210- my $fh = new FileHandle($file_name , ' r' );
211- if (defined $fh ) {
212- print " Loading latest from $file_name \n " if ($verbose );
213- while (<$fh >) {
214- if ($_ =~ m / (...._.._.._.._..) / ) {
215- $builds {$buildname }{BASENAME } = $1 ;
216- $latest = $_ ;
217- }
218- }
219- undef $fh ;
220- } else {
221- print STDERR " Error: Could not find $file_name \n " ;
222- return 0;
223- }
224- if (!defined $latest ) {
225- print STDERR " Error: Could not read latest build info for $buildname \n " ;
226- return 0;
227- }
228- set_latest_build_info($latest , $buildname );
229- return 1;
230- }
231-
232209sub write_failed_tests_by_test
233210{
234211 my $directory = shift ;
407384
408385 foreach my $buildname (keys %builds ) {
409386 my $latest = load_web_latest ($builds {$buildname }{URL });
410- if (defined $latest && $latest =~ m / (...._.._.._.._.. ) / ) {
387+ if (defined $latest && $latest =~ m / ($timestamp_re ) / ) {
411388 $builds {$buildname }{BASENAME } = $1 ;
412389 set_latest_build_info($latest , $buildname );
413390 } else {
734711 print " No status for $buildname \n " if ($verbose );
735712 }
736713 my $latest = load_web_latest($build_url );
737- if (defined $latest && $latest =~ / ^(...._.._.._.._.. ) / ) {
714+ if (defined $latest && $latest =~ / ^($timestamp_re ) / ) {
738715 my $basename = $1 ;
739716 my $fn = " $build_dir /$basename .txt" ;
740717 if (! -r $fn ) {
@@ -770,10 +747,10 @@ ($)
770747 my $post = check_post($build_dir );
771748 print " post=$post , use_build_logs=$use_build_logs \n " if ($verbose );
772749
773- my $latest = get_latest($build_dir );
750+ my ( $latest_timestamp , $latest_text ) = get_latest($build_dir );
774751 foreach my $file (@existing ) {
775752 my $totals_exist = (-e " ${file} _Totals.html" ) && !(-z _);
776- if (($post && !$totals_exist ) || ($totals_exist && !$use_build_logs && ($latest eq $file ))) {
753+ if (($post && !$totals_exist ) || ($totals_exist && !$use_build_logs && ($latest_timestamp eq $file ))) {
777754 # process only the latest text file if logs already exist
778755 print " Prettifying $file .txt\n " if ($verbose );
779756 Prettify::Process(" $file .txt" , $buildname , \%failed_tests_by_test , $use_build_logs , $builds {$buildname }-> {DIFFROOT }, $prefix , $totals_exist );
787764 my $diffRoot = $builds {$buildname }-> {DIFFROOT };
788765 utility::index_logs($build_dir , $buildname , $diffRoot );
789766 }
790- update_latest_build_info($directory , $buildname );
767+ if (!defined $latest_text ) {
768+ print STDERR " Error: Could not read latest build info for $buildname \n " ;
769+ return 0;
770+ }
771+ set_latest_build_info($latest_text , $buildname );
791772 }
792773 write_failed_tests_by_test($directory , \%failed_tests_by_test );
793774}
836817 }
837818
838819 while (defined ($_ = $dh -> read )) {
839- if ($_ =~ m / ^(...._.._.._.._.. )\. txt/ ) {
820+ if ($_ =~ m / ^($timestamp_re )\. txt/ ) {
840821 push @existing , " $cache_dir /$1 " ;
841822 }
842823 }
854835 }
855836
856837 # Delete anything left in the list
857-
858838 foreach my $file (@existing ) {
859839 print " Removing $file files\n " if ($verbose );
860- unlink $file . " .txt" ;
861- unlink $file . " .build.json" ;
862- unlink $file . " _Full.html" ;
863- unlink $file . " _Brief.html" ;
864- unlink $file . " _Totals.html" ;
865- unlink $file . " _Config.html" ;
840+ Prettify::delete_prettify_output($file );
866841 }
867842 }
868843 }
0 commit comments