aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test
diff options
context:
space:
mode:
authorGravatar ccalvarin <ccalvarin@google.com>2018-07-23 18:16:18 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-07-23 18:18:36 -0700
commitdd9f60e4d2721cdfd3044a8c8a1bdfd8e444009c (patch)
tree40d209283f1aec518fc57d7c07001a13bbabe1e3 /src/test
parent69301af7fdf8be97627bddeb33224289ebe4de93 (diff)
Remove redundancy in DigestHashFunction use in FileSystem.
Each FileSystem instance has a digest function, but the getDigest and getHashDigest functions also accepted their own custom parameter functions. We only support 1 hash per filesystem instance, these parameters are redundant. RELNOTES: None. PiperOrigin-RevId: 205758571
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/google/devtools/build/lib/actions/DigestUtilsTest.java21
-rw-r--r--src/test/java/com/google/devtools/build/lib/exec/SingleBuildFileCacheTest.java6
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java7
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTestCase.java5
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/FileArtifactValueTest.java6
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/FileFunctionTest.java11
-rw-r--r--src/test/java/com/google/devtools/build/lib/vfs/FileSystemTest.java6
7 files changed, 24 insertions, 38 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/actions/DigestUtilsTest.java b/src/test/java/com/google/devtools/build/lib/actions/DigestUtilsTest.java
index 1013c1a02e..fc6376e46f 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/DigestUtilsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/DigestUtilsTest.java
@@ -62,8 +62,7 @@ public class DigestUtilsTest {
FileSystem myfs =
new InMemoryFileSystem(BlazeClock.instance(), hf) {
@Override
- protected byte[] getDigest(Path path, DigestHashFunction hashFunction)
- throws IOException {
+ protected byte[] getDigest(Path path) throws IOException {
try {
barrierLatch.countDown();
readyLatch.countDown();
@@ -73,13 +72,12 @@ public class DigestUtilsTest {
} catch (Exception e) {
throw new IOException(e);
}
- return super.getDigest(path, hashFunction);
+ return super.getDigest(path);
}
@Override
- protected byte[] getFastDigest(Path path, DigestHashFunction hashFunction)
- throws IOException {
- return fastDigest ? super.getDigest(path, hashFunction) : null;
+ protected byte[] getFastDigest(Path path) throws IOException {
+ return fastDigest ? super.getDigest(path) : null;
}
};
@@ -139,8 +137,7 @@ public class DigestUtilsTest {
FileSystem myFS =
new InMemoryFileSystem(BlazeClock.instance(), hf) {
@Override
- protected byte[] getFastDigest(Path path, DigestHashFunction hashFunction)
- throws IOException {
+ protected byte[] getFastDigest(Path path) throws IOException {
// Digest functions have more than 3 bytes, usually at least 16.
return malformed;
}
@@ -229,17 +226,15 @@ public class DigestUtilsTest {
FileSystem tracingFileSystem =
new InMemoryFileSystem(BlazeClock.instance()) {
@Override
- protected byte[] getFastDigest(Path path, DigestHashFunction hashFunction)
- throws IOException {
+ protected byte[] getFastDigest(Path path) throws IOException {
getFastDigestCounter.incrementAndGet();
return null;
}
@Override
- protected byte[] getDigest(Path path, DigestHashFunction hashFunction)
- throws IOException {
+ protected byte[] getDigest(Path path) throws IOException {
getDigestCounter.incrementAndGet();
- return super.getDigest(path, hashFunction);
+ return super.getDigest(path);
}
};
diff --git a/src/test/java/com/google/devtools/build/lib/exec/SingleBuildFileCacheTest.java b/src/test/java/com/google/devtools/build/lib/exec/SingleBuildFileCacheTest.java
index 33f03865f6..e7b0937f95 100644
--- a/src/test/java/com/google/devtools/build/lib/exec/SingleBuildFileCacheTest.java
+++ b/src/test/java/com/google/devtools/build/lib/exec/SingleBuildFileCacheTest.java
@@ -67,10 +67,10 @@ public class SingleBuildFileCacheTest {
}
@Override
- protected byte[] getDigest(Path path, DigestHashFunction hf) throws IOException {
- assertThat(hf).isEqualTo(DigestHashFunction.MD5);
+ protected byte[] getDigest(Path path) throws IOException {
+ assertThat(getDigestFunction()).isEqualTo(DigestHashFunction.MD5);
byte[] override = md5Overrides.get(path.getPathString());
- return override != null ? override : super.getDigest(path, hf);
+ return override != null ? override : super.getDigest(path);
}
};
underTest = new SingleBuildFileCache("/", fs);
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java
index 734038cb29..19443a536c 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java
@@ -43,7 +43,6 @@ import com.google.devtools.build.lib.actions.util.ActionsTestUtil;
import com.google.devtools.build.lib.actions.util.TestAction.DummyAction;
import com.google.devtools.build.lib.events.NullEventHandler;
import com.google.devtools.build.lib.util.Pair;
-import com.google.devtools.build.lib.vfs.DigestHashFunction;
import com.google.devtools.build.lib.vfs.FileStatus;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
import com.google.devtools.build.lib.vfs.Path;
@@ -108,10 +107,8 @@ public class ArtifactFunctionTest extends ArtifactFunctionTestCase {
setupRoot(
new CustomInMemoryFs() {
@Override
- public byte[] getDigest(Path path, DigestHashFunction hf) throws IOException {
- return path.getBaseName().equals("unreadable")
- ? expectedDigest
- : super.getDigest(path, hf);
+ public byte[] getDigest(Path path) throws IOException {
+ return path.getBaseName().equals("unreadable") ? expectedDigest : super.getDigest(path);
}
});
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTestCase.java b/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTestCase.java
index b0deb69d58..5a1ca443b1 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTestCase.java
@@ -31,7 +31,6 @@ import com.google.devtools.build.lib.testutil.TestConstants;
import com.google.devtools.build.lib.testutil.TestRuleClassProvider;
import com.google.devtools.build.lib.testutil.TestUtils;
import com.google.devtools.build.lib.util.io.TimestampGranularityMonitor;
-import com.google.devtools.build.lib.vfs.DigestHashFunction;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.Root;
@@ -163,8 +162,8 @@ abstract class ArtifactFunctionTestCase {
/** InMemoryFileSystem that can pretend to do a fast digest. */
protected class CustomInMemoryFs extends InMemoryFileSystem {
@Override
- protected byte[] getFastDigest(Path path, DigestHashFunction hashFunction) throws IOException {
- return fastDigest ? getDigest(path, hashFunction) : null;
+ protected byte[] getFastDigest(Path path) throws IOException {
+ return fastDigest ? getDigest(path) : null;
}
}
}
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/FileArtifactValueTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/FileArtifactValueTest.java
index f09883adf7..1e85b6c8b3 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/FileArtifactValueTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/FileArtifactValueTest.java
@@ -21,7 +21,6 @@ import com.google.common.io.BaseEncoding;
import com.google.common.testing.EqualsTester;
import com.google.devtools.build.lib.actions.FileArtifactValue;
import com.google.devtools.build.lib.testutil.ManualClock;
-import com.google.devtools.build.lib.vfs.DigestHashFunction;
import com.google.devtools.build.lib.vfs.FileSystem;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
import com.google.devtools.build.lib.vfs.Path;
@@ -162,13 +161,12 @@ public class FileArtifactValueTest {
FileSystem fs =
new InMemoryFileSystem() {
@Override
- public byte[] getDigest(Path path, DigestHashFunction hf) throws IOException {
+ public byte[] getDigest(Path path) throws IOException {
throw exception;
}
@Override
- protected byte[] getFastDigest(Path path, DigestHashFunction hashFunction)
- throws IOException {
+ protected byte[] getFastDigest(Path path) throws IOException {
throw exception;
}
};
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/FileFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/FileFunctionTest.java
index 65639f3f90..b76bbcd24d 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/FileFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/FileFunctionTest.java
@@ -52,7 +52,6 @@ import com.google.devtools.build.lib.testutil.TestRuleClassProvider;
import com.google.devtools.build.lib.testutil.TestUtils;
import com.google.devtools.build.lib.util.Pair;
import com.google.devtools.build.lib.util.io.TimestampGranularityMonitor;
-import com.google.devtools.build.lib.vfs.DigestHashFunction;
import com.google.devtools.build.lib.vfs.FileStatus;
import com.google.devtools.build.lib.vfs.FileSystem;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
@@ -452,7 +451,7 @@ public class FileFunctionTest {
createFsAndRoot(
new CustomInMemoryFs(manualClock) {
@Override
- protected byte[] getFastDigest(Path path, DigestHashFunction hf) throws IOException {
+ protected byte[] getFastDigest(Path path) throws IOException {
return digest;
}
});
@@ -491,7 +490,7 @@ public class FileFunctionTest {
createFsAndRoot(
new CustomInMemoryFs(manualClock) {
@Override
- protected byte[] getFastDigest(Path path, DigestHashFunction hf) {
+ protected byte[] getFastDigest(Path path) {
return path.getBaseName().equals("unreadable") ? expectedDigest : null;
}
});
@@ -827,9 +826,9 @@ public class FileFunctionTest {
fs =
new CustomInMemoryFs(manualClock) {
@Override
- protected byte[] getDigest(Path path, DigestHashFunction hf) throws IOException {
+ protected byte[] getDigest(Path path) throws IOException {
digestCalls.incrementAndGet();
- return super.getDigest(path, hf);
+ return super.getDigest(path);
}
};
pkgRoot = Root.fromPath(fs.getPath("/root"));
@@ -1621,7 +1620,7 @@ public class FileFunctionTest {
}
@Override
- protected byte[] getFastDigest(Path path, DigestHashFunction hashFunction) throws IOException {
+ protected byte[] getFastDigest(Path path) throws IOException {
if (stubbedFastDigestErrors.containsKey(path)) {
throw stubbedFastDigestErrors.get(path);
}
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/FileSystemTest.java b/src/test/java/com/google/devtools/build/lib/vfs/FileSystemTest.java
index fdf94298d3..f279e84e3e 100644
--- a/src/test/java/com/google/devtools/build/lib/vfs/FileSystemTest.java
+++ b/src/test/java/com/google/devtools/build/lib/vfs/FileSystemTest.java
@@ -1304,8 +1304,7 @@ public abstract class FileSystemTest {
Fingerprint fp = new Fingerprint();
fp.addBytes(new byte[0]);
assertThat(fp.hexDigestAndReset())
- .isEqualTo(
- BaseEncoding.base16().lowerCase().encode(xFile.getDigest(DigestHashFunction.MD5)));
+ .isEqualTo(BaseEncoding.base16().lowerCase().encode(xFile.getDigest()));
}
@Test
@@ -1318,8 +1317,7 @@ public abstract class FileSystemTest {
Fingerprint fp = new Fingerprint();
fp.addBytes(buffer);
assertThat(fp.hexDigestAndReset())
- .isEqualTo(
- BaseEncoding.base16().lowerCase().encode(xFile.getDigest(DigestHashFunction.MD5)));
+ .isEqualTo(BaseEncoding.base16().lowerCase().encode(xFile.getDigest()));
}
@Test