Skip to content

Commit

Permalink
Update Math project for Java 11 (#540)
Browse files Browse the repository at this point in the history
  • Loading branch information
markro49 authored Nov 16, 2023
1 parent 6af85c7 commit d99900c
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
13 changes: 12 additions & 1 deletion framework/core/Project/Math.pm
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ sub new {
my $name = "commons-math";
my $vcs = Vcs::Git->new($PID,
"$REPO_DIR/$name.git",
"$PROJECTS_DIR/$PID/$BUGS_CSV_ACTIVE");
"$PROJECTS_DIR/$PID/$BUGS_CSV_ACTIVE",
\&_post_checkout);

return $class->SUPER::new($PID, $name, $vcs);
}
Expand Down Expand Up @@ -101,6 +102,16 @@ sub _layout2 {
return {src=>$src, test=>$test};
}

sub _post_checkout {
my ($self, $revision_id, $work_dir) = @_;
my $vid = $self->{_vcs}->lookup_vid($revision_id);

# Convert the file encoding of problematic files
my $result = determine_layout($self, $revision_id);
Utils::convert_file_encoding($work_dir."/".$result->{src}."/org/apache/commons/math3/stat/correlation/StorelessBivariateCovariance.java");
Utils::convert_file_encoding($work_dir."/".$result->{src}."/org/apache/commons/math3/stat/correlation/StorelessCovariance.java");
}

#
# Remove looping tests in addition to the broken ones
#
Expand Down
40 changes: 40 additions & 0 deletions framework/core/Utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,46 @@ sub print_env {

=pod
=item C<Utils::print_perl_call_stack>
Print the current Perl execution stack trace to F<stderr>.
=cut

sub print_perl_call_stack {
my ($package, $filename, $line, $subroutine, $hasargs, $wantarray, $evaltext, $is_require, $hints, $bitmask, $hinthash);
my $i = 1;
my @r;
while (@r = caller($i)) {
($package, $filename, $line, $subroutine, $hasargs, $wantarray, $evaltext, $is_require, $hints, $bitmask, $hinthash) = @r;
print(STDERR "$filename:$line $subroutine\n");
$i++;
}
}

=pod
=item C<Utils::convert_file_encoding(file_name)>
Copies the original file to <file_name>.bak then converts
the encoding of file_name from iso-8859-1 to utf-8.
=cut

sub convert_file_encoding {
@_ == 1 or die $ARG_ERROR;
my ($file_name) = @_;
if (-e $file_name){
rename($file_name, $file_name.".bak");
open(OUT, '>'.$file_name) or die $!;
my $converted_file = `iconv -f iso-8859-1 -t utf-8 $file_name.bak`;
print OUT $converted_file;
close(OUT);
}
}

=pod
=item C<Utils::is_continuous_integration>
Returns true if this process is running under continuous integration.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## commons-math: 2c443ab8b0efce5485f63eed62213091a188c993 ##
--- org.apache.commons.math.estimation.MinpackTest::testMinpackMeyer

0 comments on commit d99900c

Please sign in to comment.