Skip to content

Commit

Permalink
fixes some -A failures for Closure (#601)
Browse files Browse the repository at this point in the history
  • Loading branch information
markro49 authored Sep 7, 2024
1 parent 920b371 commit 1762e1e
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 2 deletions.
13 changes: 11 additions & 2 deletions framework/core/Project/Closure.pm
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,15 @@ sub determine_layout {
sub _post_checkout {
@_ == 3 or die $ARG_ERROR;
my ($self, $rev_id, $work_dir) = @_;
my $vid = $self->{_vcs}->lookup_vid($rev_id);
# get original bid
my $bid;
if (-e "$work_dir/$CONFIG") {
my $config = Utils::read_config_file("$work_dir/$CONFIG");
if (defined $config) {
$bid = $config->{$CONFIG_VID};
} else { die "no .config file"; }
} else { die "no .config file"; }
chop($bid);

open FH, "$work_dir/build.xml" or die $!;
my $build_file = do { local $/; <FH> };
Expand All @@ -87,8 +95,9 @@ sub _post_checkout {
my @entries = readdir(DIR);
closedir(DIR);
foreach my $file (@entries) {

if ($file =~ /-(\d+)-(\d+).diff/) {
if ($vid >= $1 && $vid <= $2) {
if ($bid >= $1 && $bid <= $2) {
$self->apply_patch($work_dir, "$compile_errors/$file")
or confess("Couldn't apply patch ($file): $!");
}
Expand Down
32 changes: 32 additions & 0 deletions framework/projects/Closure/compile-errors/test-107-109.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
diff --git a/test/com/google/debugging/sourcemap/SourceMapConsumerV3Test.java b/test/com/google/debugging/sourcemap/SourceMapConsumerV3Test.java
index 0364059cf..39a501b45 100644
--- a/test/com/google/debugging/sourcemap/SourceMapConsumerV3Test.java
+++ b/test/com/google/debugging/sourcemap/SourceMapConsumerV3Test.java
@@ -20,6 +20,7 @@ import junit.framework.TestCase;

import org.json.JSONArray;

+import java.util.Collection;
import java.util.Map;

/**
@@ -41,7 +41,8 @@ public class SourceMapConsumerV3Test extends TestCase {
SourceMapConsumerV3 consumer = new SourceMapConsumerV3();
consumer.parse(sourceMap);

- String[] sources = (String[]) consumer.getOriginalSources().toArray();
+ Collection<String> temp = consumer.getOriginalSources();
+ String[] sources = temp.toArray(new String[0]);

assertEquals(1, sources.length);
assertEquals(null, consumer.getSourceRoot());
@@ -62,7 +63,8 @@ public class SourceMapConsumerV3Test extends TestCase {
SourceMapConsumerV3 consumer = new SourceMapConsumerV3();
consumer.parse(sourceMap);

- String[] sources = (String[]) consumer.getOriginalSources().toArray();
+ Collection<String> temp = consumer.getOriginalSources();
+ String[] sources = temp.toArray(new String[0]);

assertEquals(1, sources.length);
assertEquals("http://server/path/", consumer.getSourceRoot());
32 changes: 32 additions & 0 deletions framework/projects/Closure/compile-errors/test-175-176.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
diff --git a/test/com/google/debugging/sourcemap/SourceMapConsumerV3Test.java b/test/com/google/debugging/sourcemap/SourceMapConsumerV3Test.java
index 0364059cf..39a501b45 100644
--- a/test/com/google/debugging/sourcemap/SourceMapConsumerV3Test.java
+++ b/test/com/google/debugging/sourcemap/SourceMapConsumerV3Test.java
@@ -20,6 +20,7 @@ import junit.framework.TestCase;

import org.json.JSONArray;

+import java.util.Collection;
import java.util.Map;

/**
@@ -41,7 +41,8 @@ public class SourceMapConsumerV3Test extends TestCase {
SourceMapConsumerV3 consumer = new SourceMapConsumerV3();
consumer.parse(sourceMap);

- String[] sources = (String[]) consumer.getOriginalSources().toArray();
+ Collection<String> temp = consumer.getOriginalSources();
+ String[] sources = temp.toArray(new String[0]);

assertEquals(1, sources.length);
assertEquals(null, consumer.getSourceRoot());
@@ -62,7 +63,8 @@ public class SourceMapConsumerV3Test extends TestCase {
SourceMapConsumerV3 consumer = new SourceMapConsumerV3();
consumer.parse(sourceMap);

- String[] sources = (String[]) consumer.getOriginalSources().toArray();
+ Collection<String> temp = consumer.getOriginalSources();
+ String[] sources = temp.toArray(new String[0]);

assertEquals(1, sources.length);
assertEquals("http://server/path/", consumer.getSourceRoot());

0 comments on commit 1762e1e

Please sign in to comment.