aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Carmi Grushko <carmi@google.com>2015-11-10 17:19:13 +0000
committerGravatar Dmitry Lomov <dslomov@google.com>2015-11-11 13:07:36 +0000
commitfd8acab0fcd4586c7beab61145cc565701bc3009 (patch)
tree8ef529e52d7106e86d2c4f9aa6d50a86e46575d7
parent254024df7c4a655a269e3e49c0a600716f1aedee (diff)
Replace home-made assertions with equivalent Google Truth calls.
-- MOS_MIGRATED_REVID=107492955
-rw-r--r--src/test/java/com/google/devtools/build/lib/actions/ArtifactTest.java47
-rw-r--r--src/test/java/com/google/devtools/build/lib/actions/FailActionTest.java5
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/ConfiguredAttributeMapperTest.java24
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/actions/SpawnActionTest.java18
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/select/AbstractAttributeMapperTest.java5
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/select/AggregatingAttributeMapperTest.java58
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/select/RawAttributeMapperTest.java13
-rw-r--r--src/test/java/com/google/devtools/build/lib/packages/BuildTypeTest.java53
-rw-r--r--src/test/java/com/google/devtools/build/lib/packages/PackageGroupTest.java6
-rw-r--r--src/test/java/com/google/devtools/build/lib/runtime/AbstractCommandTest.java28
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/GlobFunctionTest.java9
-rw-r--r--src/test/java/com/google/devtools/build/lib/syntax/TypeTest.java24
-rw-r--r--src/test/java/com/google/devtools/build/lib/testutil/MoreAsserts.java94
-rw-r--r--src/test/java/com/google/devtools/build/lib/util/DependencySetTest.java32
-rw-r--r--src/test/java/com/google/devtools/build/lib/util/DependencySetWindowsTest.java15
-rw-r--r--src/test/java/com/google/devtools/build/lib/vfs/GlobTest.java42
-rw-r--r--src/test/java/com/google/devtools/build/lib/vfs/RecursiveGlobTest.java12
17 files changed, 200 insertions, 285 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/actions/ArtifactTest.java b/src/test/java/com/google/devtools/build/lib/actions/ArtifactTest.java
index 5eee2a8499..ec0b924847 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/ArtifactTest.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/ArtifactTest.java
@@ -15,7 +15,6 @@ package com.google.devtools.build.lib.actions;
import static com.google.common.truth.Truth.assertThat;
-import static com.google.devtools.build.lib.testutil.MoreAsserts.assertSameContents;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
@@ -169,7 +168,7 @@ public class ArtifactTest {
List<String> paths = new ArrayList<>();
MutableActionGraph actionGraph = new MapBasedActionGraph();
Artifact.addExecPaths(getFooBarArtifacts(actionGraph, false), paths);
- assertSameContents(ImmutableList.of("bar1.h", "bar2.h"), paths);
+ assertThat(paths).containsExactlyElementsIn(ImmutableList.of("bar1.h", "bar2.h"));
}
@Test
@@ -178,7 +177,7 @@ public class ArtifactTest {
MutableActionGraph actionGraph = new MapBasedActionGraph();
Artifact.addExpandedExecPathStrings(getFooBarArtifacts(actionGraph, true), paths,
ActionInputHelper.actionGraphMiddlemanExpander(actionGraph));
- assertSameContents(ImmutableList.of("bar1.h", "bar2.h", "bar3.h"), paths);
+ assertThat(paths).containsExactly("bar1.h", "bar1.h", "bar2.h", "bar3.h");
}
@Test
@@ -187,9 +186,11 @@ public class ArtifactTest {
MutableActionGraph actionGraph = new MapBasedActionGraph();
Artifact.addExpandedExecPaths(getFooBarArtifacts(actionGraph, true), paths,
ActionInputHelper.actionGraphMiddlemanExpander(actionGraph));
- assertSameContents(ImmutableList.of(
- new PathFragment("bar1.h"), new PathFragment("bar2.h"), new PathFragment("bar3.h")),
- paths);
+ assertThat(paths).containsExactly(
+ new PathFragment("bar1.h"),
+ new PathFragment("bar1.h"),
+ new PathFragment("bar2.h"),
+ new PathFragment("bar3.h"));
}
@Test
@@ -209,7 +210,7 @@ public class ArtifactTest {
manuallyExpanded.add(artifact);
}
}
- assertSameContents(manuallyExpanded, expanded);
+ assertThat(expanded).containsExactlyElementsIn(manuallyExpanded);
}
@Test
@@ -217,7 +218,7 @@ public class ArtifactTest {
List<String> paths = new ArrayList<>();
MutableActionGraph actionGraph = new MapBasedActionGraph();
Artifact.addExecPaths(getFooBarArtifacts(actionGraph, false), paths);
- assertSameContents(ImmutableList.of("bar1.h", "bar2.h"), paths);
+ assertThat(paths).containsExactlyElementsIn(ImmutableList.of("bar1.h", "bar2.h"));
}
@Test
@@ -226,7 +227,7 @@ public class ArtifactTest {
MutableActionGraph actionGraph = new MapBasedActionGraph();
Artifact.addExpandedExecPathStrings(getFooBarArtifacts(actionGraph, true), paths,
ActionInputHelper.actionGraphMiddlemanExpander(actionGraph));
- assertSameContents(ImmutableList.of("bar1.h", "bar2.h", "bar3.h"), paths);
+ assertThat(paths).containsExactly("bar1.h", "bar1.h", "bar2.h", "bar3.h");
}
@Test
@@ -235,9 +236,11 @@ public class ArtifactTest {
MutableActionGraph actionGraph = new MapBasedActionGraph();
Artifact.addExpandedExecPaths(getFooBarArtifacts(actionGraph, true), paths,
ActionInputHelper.actionGraphMiddlemanExpander(actionGraph));
- assertSameContents(ImmutableList.of(
- new PathFragment("bar1.h"), new PathFragment("bar2.h"), new PathFragment("bar3.h")),
- paths);
+ assertThat(paths).containsExactly(
+ new PathFragment("bar1.h"),
+ new PathFragment("bar1.h"),
+ new PathFragment("bar2.h"),
+ new PathFragment("bar3.h"));
}
@Test
@@ -257,7 +260,7 @@ public class ArtifactTest {
manuallyExpanded.add(artifact);
}
}
- assertSameContents(manuallyExpanded, expanded);
+ assertThat(expanded).containsExactlyElementsIn(manuallyExpanded);
}
@Test
@@ -309,22 +312,22 @@ public class ArtifactTest {
new PathFragment("b/c"),
new LabelArtifactOwner(Label.parseAbsoluteUnchecked("//foo:bar"))).serializeToString());
}
-
+
@Test
public void testLongDirname() throws Exception {
String dirName = createDirNameArtifact().getDirname();
-
- assertThat(dirName).isEqualTo("aaa/bbb/ccc");
+
+ assertThat(dirName).isEqualTo("aaa/bbb/ccc");
}
-
+
@Test
public void testDirnameInExecutionDir() throws Exception {
- Artifact artifact = new Artifact(scratch.file("/foo/bar.txt"),
+ Artifact artifact = new Artifact(scratch.file("/foo/bar.txt"),
Root.asDerivedRoot(scratch.dir("/foo")));
-
- assertThat(artifact.getDirname()).isEqualTo(".");
+
+ assertThat(artifact.getDirname()).isEqualTo(".");
}
-
+
@Test
public void testCanConstructPathFromDirAndFilename() throws Exception {
Artifact artifact = createDirNameArtifact();
@@ -333,7 +336,7 @@ public class ArtifactTest {
assertThat(constructed).isEqualTo("aaa/bbb/ccc/ddd");
}
-
+
private Artifact createDirNameArtifact() throws Exception {
return new Artifact(scratch.file("/aaa/bbb/ccc/ddd"), Root.asDerivedRoot(scratch.dir("/")));
}
diff --git a/src/test/java/com/google/devtools/build/lib/actions/FailActionTest.java b/src/test/java/com/google/devtools/build/lib/actions/FailActionTest.java
index aba15e7ddc..bc8f364be5 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/FailActionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/FailActionTest.java
@@ -16,7 +16,6 @@ package com.google.devtools.build.lib.actions;
import static com.google.common.truth.Truth.assertThat;
import static com.google.devtools.build.lib.actions.util.ActionsTestUtil.NULL_ACTION_OWNER;
-import static com.google.devtools.build.lib.testutil.MoreAsserts.assertSameContents;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.fail;
@@ -66,12 +65,12 @@ public class FailActionTest {
@Test
public void testInputsAreEmptySet() {
- assertSameContents(Collections.emptySet(), failAction.getInputs());
+ assertThat(failAction.getInputs()).containsExactlyElementsIn(Collections.emptySet());
}
@Test
public void testRetainsItsOutputs() {
- assertSameContents(outputs, failAction.getOutputs());
+ assertThat(failAction.getOutputs()).containsExactlyElementsIn(outputs);
}
@Test
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/ConfiguredAttributeMapperTest.java b/src/test/java/com/google/devtools/build/lib/analysis/ConfiguredAttributeMapperTest.java
index 618882fa25..e83160ed76 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/ConfiguredAttributeMapperTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/ConfiguredAttributeMapperTest.java
@@ -13,7 +13,7 @@
// limitations under the License.
package com.google.devtools.build.lib.analysis;
-import static com.google.devtools.build.lib.testutil.MoreAsserts.assertSameContents;
+import static com.google.common.truth.Truth.assertThat;
import com.google.common.collect.ImmutableList;
import com.google.devtools.build.lib.analysis.config.CompilationMode;
@@ -122,18 +122,20 @@ public class ConfiguredAttributeMapperTest extends BuildViewTestCase {
useConfiguration("-c", "opt");
getMapper("//a:bin").visitLabels(testVisitor);
- assertSameContents(ImmutableList.of(binSrc, Label.parseAbsolute("//a:adep")), visitedLabels);
+ assertThat(visitedLabels)
+ .containsExactlyElementsIn(ImmutableList.of(binSrc, Label.parseAbsolute("//a:adep")));
visitedLabels.clear();
useConfiguration("-c", "dbg");
getMapper("//a:bin").visitLabels(testVisitor);
- assertSameContents(ImmutableList.of(binSrc, Label.parseAbsolute("//a:bdep")), visitedLabels);
+ assertThat(visitedLabels)
+ .containsExactlyElementsIn(ImmutableList.of(binSrc, Label.parseAbsolute("//a:bdep")));
visitedLabels.clear();
useConfiguration("-c", "fastbuild");
getMapper("//a:bin").visitLabels(testVisitor);
- assertSameContents(
- ImmutableList.of(binSrc, Label.parseAbsolute("//a:defaultdep")), visitedLabels);
+ assertThat(visitedLabels)
+ .containsExactlyElementsIn(ImmutableList.of(binSrc, Label.parseAbsolute("//a:defaultdep")));
}
/**
@@ -165,9 +167,8 @@ public class ConfiguredAttributeMapperTest extends BuildViewTestCase {
useConfiguration("-c", "dbg");
// Target configuration is in dbg mode, so we should match //conditions:b:
- assertSameContents(
- ImmutableList.of(Label.parseAbsolute("//a:bdep")),
- getMapper("//a:gen").get("tools", BuildType.LABEL_LIST));
+ assertThat(getMapper("//a:gen").get("tools", BuildType.LABEL_LIST))
+ .containsExactlyElementsIn(ImmutableList.of(Label.parseAbsolute("//a:bdep")));
// Verify the "tools" dep uses a different configuration that's not also in "dbg":
assertEquals(Attribute.ConfigurationTransition.HOST,
@@ -190,8 +191,9 @@ public class ConfiguredAttributeMapperTest extends BuildViewTestCase {
" cmd = 'nothing',",
")");
useConfiguration("--define", "foo=a", "--define", "bar=d");
- assertSameContents(
- ImmutableList.of(Label.parseAbsolute("//hello:a.in"), Label.parseAbsolute("//hello:d.in")),
- getMapper("//hello:gen").get("srcs", BuildType.LABEL_LIST));
+ assertThat(getMapper("//hello:gen").get("srcs", BuildType.LABEL_LIST))
+ .containsExactlyElementsIn(
+ ImmutableList.of(
+ Label.parseAbsolute("//hello:a.in"), Label.parseAbsolute("//hello:d.in")));
}
}
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/actions/SpawnActionTest.java b/src/test/java/com/google/devtools/build/lib/analysis/actions/SpawnActionTest.java
index cfbb3dfa78..c2bc2f5bfb 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/actions/SpawnActionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/actions/SpawnActionTest.java
@@ -14,7 +14,6 @@
package com.google.devtools.build.lib.analysis.actions;
import static com.google.common.truth.Truth.assertThat;
-import static com.google.devtools.build.lib.testutil.MoreAsserts.assertSameContents;
import static java.nio.charset.StandardCharsets.ISO_8859_1;
import static java.util.Arrays.asList;
@@ -110,10 +109,10 @@ public class SpawnActionTest extends BuildViewTestCase {
SpawnAction action = (SpawnAction) actions[0];
assertEquals(ActionsTestUtil.NULL_ACTION_OWNER.getLabel(),
action.getOwner().getLabel());
- assertSameContents(asList(input), action.getInputs());
- assertSameContents(asList(output), action.getOutputs());
+ assertThat(action.getInputs()).containsExactlyElementsIn(asList(input));
+ assertThat(action.getOutputs()).containsExactlyElementsIn(asList(output));
assertEquals(AbstractAction.DEFAULT_RESOURCE_SET, action.getSpawn().getLocalResources());
- assertSameContents(asList("/bin/xxx"), action.getArguments());
+ assertThat(action.getArguments()).containsExactlyElementsIn(asList("/bin/xxx"));
assertEquals("Test", action.getProgressMessage());
}
@@ -124,8 +123,8 @@ public class SpawnActionTest extends BuildViewTestCase {
.build(ActionsTestUtil.NULL_ACTION_OWNER, collectingAnalysisEnvironment, targetConfig);
collectingAnalysisEnvironment.registerAction(actions);
SpawnAction action = (SpawnAction) actions[0];
- assertSameContents(asList(welcomeArtifact.getExecPath().getPathString()),
- action.getArguments());
+ assertThat(action.getArguments())
+ .containsExactlyElementsIn(asList(welcomeArtifact.getExecPath().getPathString()));
}
public void testBuilderWithJavaExecutable() throws Exception {
@@ -286,15 +285,16 @@ public class SpawnActionTest extends BuildViewTestCase {
SpawnInfo spawnInfo = info.getExtension(SpawnInfo.spawnInfo);
assertNotNull(spawnInfo);
- assertSameContents(copyFromWelcomeToDestination.getArguments(), spawnInfo.getArgumentList());
+ assertThat(spawnInfo.getArgumentList())
+ .containsExactlyElementsIn(copyFromWelcomeToDestination.getArguments());
Iterable<String> inputPaths = Artifact.toExecPaths(
copyFromWelcomeToDestination.getInputs());
Iterable<String> outputPaths = Artifact.toExecPaths(
copyFromWelcomeToDestination.getOutputs());
- assertSameContents(inputPaths, spawnInfo.getInputFileList());
- assertSameContents(outputPaths, spawnInfo.getOutputFileList());
+ assertThat(spawnInfo.getInputFileList()).containsExactlyElementsIn(inputPaths);
+ assertThat(spawnInfo.getOutputFileList()).containsExactlyElementsIn(outputPaths);
Map<String, String> environment = copyFromWelcomeToDestination.getEnvironment();
assertEquals(environment.size(), spawnInfo.getVariableCount());
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/select/AbstractAttributeMapperTest.java b/src/test/java/com/google/devtools/build/lib/analysis/select/AbstractAttributeMapperTest.java
index bdbc4c01ff..5e6c31bd50 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/select/AbstractAttributeMapperTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/select/AbstractAttributeMapperTest.java
@@ -30,7 +30,6 @@ import com.google.devtools.build.lib.packages.RuleClass;
import com.google.devtools.build.lib.packages.util.PackageFactoryApparatus;
import com.google.devtools.build.lib.syntax.Type;
import com.google.devtools.build.lib.testutil.FoundationTestCase;
-import com.google.devtools.build.lib.testutil.MoreAsserts;
import com.google.devtools.build.lib.testutil.Scratch;
import com.google.devtools.build.lib.vfs.Path;
@@ -133,8 +132,8 @@ public class AbstractAttributeMapperTest extends FoundationTestCase {
public void testVisitation() throws Exception {
VisitationRecorder recorder = new VisitationRecorder();
mapper.visitLabels(recorder);
- MoreAsserts.assertSameContents(
- ImmutableList.of("//x:a", "//x:b", "//x:c"), recorder.labelsVisited);
+ assertThat(recorder.labelsVisited)
+ .containsExactlyElementsIn(ImmutableList.of("//x:a", "//x:b", "//x:c"));
}
public void testComputedDefault() throws Exception {
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/select/AggregatingAttributeMapperTest.java b/src/test/java/com/google/devtools/build/lib/analysis/select/AggregatingAttributeMapperTest.java
index 0d363b9cc3..184a9242a6 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/select/AggregatingAttributeMapperTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/select/AggregatingAttributeMapperTest.java
@@ -13,7 +13,7 @@
// limitations under the License.
package com.google.devtools.build.lib.analysis.select;
-import static com.google.devtools.build.lib.testutil.MoreAsserts.assertSameContents;
+import static com.google.common.truth.Truth.assertThat;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
@@ -45,9 +45,8 @@ public class AggregatingAttributeMapperTest extends AbstractAttributeMapperTest
Rule rule = createRule("a", "myrule",
"sh_binary(name = 'myrule',",
" srcs = ['a.sh'])");
- assertSameContents(
- ImmutableList.of(ImmutableList.of(Label.create("a", "a.sh"))),
- AggregatingAttributeMapper.of(rule).visitAttribute("srcs", BuildType.LABEL_LIST));
+ assertThat(AggregatingAttributeMapper.of(rule).visitAttribute("srcs", BuildType.LABEL_LIST))
+ .containsExactlyElementsIn(ImmutableList.of(ImmutableList.of(Label.create("a", "a.sh"))));
}
/**
@@ -62,12 +61,12 @@ public class AggregatingAttributeMapperTest extends AbstractAttributeMapperTest
" '//conditions:b': ['b.sh'],",
" '" + BuildType.Selector.DEFAULT_CONDITION_KEY + "': ['default.sh'],",
" }))");
- assertSameContents(
- ImmutableList.of(
- ImmutableList.of(Label.create("a", "a.sh")),
- ImmutableList.of(Label.create("a", "b.sh")),
- ImmutableList.of(Label.create("a", "default.sh"))),
- AggregatingAttributeMapper.of(rule).visitAttribute("srcs", BuildType.LABEL_LIST));
+ assertThat(AggregatingAttributeMapper.of(rule).visitAttribute("srcs", BuildType.LABEL_LIST))
+ .containsExactlyElementsIn(
+ ImmutableList.of(
+ ImmutableList.of(Label.create("a", "a.sh")),
+ ImmutableList.of(Label.create("a", "b.sh")),
+ ImmutableList.of(Label.create("a", "default.sh"))));
}
public void testGetPossibleValuesWithConcatenatedSelects() throws Exception {
@@ -80,13 +79,13 @@ public class AggregatingAttributeMapperTest extends AbstractAttributeMapperTest
" '//conditions:a2': ['a2.sh'],",
" '//conditions:b2': ['b2.sh']})",
" )");
- assertSameContents(
- ImmutableList.of(
- ImmutableList.of(Label.create("a", "a1.sh"), Label.create("a", "a2.sh")),
- ImmutableList.of(Label.create("a", "a1.sh"), Label.create("a", "b2.sh")),
- ImmutableList.of(Label.create("a", "b1.sh"), Label.create("a", "a2.sh")),
- ImmutableList.of(Label.create("a", "b1.sh"), Label.create("a", "b2.sh"))),
- AggregatingAttributeMapper.of(rule).visitAttribute("srcs", BuildType.LABEL_LIST));
+ assertThat(AggregatingAttributeMapper.of(rule).visitAttribute("srcs", BuildType.LABEL_LIST))
+ .containsExactlyElementsIn(
+ ImmutableList.of(
+ ImmutableList.of(Label.create("a", "a1.sh"), Label.create("a", "a2.sh")),
+ ImmutableList.of(Label.create("a", "a1.sh"), Label.create("a", "b2.sh")),
+ ImmutableList.of(Label.create("a", "b1.sh"), Label.create("a", "a2.sh")),
+ ImmutableList.of(Label.create("a", "b1.sh"), Label.create("a", "b2.sh"))));
}
/**
@@ -102,10 +101,9 @@ public class AggregatingAttributeMapperTest extends AbstractAttributeMapperTest
}
ruleDef.append(")");
Rule rule = createRule("a", "gen", ruleDef.toString());
- assertSameContents(
- ImmutableList.of("abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"),
- // Naive evaluation would visit 2^26 cases and either overflow memory or timeout the test.
- AggregatingAttributeMapper.of(rule).visitAttribute("cmd", Type.STRING));
+ // Naive evaluation would visit 2^26 cases and either overflow memory or timeout the test.
+ assertThat(AggregatingAttributeMapper.of(rule).visitAttribute("cmd", Type.STRING))
+ .containsExactly("abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
}
/**
@@ -123,10 +121,10 @@ public class AggregatingAttributeMapperTest extends AbstractAttributeMapperTest
VisitationRecorder recorder = new VisitationRecorder();
AggregatingAttributeMapper.of(rule).visitLabels(recorder);
- assertSameContents(
- ImmutableList.of(
- "//a:a.sh", "//a:b.sh", "//a:default.sh", "//conditions:a", "//conditions:b"),
- recorder.labelsVisited);
+ assertThat(recorder.labelsVisited)
+ .containsExactlyElementsIn(
+ ImmutableList.of(
+ "//a:a.sh", "//a:b.sh", "//a:default.sh", "//conditions:a", "//conditions:b"));
}
public void testGetReachableLabels() throws Exception {
@@ -153,10 +151,9 @@ public class AggregatingAttributeMapperTest extends AbstractAttributeMapperTest
Label.create("conditions", "c"), Label.create("conditions", "d"));
AggregatingAttributeMapper mapper = AggregatingAttributeMapper.of(rule);
- assertSameContents(
- Iterables.concat(valueLabels, keyLabels),
- mapper.getReachableLabels("srcs", true));
- assertSameContents(valueLabels, mapper.getReachableLabels("srcs", false));
+ assertThat(mapper.getReachableLabels("srcs", true))
+ .containsExactlyElementsIn(Iterables.concat(valueLabels, keyLabels));
+ assertThat(mapper.getReachableLabels("srcs", false)).containsExactlyElementsIn(valueLabels);
}
public void testDuplicateCheckOnNullValues() throws Exception {
@@ -170,6 +167,7 @@ public class AggregatingAttributeMapperTest extends AbstractAttributeMapperTest
AggregatingAttributeMapper mapper = AggregatingAttributeMapper.of(rule);
Attribute launcherAttribute = mapper.getAttributeDefinition("launcher");
assertNull(mapper.get(launcherAttribute.getName(), launcherAttribute.getType()));
- assertSameContents(ImmutableList.of(), mapper.checkForDuplicateLabels(launcherAttribute));
+ assertThat(mapper.checkForDuplicateLabels(launcherAttribute))
+ .containsExactlyElementsIn(ImmutableList.of());
}
}
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/select/RawAttributeMapperTest.java b/src/test/java/com/google/devtools/build/lib/analysis/select/RawAttributeMapperTest.java
index bed3c97dd4..fad95ffce5 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/select/RawAttributeMapperTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/select/RawAttributeMapperTest.java
@@ -14,7 +14,6 @@
package com.google.devtools.build.lib.analysis.select;
import static com.google.common.truth.Truth.assertThat;
-import static com.google.devtools.build.lib.testutil.MoreAsserts.assertSameContents;
import com.google.common.collect.ImmutableSet;
import com.google.devtools.build.lib.cmdline.Label;
@@ -101,12 +100,12 @@ public class RawAttributeMapperTest extends AbstractAttributeMapperTest {
public void testGetConfigurabilityKeys() throws Exception {
RawAttributeMapper rawMapper = RawAttributeMapper.of(setupGenRule());
- assertSameContents(
- ImmutableSet.of(
- Label.parseAbsolute("//conditions:a"),
- Label.parseAbsolute("//conditions:b"),
- Label.parseAbsolute("//conditions:default")),
- rawMapper.getConfigurabilityKeys("srcs", BuildType.LABEL_LIST));
+ assertThat(rawMapper.getConfigurabilityKeys("srcs", BuildType.LABEL_LIST))
+ .containsExactlyElementsIn(
+ ImmutableSet.of(
+ Label.parseAbsolute("//conditions:a"),
+ Label.parseAbsolute("//conditions:b"),
+ Label.parseAbsolute("//conditions:default")));
assertThat(rawMapper.getConfigurabilityKeys("data", BuildType.LABEL_LIST)).isEmpty();
}
diff --git a/src/test/java/com/google/devtools/build/lib/packages/BuildTypeTest.java b/src/test/java/com/google/devtools/build/lib/packages/BuildTypeTest.java
index 9cec42f877..ab5f613734 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/BuildTypeTest.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/BuildTypeTest.java
@@ -14,7 +14,6 @@
package com.google.devtools.build.lib.packages;
import static com.google.common.truth.Truth.assertThat;
-import static com.google.devtools.build.lib.testutil.MoreAsserts.assertSameContents;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -92,7 +91,7 @@ public class BuildTypeTest {
Label.parseAbsolute("//conditions:a"), Label.create("a", "a"),
Label.parseAbsolute("//conditions:b"), Label.create("b", "b"),
Label.parseAbsolute(BuildType.Selector.DEFAULT_CONDITION_KEY), Label.create("d", "d"));
- assertSameContents(expectedMap.entrySet(), selector.getEntries().entrySet());
+ assertThat(selector.getEntries().entrySet()).containsExactlyElementsIn(expectedMap.entrySet());
}
/**
@@ -153,25 +152,25 @@ public class BuildTypeTest {
ImmutableList.of(selector1, selector2), null, currentRule, BuildType.LABEL_LIST);
assertEquals(BuildType.LABEL_LIST, selectorList.getOriginalType());
- assertSameContents(
- ImmutableSet.of(
- Label.parseAbsolute("//conditions:a"), Label.parseAbsolute("//conditions:b"),
- Label.parseAbsolute("//conditions:c"), Label.parseAbsolute("//conditions:d")),
- selectorList.getKeyLabels());
+ assertThat(selectorList.getKeyLabels())
+ .containsExactlyElementsIn(
+ ImmutableSet.of(
+ Label.parseAbsolute("//conditions:a"), Label.parseAbsolute("//conditions:b"),
+ Label.parseAbsolute("//conditions:c"), Label.parseAbsolute("//conditions:d")));
List<Selector<List<Label>>> selectors = selectorList.getSelectors();
- assertSameContents(
- ImmutableMap.of(
- Label.parseAbsolute("//conditions:a"), ImmutableList.of(Label.create("a", "a")),
- Label.parseAbsolute("//conditions:b"), ImmutableList.of(Label.create("b", "b")))
- .entrySet(),
- selectors.get(0).getEntries().entrySet());
- assertSameContents(
- ImmutableMap.of(
- Label.parseAbsolute("//conditions:c"), ImmutableList.of(Label.create("c", "c")),
- Label.parseAbsolute("//conditions:d"), ImmutableList.of(Label.create("d", "d")))
- .entrySet(),
- selectors.get(1).getEntries().entrySet());
+ assertThat(selectors.get(0).getEntries().entrySet())
+ .containsExactlyElementsIn(
+ ImmutableMap.of(
+ Label.parseAbsolute("//conditions:a"), ImmutableList.of(Label.create("a", "a")),
+ Label.parseAbsolute("//conditions:b"), ImmutableList.of(Label.create("b", "b")))
+ .entrySet());
+ assertThat(selectors.get(1).getEntries().entrySet())
+ .containsExactlyElementsIn(
+ ImmutableMap.of(
+ Label.parseAbsolute("//conditions:c"), ImmutableList.of(Label.create("c", "c")),
+ Label.parseAbsolute("//conditions:d"), ImmutableList.of(Label.create("d", "d")))
+ .entrySet());
}
@Test
@@ -207,18 +206,20 @@ public class BuildTypeTest {
Object converted = BuildType
.selectableConvert(BuildType.LABEL_LIST, nativeInput, null, currentRule);
assertTrue(converted instanceof List<?>);
- assertSameContents(expectedLabels, (List<Label>) converted);
+ assertThat((List<Label>) converted).containsExactlyElementsIn(expectedLabels);
// Conversion to selectable type:
converted = BuildType
.selectableConvert(BuildType.LABEL_LIST, selectableInput, null, currentRule);
BuildType.SelectorList<?> selectorList = (BuildType.SelectorList<?>) converted;
- assertSameContents(
- ImmutableMap.of(
- Label.parseAbsolute("//conditions:a"), expectedLabels,
- Label.parseAbsolute(BuildType.Selector.DEFAULT_CONDITION_KEY),
- expectedLabels).entrySet(),
- ((Selector<Label>) selectorList.getSelectors().get(0)).getEntries().entrySet());
+ assertThat(((Selector<Label>) selectorList.getSelectors().get(0)).getEntries().entrySet())
+ .containsExactlyElementsIn(
+ ImmutableMap.of(
+ Label.parseAbsolute("//conditions:a"),
+ expectedLabels,
+ Label.parseAbsolute(BuildType.Selector.DEFAULT_CONDITION_KEY),
+ expectedLabels)
+ .entrySet());
}
/**
diff --git a/src/test/java/com/google/devtools/build/lib/packages/PackageGroupTest.java b/src/test/java/com/google/devtools/build/lib/packages/PackageGroupTest.java
index 5d2ab8d8bf..f5c540a383 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/PackageGroupTest.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/PackageGroupTest.java
@@ -13,13 +13,13 @@
// limitations under the License.
package com.google.devtools.build.lib.packages;
+import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import com.google.common.collect.ImmutableList;
import com.google.devtools.build.lib.events.util.EventCollectionApparatus;
import com.google.devtools.build.lib.packages.util.PackageFactoryApparatus;
-import com.google.devtools.build.lib.testutil.MoreAsserts;
import com.google.devtools.build.lib.testutil.Scratch;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
@@ -126,8 +126,8 @@ public class PackageGroupTest {
public void testEverythingSpecificationWorks() throws Exception {
scratch.file("fruits/BUILD", "package_group(name = 'mango', packages = ['//...'])");
PackageGroup packageGroup = getPackageGroup("fruits", "mango");
- MoreAsserts.assertSameContents(
- ImmutableList.of(PackageSpecification.EVERYTHING), packageGroup.getPackageSpecifications());
+ assertThat(packageGroup.getPackageSpecifications())
+ .containsExactlyElementsIn(ImmutableList.of(PackageSpecification.EVERYTHING));
}
private Package getPackage(String packageName) throws Exception {
diff --git a/src/test/java/com/google/devtools/build/lib/runtime/AbstractCommandTest.java b/src/test/java/com/google/devtools/build/lib/runtime/AbstractCommandTest.java
index 7abb490bfd..3f745ce2cf 100644
--- a/src/test/java/com/google/devtools/build/lib/runtime/AbstractCommandTest.java
+++ b/src/test/java/com/google/devtools/build/lib/runtime/AbstractCommandTest.java
@@ -13,9 +13,11 @@
// limitations under the License.
package com.google.devtools.build.lib.runtime;
+import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertEquals;
+
import com.google.common.collect.ImmutableList;
import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider;
-import com.google.devtools.build.lib.testutil.MoreAsserts;
import com.google.devtools.build.lib.util.ExitCode;
import com.google.devtools.common.options.Option;
import com.google.devtools.common.options.OptionsBase;
@@ -29,9 +31,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-
/**
* Tests {@link BlazeCommand}.
*/
@@ -79,9 +78,10 @@ public class AbstractCommandTest {
ConfiguredRuleClassProvider ruleClassProvider = new ConfiguredRuleClassProvider.Builder()
.build();
- MoreAsserts.assertSameContents(optionClassesWithDefault(FooOptions.class, BarOptions.class),
- BlazeCommandUtils.getOptions(
- TestCommand.class, ImmutableList.<BlazeModule>of(), ruleClassProvider));
+ assertThat(
+ BlazeCommandUtils.getOptions(
+ TestCommand.class, ImmutableList.<BlazeModule>of(), ruleClassProvider))
+ .containsExactlyElementsIn(optionClassesWithDefault(FooOptions.class, BarOptions.class));
}
/***************************************************************************
@@ -100,12 +100,14 @@ public class AbstractCommandTest {
public void testOptionsAreInherited() {
ConfiguredRuleClassProvider ruleClassProvider = new ConfiguredRuleClassProvider.Builder()
.build();
- MoreAsserts.assertSameContents(optionClassesWithDefault(FooOptions.class),
- BlazeCommandUtils.getOptions(
- CommandA.class, ImmutableList.<BlazeModule>of(), ruleClassProvider));
- MoreAsserts.assertSameContents(optionClassesWithDefault(FooOptions.class, BarOptions.class),
- BlazeCommandUtils.getOptions(
- CommandB.class, ImmutableList.<BlazeModule>of(), ruleClassProvider));
+ assertThat(
+ BlazeCommandUtils.getOptions(
+ CommandA.class, ImmutableList.<BlazeModule>of(), ruleClassProvider))
+ .containsExactlyElementsIn(optionClassesWithDefault(FooOptions.class));
+ assertThat(
+ BlazeCommandUtils.getOptions(
+ CommandB.class, ImmutableList.<BlazeModule>of(), ruleClassProvider))
+ .containsExactlyElementsIn(optionClassesWithDefault(FooOptions.class, BarOptions.class));
}
private Collection<Class<?>> optionClassesWithDefault(Class<?>... optionClasses) {
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/GlobFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/GlobFunctionTest.java
index e38d037dd0..8aa1422da2 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/GlobFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/GlobFunctionTest.java
@@ -31,7 +31,6 @@ import com.google.devtools.build.lib.events.NullEventHandler;
import com.google.devtools.build.lib.pkgcache.PathPackageLocator;
import com.google.devtools.build.lib.skyframe.GlobValue.InvalidGlobPatternException;
import com.google.devtools.build.lib.testutil.ManualClock;
-import com.google.devtools.build.lib.testutil.MoreAsserts;
import com.google.devtools.build.lib.util.BlazeClock;
import com.google.devtools.build.lib.util.io.TimestampGranularityMonitor;
import com.google.devtools.build.lib.vfs.Dirent;
@@ -319,10 +318,10 @@ public abstract class GlobFunctionTest {
private void assertGlobMatches(boolean excludeDirs, String pattern, String... expecteds)
throws Exception {
- MoreAsserts.assertSameContents(
- ImmutableList.copyOf(expecteds),
- Iterables.transform(
- runGlob(excludeDirs, pattern).getMatches(), Functions.toStringFunction()));
+ assertThat(
+ Iterables.transform(
+ runGlob(excludeDirs, pattern).getMatches(), Functions.toStringFunction()))
+ .containsExactlyElementsIn(ImmutableList.copyOf(expecteds));
}
private void assertGlobsEqual(String pattern1, String pattern2) throws Exception {
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/TypeTest.java b/src/test/java/com/google/devtools/build/lib/syntax/TypeTest.java
index 000272bd2b..be325a31df 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/TypeTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/TypeTest.java
@@ -14,7 +14,6 @@
package com.google.devtools.build.lib.syntax;
import static com.google.common.truth.Truth.assertThat;
-import static com.google.devtools.build.lib.testutil.MoreAsserts.assertSameContents;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
@@ -181,17 +180,18 @@ public class TypeTest {
@Test
public void testTagConversion() throws Exception {
- assertSameContents(Sets.newHashSet("attribute"),
- Type.BOOLEAN.toTagSet(true, "attribute"));
- assertSameContents(Sets.newHashSet("noattribute"),
- Type.BOOLEAN.toTagSet(false, "attribute"));
-
- assertSameContents(Sets.newHashSet("whiskey"),
- Type.STRING.toTagSet("whiskey", "preferred_cocktail"));
-
- assertSameContents(Sets.newHashSet("cheddar", "ementaler", "gruyere"),
- Type.STRING_LIST.toTagSet(
- Lists.newArrayList("cheddar", "ementaler", "gruyere"), "cheeses"));
+ assertThat(Type.BOOLEAN.toTagSet(true, "attribute"))
+ .containsExactlyElementsIn(Sets.newHashSet("attribute"));
+ assertThat(Type.BOOLEAN.toTagSet(false, "attribute"))
+ .containsExactlyElementsIn(Sets.newHashSet("noattribute"));
+
+ assertThat(Type.STRING.toTagSet("whiskey", "preferred_cocktail"))
+ .containsExactlyElementsIn(Sets.newHashSet("whiskey"));
+
+ assertThat(
+ Type.STRING_LIST.toTagSet(
+ Lists.newArrayList("cheddar", "ementaler", "gruyere"), "cheeses"))
+ .containsExactlyElementsIn(Sets.newHashSet("cheddar", "ementaler", "gruyere"));
}
@Test
diff --git a/src/test/java/com/google/devtools/build/lib/testutil/MoreAsserts.java b/src/test/java/com/google/devtools/build/lib/testutil/MoreAsserts.java
index c8c0d7bf4c..37e8675f22 100644
--- a/src/test/java/com/google/devtools/build/lib/testutil/MoreAsserts.java
+++ b/src/test/java/com/google/devtools/build/lib/testutil/MoreAsserts.java
@@ -51,34 +51,6 @@ import java.util.regex.Pattern;
*/
public class MoreAsserts {
- public static void assertContainsRegex(String regex, String actual) {
- assertThat(actual).containsMatch(regex);
- }
-
- public static void assertContainsRegex(String msg, String regex, String actual) {
- assertWithMessage(msg).that(actual).containsMatch(regex);
- }
-
- public static void assertNotContainsRegex(String regex, String actual) {
- assertThat(actual).doesNotContainMatch(regex);
- }
-
- public static void assertNotContainsRegex(String msg, String regex, String actual) {
- assertWithMessage(msg).that(actual).doesNotContainMatch(regex);
- }
-
- public static void assertMatchesRegex(String regex, String actual) {
- assertThat(actual).matches(regex);
- }
-
- public static void assertMatchesRegex(String msg, String regex, String actual) {
- assertWithMessage(msg).that(actual).matches(regex);
- }
-
- public static void assertNotMatchesRegex(String regex, String actual) {
- assertThat(actual).doesNotMatch(regex);
- }
-
public static <T> void assertEquals(T expected, T actual, Comparator<T> comp) {
assertThat(comp.compare(expected, actual)).isEqualTo(0);
}
@@ -98,46 +70,6 @@ public class MoreAsserts {
assertThat(actual).hasSize(i);
}
- public static void assertGreaterThanOrEqual(long target, long actual) {
- assertThat(actual).isAtLeast(target);
- }
-
- public static void assertGreaterThanOrEqual(String msg, long target, long actual) {
- assertWithMessage(msg).that(actual).isAtLeast(target);
- }
-
- public static void assertGreaterThan(long target, long actual) {
- assertThat(actual).isGreaterThan(target);
- }
-
- public static void assertGreaterThan(String msg, long target, long actual) {
- assertWithMessage(msg).that(actual).isGreaterThan(target);
- }
-
- public static void assertLessThanOrEqual(long target, long actual) {
- assertThat(actual).isAtMost(target);
- }
-
- public static void assertLessThanOrEqual(String msg, long target, long actual) {
- assertWithMessage(msg).that(actual).isAtMost(target);
- }
-
- public static void assertLessThan(long target, long actual) {
- assertThat(actual).isLessThan(target);
- }
-
- public static void assertLessThan(String msg, long target, long actual) {
- assertWithMessage(msg).that(actual).isLessThan(target);
- }
-
- public static void assertEndsWith(String ending, String actual) {
- assertThat(actual).endsWith(ending);
- }
-
- public static void assertStartsWith(String prefix, String actual) {
- assertThat(actual).startsWith(prefix);
- }
-
/**
* Scans if an instance of given class is strongly reachable from a given
* object.
@@ -316,13 +248,6 @@ public class MoreAsserts {
return set;
}
- public static <T> void assertSameContents(
- Iterable<? extends T> expected, Iterable<? extends T> actual) {
- if (!Sets.newHashSet(expected).equals(Sets.newHashSet(actual))) {
- fail("got string set: " + asStringSet(actual) + "\nwant: " + asStringSet(expected));
- }
- }
-
/**
* If the specified EventCollector contains any events, an informative
* assertion fails in the context of the specified TestCase.
@@ -473,25 +398,6 @@ public class MoreAsserts {
}
/**
- * If "arguments" does not contain "expectedSubset" as a subset, an
- * informative assertion is failed in the context of the specified TestCase.
- *
- * <p>Argument order mnemonic: assert(X)ContainsSubset(Y).
- */
- public static <T> void assertContainsSubset(Iterable<T> arguments,
- Iterable<T> expectedSubset) {
- Set<T> argumentsSet = arguments instanceof Set<?>
- ? (Set<T>) arguments
- : Sets.newHashSet(arguments);
-
- for (T x : expectedSubset) {
- assertWithMessage("assertContainsSubset failed: did not find element " + x
- + "\nExpected subset = " + expectedSubset + "\nArguments = " + arguments)
- .that(argumentsSet).contains(x);
- }
- }
-
- /**
* Check to see if each element of expectedMessages is the beginning of a message
* in eventCollector, in order, as in {@link #containsSublistWithGapsAndEqualityChecker}.
* If not, an informative assertion is failed
diff --git a/src/test/java/com/google/devtools/build/lib/util/DependencySetTest.java b/src/test/java/com/google/devtools/build/lib/util/DependencySetTest.java
index c99821ae45..db1f289cc8 100644
--- a/src/test/java/com/google/devtools/build/lib/util/DependencySetTest.java
+++ b/src/test/java/com/google/devtools/build/lib/util/DependencySetTest.java
@@ -18,7 +18,6 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import com.google.common.collect.Sets;
-import com.google.devtools.build.lib.testutil.MoreAsserts;
import com.google.devtools.build.lib.testutil.Scratch;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
import com.google.devtools.build.lib.vfs.Path;
@@ -51,8 +50,7 @@ public class DependencySetTest {
" " + file1 + " \\",
" " + file2 + " ");
DependencySet depset = newDependencySet().read(dotd);
- MoreAsserts.assertSameContents(Sets.newHashSet(file1, file2),
- depset.getDependencies());
+ assertThat(depset.getDependencies()).containsExactlyElementsIn(Sets.newHashSet(file1, file2));
assertEquals(depset.getOutputFileName(), filename);
}
@@ -66,8 +64,7 @@ public class DependencySetTest {
" " + file1 + " \\\r",
" " + file2 + " ");
DependencySet depset = newDependencySet().read(dotd);
- MoreAsserts.assertSameContents(Sets.newHashSet(file1, file2),
- depset.getDependencies());
+ assertThat(depset.getDependencies()).containsExactlyElementsIn(Sets.newHashSet(file1, file2));
assertEquals(depset.getOutputFileName(), filename);
}
@@ -81,8 +78,7 @@ public class DependencySetTest {
+ " " + file1 + " \\\r"
+ " " + file2 + " ");
DependencySet depset = newDependencySet().read(dotd);
- MoreAsserts.assertSameContents(Sets.newHashSet(file1, file2),
- depset.getDependencies());
+ assertThat(depset.getDependencies()).containsExactlyElementsIn(Sets.newHashSet(file1, file2));
assertEquals(depset.getOutputFileName(), filename);
}
@@ -96,8 +92,7 @@ public class DependencySetTest {
+ " " + file1 + " \\\r\n"
+ " " + file2 + " ");
DependencySet depset = newDependencySet().read(dotd);
- MoreAsserts.assertSameContents(Sets.newHashSet(file1, file2),
- depset.getDependencies());
+ assertThat(depset.getDependencies()).containsExactlyElementsIn(Sets.newHashSet(file1, file2));
assertEquals(depset.getOutputFileName(), filename);
}
@@ -113,8 +108,8 @@ public class DependencySetTest {
" " + file2 + "\\",
" " + file3 + " " + file4);
DependencySet depset = newDependencySet().read(dotd);
- MoreAsserts.assertSameContents(Sets.newHashSet(file1, file2, file3, file4),
- depset.getDependencies());
+ assertThat(depset.getDependencies())
+ .containsExactlyElementsIn(Sets.newHashSet(file1, file2, file3, file4));
assertEquals(depset.getOutputFileName(), filename);
}
@@ -128,8 +123,7 @@ public class DependencySetTest {
" " + file1 + " \\",
" " + file2 + " ");
DependencySet depset = newDependencySet().read(dotd);
- MoreAsserts.assertSameContents(Sets.newHashSet(file1, file2),
- depset.getDependencies());
+ assertThat(depset.getDependencies()).containsExactlyElementsIn(Sets.newHashSet(file1, file2));
assertEquals(depset.getOutputFileName(), filename);
}
@@ -153,8 +147,8 @@ public class DependencySetTest {
" " + file1,
"hello2.o: \\",
" " + file2);
- MoreAsserts.assertSameContents(Sets.newHashSet(file1, file2),
- newDependencySet().read(dotd).getDependencies());
+ assertThat(newDependencySet().read(dotd).getDependencies())
+ .containsExactlyElementsIn(Sets.newHashSet(file1, file2));
}
/*
@@ -176,8 +170,8 @@ public class DependencySetTest {
"hello.o: \\",
" " + file1 + " \\",
" " + file3 + " ");
- MoreAsserts.assertSameContents(Sets.newHashSet(file1, file2, file3),
- newDependencySet().read(dotd).getDependencies());
+ assertThat(newDependencySet().read(dotd).getDependencies())
+ .containsExactly(file1, file1, file2, file3);
}
@Test
@@ -206,7 +200,7 @@ public class DependencySetTest {
depSet1.addDependency(file2);
depSet1.addDependency(file3);
depSet1.setOutputFileName(filename);
-
+
Path outfile = scratch.resolve(filename);
Path dotd = scratch.resolve("/usr/local/blah/blah/genhello/hello.d");
FileSystemUtils.createDirectoryAndParents(dotd.getParentDirectory());
@@ -237,7 +231,7 @@ public class DependencySetTest {
Path dotd = scratch.resolve(filename);
FileSystemUtils.createDirectoryAndParents(dotd.getParentDirectory());
depSet1.write(dotd, ".d");
-
+
DependencySet depSet2 = newDependencySet().read(dotd);
assertEquals(depSet1, depSet2);
// due to how pic.d files are written, absolute paths are changed into relatives
diff --git a/src/test/java/com/google/devtools/build/lib/util/DependencySetWindowsTest.java b/src/test/java/com/google/devtools/build/lib/util/DependencySetWindowsTest.java
index 298824ee1b..8fad3be22e 100644
--- a/src/test/java/com/google/devtools/build/lib/util/DependencySetWindowsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/util/DependencySetWindowsTest.java
@@ -13,8 +13,9 @@
// limitations under the License.
package com.google.devtools.build.lib.util;
+import static com.google.common.truth.Truth.assertThat;
+
import com.google.common.collect.Sets;
-import com.google.devtools.build.lib.testutil.MoreAsserts;
import com.google.devtools.build.lib.testutil.Scratch;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
@@ -49,8 +50,7 @@ public class DependencySetWindowsTest {
new PathFragment("C:/mingw/include/_mingw.h"),
new PathFragment("C:/mingw/lib/gcc/mingw32/4.8.1/include/stdarg.h"));
- MoreAsserts.assertSameContents(expected,
- newDependencySet().read(dotd).getDependencies());
+ assertThat(newDependencySet().read(dotd).getDependencies()).containsExactlyElementsIn(expected);
}
@Test
@@ -58,9 +58,9 @@ public class DependencySetWindowsTest {
Path dotd = scratch.file("/tmp/foo.d",
"bazel-out/hello-lib/cpp/hello-lib.o: \\",
"C:\\Program\\ Files\\ (x86)\\LLVM\\stddef.h");
- MoreAsserts.assertSameContents(
- Sets.newHashSet(new PathFragment("C:/Program Files (x86)/LLVM/stddef.h")),
- newDependencySet().read(dotd).getDependencies());
+ assertThat(newDependencySet().read(dotd).getDependencies())
+ .containsExactlyElementsIn(
+ Sets.newHashSet(new PathFragment("C:/Program Files (x86)/LLVM/stddef.h")));
}
@Test
@@ -83,7 +83,6 @@ public class DependencySetWindowsTest {
new PathFragment("C:/Program Files (x86)/LLVM/lib/clang/3.5.0/include/stddef.h"),
new PathFragment("C:/Program Files (x86)/LLVM/lib/clang/3.5.0/include/stdarg.h"));
- MoreAsserts.assertSameContents(expected,
- newDependencySet().read(dotd).getDependencies());
+ assertThat(newDependencySet().read(dotd).getDependencies()).containsExactlyElementsIn(expected);
}
}
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/GlobTest.java b/src/test/java/com/google/devtools/build/lib/vfs/GlobTest.java
index 2b54531b8b..e99895c69f 100644
--- a/src/test/java/com/google/devtools/build/lib/vfs/GlobTest.java
+++ b/src/test/java/com/google/devtools/build/lib/vfs/GlobTest.java
@@ -23,7 +23,6 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.collect.Ordering;
import com.google.common.util.concurrent.Uninterruptibles;
-import com.google.devtools.build.lib.testutil.MoreAsserts;
import com.google.devtools.build.lib.testutil.TestUtils;
import com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem;
@@ -228,11 +227,12 @@ public class GlobTest {
Collection<String> excludes,
String... expecteds)
throws Exception {
- MoreAsserts.assertSameContents(resolvePaths(expecteds),
- new UnixGlob.Builder(tmpPath)
- .addPatterns(pattern)
- .addExcludes(excludes)
- .globInterruptible());
+ assertThat(
+ new UnixGlob.Builder(tmpPath)
+ .addPatterns(pattern)
+ .addExcludes(excludes)
+ .globInterruptible())
+ .containsExactlyElementsIn(resolvePaths(expecteds));
}
private Set<Path> resolvePaths(String... relativePaths) {
@@ -260,11 +260,12 @@ public class GlobTest {
}
};
- MoreAsserts.assertSameContents(ImmutableList.of(tmpPath.getRelative("foo/bar/wiz/file")),
- new UnixGlob.Builder(tmpPath)
- .addPattern("foo/bar/wiz/file")
- .setFilesystemCalls(new AtomicReference<>(syscalls))
- .glob());
+ assertThat(
+ new UnixGlob.Builder(tmpPath)
+ .addPattern("foo/bar/wiz/file")
+ .setFilesystemCalls(new AtomicReference<>(syscalls))
+ .glob())
+ .containsExactlyElementsIn(ImmutableList.of(tmpPath.getRelative("foo/bar/wiz/file")));
}
@Test
@@ -455,9 +456,22 @@ public class GlobTest {
// In the non-interruptible case, the interrupt bit should be set, but the
// glob should return the correct set of full results.
assertTrue(Thread.interrupted());
- MoreAsserts.assertSameContents(resolvePaths(".", "foo", "foo/bar", "foo/bar/wiz",
- "foo/bar/wiz/file", "foo/barnacle", "foo/barnacle/wiz", "food", "food/barnacle",
- "food/barnacle/wiz", "fool", "fool/barnacle", "fool/barnacle/wiz"), result);
+ assertThat(result)
+ .containsExactlyElementsIn(
+ resolvePaths(
+ ".",
+ "foo",
+ "foo/bar",
+ "foo/bar/wiz",
+ "foo/bar/wiz/file",
+ "foo/barnacle",
+ "foo/barnacle/wiz",
+ "food",
+ "food/barnacle",
+ "food/barnacle/wiz",
+ "fool",
+ "fool/barnacle",
+ "fool/barnacle/wiz"));
assertFalse(executor.isShutdown());
executor.shutdown();
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/RecursiveGlobTest.java b/src/test/java/com/google/devtools/build/lib/vfs/RecursiveGlobTest.java
index 0c3eed22f7..ef03d69186 100644
--- a/src/test/java/com/google/devtools/build/lib/vfs/RecursiveGlobTest.java
+++ b/src/test/java/com/google/devtools/build/lib/vfs/RecursiveGlobTest.java
@@ -14,7 +14,6 @@
package com.google.devtools.build.lib.vfs;
import static com.google.common.truth.Truth.assertThat;
-import static com.google.devtools.build.lib.testutil.MoreAsserts.assertSameContents;
import static org.junit.Assert.fail;
import com.google.common.collect.ImmutableList;
@@ -177,11 +176,12 @@ public class RecursiveGlobTest {
private void assertGlobWithExcludesMatches(Collection<String> pattern,
Collection<String> excludes,
String... expecteds) throws Exception {
- assertSameContents(resolvePaths(expecteds),
- new UnixGlob.Builder(tmpPath)
- .addPatterns(pattern)
- .addExcludes(excludes)
- .globInterruptible());
+ assertThat(
+ new UnixGlob.Builder(tmpPath)
+ .addPatterns(pattern)
+ .addExcludes(excludes)
+ .globInterruptible())
+ .containsExactlyElementsIn(resolvePaths(expecteds));
}
private Set<Path> resolvePaths(String... relativePaths) {