summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorTobias Thierer <tobiast@google.com>2019-07-23 17:31:17 +0100
committerTobias Thierer <tobiast@google.com>2019-07-24 18:48:13 +0100
commit0fd993d78fe0119dcba24a4b99a3ad5f099d3c7d (patch)
treeb866f602e461c69221270ca84c3738b8117eed87 /tools
parent59f8d0808588530c949363295f9fff11618b3303 (diff)
CompareUpstreams: support comparing against snapshots.
CompareUpstreams used to compare ojluni sources vs. copies of the upstream sources stored in a "Repository" (checked-out and built source repositories). Since I've not recently been able to build OpenJDK 8 (requires an older C++ compiler than what is installed on my machine), I couldn't run CompareUpstreams without losing the information for the files that are only generated during the OpenJDK 8 build. This CL changes CompareUpstreams to instead compare against the snapshot of only the files of interest from the upstream repository (which in turn is a copy of a historic output of CopyUpstreamFiles at a time when I still had a compiled version of OpenJDK 8 on my local disk). The old functionality is still available/present in the code, but it's turned off by a hard-coded boolean constant for now. Note that the CompareUpstreams tool still requires the environment variable OPENJDK_HOME (which points to a directory with checked-out upstream repositories) to be set, but the files in those directories are not looked at unless the aforementioned hard-coded boolean constant is changed; I didn't bother refactoring that part for now. Test: Re-generated the verification spreadsheet and checked that the latest version as well as the changes relative to the previous version look sane and doesn't lose the comparison information for generated files. Change-Id: Ibde72b898c48ad2a29456e2af8b54708696c9bf3
Diffstat (limited to 'tools')
-rw-r--r--tools/upstream/src/main/java/libcore/CompareUpstreams.java26
-rw-r--r--tools/upstream/src/main/java/libcore/StandardRepositories.java12
-rw-r--r--tools/upstream/src/main/java/libcore/Util.java18
3 files changed, 45 insertions, 11 deletions
diff --git a/tools/upstream/src/main/java/libcore/CompareUpstreams.java b/tools/upstream/src/main/java/libcore/CompareUpstreams.java
index ca17f67a4a..bdd23645d6 100644
--- a/tools/upstream/src/main/java/libcore/CompareUpstreams.java
+++ b/tools/upstream/src/main/java/libcore/CompareUpstreams.java
@@ -69,6 +69,17 @@ import java.util.regex.Pattern;
*/
public class CompareUpstreams {
+ /**
+ * Whether to compare against snapshots based on (a) the output of {@link CopyUpstreamFiles},
+ * as opposed to (b) directly against checked-out upstream source {@link Repository}s.
+ *
+ * Because the snapshots are currently kept on x20 which is slow to access, (b) run much
+ * faster (a few seconds vs. 30 minutes), but it requires the checked-out and compiled
+ * upstream repositories to exist which is not the case for everyone / not easily achievable
+ * (OpenJDK 8 requires an old C++ compiler to build).
+ */
+ public static final boolean COMPARE_AGAINST_UPSTREAM_SNAPSHOT = true;
+
private final StandardRepositories standardRepositories;
public CompareUpstreams(StandardRepositories standardRepositories) {
@@ -153,6 +164,11 @@ public class CompareUpstreams {
}
headers.add("diff");
printTsv(out, headers);
+
+ Path snapshotRoot = COMPARE_AGAINST_UPSTREAM_SNAPSHOT
+ ? Util.pathFromEnvOrThrow("OJLUNI_UPSTREAMS")
+ : null;
+
for (Path relPath : relPaths) {
Repository expectedUpstream = standardRepositories.referenceUpstreamAsOfAndroidP(
relPath);
@@ -167,7 +183,15 @@ public class CompareUpstreams {
List<String> comparisons = new ArrayList<>(upstreams.size());
for (Repository upstream : upstreams) {
final String comparison;
- Path upstreamFile = upstream.absolutePath(relPath);
+ final Path upstreamFile;
+ if (COMPARE_AGAINST_UPSTREAM_SNAPSHOT) {
+ Path maybePath = snapshotRoot
+ .resolve(upstream.name())
+ .resolve(relPath);
+ upstreamFile = maybePath.toFile().exists() ? maybePath : null;
+ } else {
+ upstreamFile = upstream.absolutePath(relPath);
+ }
if (upstreamFile == null) {
comparison = "missing";
} else {
diff --git a/tools/upstream/src/main/java/libcore/StandardRepositories.java b/tools/upstream/src/main/java/libcore/StandardRepositories.java
index 3bdbebfdab..31efe94d7a 100644
--- a/tools/upstream/src/main/java/libcore/StandardRepositories.java
+++ b/tools/upstream/src/main/java/libcore/StandardRepositories.java
@@ -76,19 +76,11 @@ public class StandardRepositories {
}
public static StandardRepositories fromEnv() {
- Path androidBuildTop = Paths.get(getEnvOrThrow("ANDROID_BUILD_TOP"));
- Path upstreamRoot = Paths.get(getEnvOrThrow("OPENJDK_HOME"));
+ Path androidBuildTop = Util.pathFromEnvOrThrow("ANDROID_BUILD_TOP");
+ Path upstreamRoot = Util.pathFromEnvOrThrow("OPENJDK_HOME");
return new StandardRepositories(androidBuildTop, upstreamRoot);
}
- private static String getEnvOrThrow(String name) {
- String result = System.getenv(name);
- if (result == null) {
- throw new IllegalStateException("Environment variable undefined: " + name);
- }
- return result;
- }
-
private static final Set<String> juFilesFromJsr166 = Collections.unmodifiableSet(
new HashSet<>(Arrays.asList(
"AbstractQueue",
diff --git a/tools/upstream/src/main/java/libcore/Util.java b/tools/upstream/src/main/java/libcore/Util.java
index c50e99028f..0f69c5fdb0 100644
--- a/tools/upstream/src/main/java/libcore/Util.java
+++ b/tools/upstream/src/main/java/libcore/Util.java
@@ -26,6 +26,7 @@ import java.io.PrintWriter;
import java.io.Reader;
import java.io.Writer;
import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
@@ -36,6 +37,23 @@ class Util {
private Util() {
}
+ public static Path pathFromEnvOrThrow(String name) {
+ String envValue = getEnvOrThrow(name);
+ Path result = Paths.get(envValue);
+ if (!result.toFile().exists()) {
+ throw new IllegalArgumentException("Path not found: " + result);
+ }
+ return result;
+ }
+
+ private static String getEnvOrThrow(String name) {
+ String result = System.getenv(name);
+ if (result == null) {
+ throw new IllegalStateException("Environment variable undefined: " + name);
+ }
+ return result;
+ }
+
public static Lines readLines(Reader reader) throws IOException {
List<String> result = new ArrayList<>();
BufferedReader br = (reader instanceof BufferedReader)