diff options
author | janakr <janakr@google.com> | 2017-07-25 00:04:53 +0200 |
---|---|---|
committer | Jakob Buchgraber <buchgr@google.com> | 2017-07-25 13:17:37 +0200 |
commit | 150858b40e98ee969b74a10702de06f974b757be (patch) | |
tree | 32e579108ef0be12936ea0649cffda745b132e79 /src/main/java/com/google | |
parent | 7ecf8ea7830b5b6b62fe041f48fe511f36a8f831 (diff) |
Add hook to process SkyframeExecutor in tests. Also add sentinel exception to indicate unserializability, improve error message in Path when serialization fails, and add some test-only methods to SkyframeExecutor and PackageFactory.
PiperOrigin-RevId: 162993806
Diffstat (limited to 'src/main/java/com/google')
7 files changed, 53 insertions, 7 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java b/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java index 3eead14e7d..1ca18e2129 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java +++ b/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java @@ -383,6 +383,11 @@ public final class PackageFactory { public abstract BuilderForTesting builder(); } + @VisibleForTesting + public Package.Builder.Helper getPackageBuilderHelperForTesting() { + return packageBuilderHelper; + } + /** * Constructs a {@code PackageFactory} instance with a specific glob path translator * and rule factory. diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/NotSerializableRuntimeException.java b/src/main/java/com/google/devtools/build/lib/skyframe/NotSerializableRuntimeException.java new file mode 100644 index 0000000000..c54bd45dd7 --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/skyframe/NotSerializableRuntimeException.java @@ -0,0 +1,24 @@ +// Copyright 2017 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.google.devtools.build.lib.skyframe; + +import java.io.Serializable; + +/** + * An exception that can be thrown by {@code writeObject} and {@code readObject} implementations of + * {@link Serializable} objects to indicate that they cannot actually be serialized. Should be used + * only as a shim: in the long run, all {@link Serializable} objects should actually be + * serializable. + */ +public class NotSerializableRuntimeException extends RuntimeException {} diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java index c1feb56a85..693d0a4eb8 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java @@ -128,6 +128,7 @@ import com.google.devtools.build.lib.util.ResourceUsage; import com.google.devtools.build.lib.util.io.TimestampGranularityMonitor; import com.google.devtools.build.lib.vfs.BatchStat; import com.google.devtools.build.lib.vfs.Dirent; +import com.google.devtools.build.lib.vfs.FileSystem; import com.google.devtools.build.lib.vfs.ModifiedFileSet; import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.PathFragment; @@ -1889,6 +1890,21 @@ public abstract class SkyframeExecutor implements WalkableGraphFactory { return memoizingEvaluator; } + @VisibleForTesting + public FileSystem getFileSystemForTesting() { + return directories.getFileSystem(); + } + + @VisibleForTesting + public RuleClassProvider getRuleClassProviderForTesting() { + return ruleClassProvider; + } + + @VisibleForTesting + public Package.Builder.Helper getPackageBuilderHelperForTesting() { + return pkgFactory.getPackageBuilderHelperForTesting(); + } + public void sync( ExtendedEventHandler eventHandler, PackageCacheOptions packageCacheOptions, diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/TargetPatternPhaseValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/TargetPatternPhaseValue.java index 8b61f73a4a..f59e884918 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/TargetPatternPhaseValue.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/TargetPatternPhaseValue.java @@ -107,12 +107,12 @@ public final class TargetPatternPhaseValue implements SkyValue { @SuppressWarnings("unused") private void writeObject(ObjectOutputStream out) { - throw new UnsupportedOperationException(); + throw new NotSerializableRuntimeException(); } @SuppressWarnings("unused") private void readObject(ObjectInputStream in) { - throw new UnsupportedOperationException(); + throw new NotSerializableRuntimeException(); } @SuppressWarnings("unused") diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/TestSuiteExpansionValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/TestSuiteExpansionValue.java index e1d8cb7a8c..cc2e04c9a0 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/TestSuiteExpansionValue.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/TestSuiteExpansionValue.java @@ -50,12 +50,12 @@ public final class TestSuiteExpansionValue implements SkyValue { @SuppressWarnings("unused") private void writeObject(ObjectOutputStream out) { - throw new UnsupportedOperationException(); + throw new NotSerializableRuntimeException(); } @SuppressWarnings("unused") private void readObject(ObjectInputStream in) { - throw new UnsupportedOperationException(); + throw new NotSerializableRuntimeException(); } @SuppressWarnings("unused") diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/TestsInSuiteValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/TestsInSuiteValue.java index 3dabf0682f..8a95b0b9d9 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/TestsInSuiteValue.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/TestsInSuiteValue.java @@ -47,12 +47,12 @@ final class TestsInSuiteValue implements SkyValue { @SuppressWarnings("unused") private void writeObject(ObjectOutputStream out) { - throw new UnsupportedOperationException(); + throw new NotSerializableRuntimeException(); } @SuppressWarnings("unused") private void readObject(ObjectInputStream in) { - throw new UnsupportedOperationException(); + throw new NotSerializableRuntimeException(); } @SuppressWarnings("unused") diff --git a/src/main/java/com/google/devtools/build/lib/vfs/Path.java b/src/main/java/com/google/devtools/build/lib/vfs/Path.java index b41589caae..a1436b5178 100644 --- a/src/main/java/com/google/devtools/build/lib/vfs/Path.java +++ b/src/main/java/com/google/devtools/build/lib/vfs/Path.java @@ -216,7 +216,8 @@ public class Path implements Comparable<Path>, Serializable { } private void writeObject(ObjectOutputStream out) throws IOException { - Preconditions.checkState(fileSystem == fileSystemForSerialization, fileSystem); + Preconditions.checkState( + fileSystem == fileSystemForSerialization, "%s %s", fileSystem, fileSystemForSerialization); out.writeUTF(getPathString()); } |