Skip to content

Commit

Permalink
Move test helper assertIsSubsetOf to `FileSystemValueCheckerInferri…
Browse files Browse the repository at this point in the history
…ngAncestorsTestBase`

PiperOrigin-RevId: 546280755
Change-Id: Ie2c79d34e1f94a003c4caf6d32f79be9a54101cc
  • Loading branch information
Googler authored and copybara-github committed Jul 7, 2023
1 parent 6ae9503 commit 772cdde
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package com.google.devtools.build.lib.skyframe;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.common.truth.Truth8.assertThat;
import static com.google.devtools.build.lib.actions.FileStateValue.DIRECTORY_FILE_STATE_NODE;
import static com.google.devtools.build.lib.actions.FileStateValue.NONEXISTENT_FILE_STATE_NODE;
Expand Down Expand Up @@ -717,13 +716,6 @@ public void getDiffWithInferredAncestors_statCrashes_fails() throws Exception {
skyValueDirtinessChecker));
}

private static <T> void assertIsSubsetOf(Iterable<T> list, T... elements) {
ImmutableSet<T> set = ImmutableSet.copyOf(elements);
assertWithMessage("%s has elements from outside of %s", list, set)
.that(set)
.containsAtLeastElementsIn(list);
}

private Delta fileStateValueDelta(String relativePath) throws IOException {
return Delta.justNew(fileStateValue(relativePath));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
package com.google.devtools.build.lib.skyframe;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static org.junit.Assert.fail;

import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.devtools.build.lib.actions.FileStateValue;
import com.google.devtools.build.lib.testutil.Scratch;
import com.google.devtools.build.lib.vfs.DelegateFileSystem;
Expand Down Expand Up @@ -107,4 +109,11 @@ protected FileStateValue fileStateValue(String relativePath) throws IOException
protected static DirectoryListingStateValue directoryListingStateValue(Dirent... dirents) {
return DirectoryListingStateValue.create(ImmutableList.copyOf(dirents));
}

protected static <T> void assertIsSubsetOf(Iterable<T> list, T... elements) {
ImmutableSet<T> set = ImmutableSet.copyOf(elements);
assertWithMessage("%s has elements from outside of %s", list, set)
.that(set)
.containsAtLeastElementsIn(list);
}
}

0 comments on commit 772cdde

Please sign in to comment.