@@ -104,23 +104,26 @@ sub check_post
104
104
return 0;
105
105
}
106
106
107
+ my $timestamp_re = qr / ...._.._.._.._../ ;
108
+
107
109
sub list_logs
108
110
{
109
111
my $list_ref = shift ;
110
112
my $dir = shift ;
113
+
111
114
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 " );
122
117
return 0;
123
118
}
119
+
120
+ while (defined ($_ = $dh -> read )) {
121
+ if ($_ =~ m / ^($timestamp_re )\. txt/ ) {
122
+ push (@$list_ref , " $dir /$1 " );
123
+ }
124
+ }
125
+
126
+ return 1;
124
127
}
125
128
126
129
sub delete_old_logs
@@ -134,7 +137,7 @@ sub delete_old_logs
134
137
for (my $i = $keep ; $i < $n ; ++$i ) {
135
138
my $fb = shift (@$logs_ref );
136
139
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 );
138
141
}
139
142
return ($keep < $n );
140
143
}
@@ -143,20 +146,22 @@ sub get_latest
143
146
{
144
147
my $build_dir = shift ;
145
148
my $file_name = " $build_dir /latest.txt" ;
146
- my $latest = " " ;
149
+ my $timestamp = undef ;
150
+ my $text = undef ;
147
151
my $fh = new FileHandle($file_name , ' r' );
148
152
if (defined $fh ) {
149
153
print " Loading latest from $file_name \n " if ($verbose );
150
154
while (<$fh >) {
151
- if ($_ =~ m / (...._.._.._.._..) / ) {
152
- $latest = " $build_dir /$1 " ;
155
+ if ($_ =~ m / ($timestamp_re ) / ) {
156
+ $timestamp = " $build_dir /$1 " ;
157
+ $text = $_ ;
153
158
}
154
159
}
155
160
undef $fh ;
156
161
} else {
157
162
print STDERR " Error: Could not find $file_name \n " ;
158
163
}
159
- return $latest ;
164
+ return $timestamp , $text ;
160
165
}
161
166
162
167
sub set_latest_build_info
@@ -201,34 +206,6 @@ sub set_latest_build_info
201
206
}
202
207
}
203
208
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
-
232
209
sub write_failed_tests_by_test
233
210
{
234
211
my $directory = shift ;
407
384
408
385
foreach my $buildname (keys %builds ) {
409
386
my $latest = load_web_latest ($builds {$buildname }{URL });
410
- if (defined $latest && $latest =~ m / (...._.._.._.._.. ) / ) {
387
+ if (defined $latest && $latest =~ m / ($timestamp_re ) / ) {
411
388
$builds {$buildname }{BASENAME } = $1 ;
412
389
set_latest_build_info($latest , $buildname );
413
390
} else {
734
711
print " No status for $buildname \n " if ($verbose );
735
712
}
736
713
my $latest = load_web_latest($build_url );
737
- if (defined $latest && $latest =~ / ^(...._.._.._.._.. ) / ) {
714
+ if (defined $latest && $latest =~ / ^($timestamp_re ) / ) {
738
715
my $basename = $1 ;
739
716
my $fn = " $build_dir /$basename .txt" ;
740
717
if (! -r $fn ) {
@@ -770,10 +747,10 @@ ($)
770
747
my $post = check_post($build_dir );
771
748
print " post=$post , use_build_logs=$use_build_logs \n " if ($verbose );
772
749
773
- my $latest = get_latest($build_dir );
750
+ my ( $latest_timestamp , $latest_text ) = get_latest($build_dir );
774
751
foreach my $file (@existing ) {
775
752
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 ))) {
777
754
# process only the latest text file if logs already exist
778
755
print " Prettifying $file .txt\n " if ($verbose );
779
756
Prettify::Process(" $file .txt" , $buildname , \%failed_tests_by_test , $use_build_logs , $builds {$buildname }-> {DIFFROOT }, $prefix , $totals_exist );
787
764
my $diffRoot = $builds {$buildname }-> {DIFFROOT };
788
765
utility::index_logs($build_dir , $buildname , $diffRoot );
789
766
}
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 );
791
772
}
792
773
write_failed_tests_by_test($directory , \%failed_tests_by_test );
793
774
}
836
817
}
837
818
838
819
while (defined ($_ = $dh -> read )) {
839
- if ($_ =~ m / ^(...._.._.._.._.. )\. txt/ ) {
820
+ if ($_ =~ m / ^($timestamp_re )\. txt/ ) {
840
821
push @existing , " $cache_dir /$1 " ;
841
822
}
842
823
}
854
835
}
855
836
856
837
# Delete anything left in the list
857
-
858
838
foreach my $file (@existing ) {
859
839
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 );
866
841
}
867
842
}
868
843
}
0 commit comments