Make InMemoryFS never call FileSystem's default constructor.
This moves most tests that rely on InMemoryFS to provide basic FS functionality in a test environment off from the default value, and onto instead using DigestHashFunction.DEFAULT_HASH_FOR_TESTS.
RELNOTES: None.
// limitations under the License.
package com.google.devtools.build.lib.vfs.inmemoryfs;
+import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.google.devtools.build.lib.clock.Clock;
@@ -58,14 +59,6 @@ public class InMemoryFileSystem extends FileSystem {
// Maximum number of traversals before ELOOP is thrown.
private static final int MAX_TRAVERSALS = 256;
- /**
- * Creates a new InMemoryFileSystem with scope checking disabled (all paths are considered to be
- * within scope) and a default clock.
- */
- public InMemoryFileSystem() {
- this(new JavaClock());
- }
-
/**
* Creates a new InMemoryFileSystem with scope checking disabled (all paths are considered to be
* within scope) and a default clock.
@@ -76,14 +69,6 @@ public class InMemoryFileSystem extends FileSystem {
this(new JavaClock(), hashFunction);
}
- /**
- * Creates a new InMemoryFileSystem with scope checking disabled (all
- * paths are considered to be within scope).
- */
- public InMemoryFileSystem(Clock clock) {
- this(clock, (PathFragment) null);
- }
-
/**
* Creates a new InMemoryFileSystem with scope checking disabled (all paths are considered to be
* within scope).
@@ -95,11 +80,31 @@ public class InMemoryFileSystem extends FileSystem {
this.scopeRoot = null;
}
+ /**
+ * Creates a new InMemoryFileSystem with scope checking disabled (all paths are considered to be
+ * within scope) and a default clock.
+ */
+ @VisibleForTesting
+ public InMemoryFileSystem() {
+ this(new JavaClock());
+ }
+
+ /**
+ * Creates a new InMemoryFileSystem with scope checking disabled (all
+ * paths are considered to be within scope).
+ */
+ @VisibleForTesting
+ public InMemoryFileSystem(Clock clock) {
+ this(clock, (PathFragment) null);
+ }
+
/**
* Creates a new InMemoryFileSystem with scope checking bound to scopeRoot, i.e. any path that's
* not below scopeRoot is considered to be out of scope.
*/
+ @VisibleForTesting
public InMemoryFileSystem(Clock clock, PathFragment scopeRoot) {
+ super(DigestHashFunction.DEFAULT_HASH_FOR_TESTS);
this.scopeRoot = scopeRoot;
this.clock = clock;
this.rootInode = newRootInode(clock);
