diff options
author | 2017-05-30 17:00:48 +0200 | |
---|---|---|
committer | 2017-05-31 09:18:22 +0200 | |
commit | 78cfa8d1977036452f45838f739cc53debf8a615 (patch) | |
tree | 1a7aa946715e7d1b764955f3ee857ef435295ec0 /src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java | |
parent | a1fb6f26cfeaa712f447e5d41d2a98565e9ab478 (diff) |
Migrate most of the assertions to Truth that the auto-migration tool did not catch.
IntelliJ's "replace structurally" command was surprisingly useful.
RELNOTES: None.
PiperOrigin-RevId: 157463734
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java index 4f5b63e26e..88aa3c09b8 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java @@ -17,8 +17,6 @@ import static com.google.common.collect.Iterables.getOnlyElement; import static com.google.common.truth.Truth.assertThat; import static com.google.devtools.build.lib.actions.util.ActionsTestUtil.baseArtifactNames; import static com.google.devtools.build.lib.actions.util.ActionsTestUtil.baseNamesOf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -114,15 +112,16 @@ public class CcCommonTest extends BuildViewTestCase { // But we avoid creating .so files for empty libraries, // because those have a potentially significant run-time startup cost. if (emptyShouldOutputStaticLibrary()) { - assertEquals("libemptylib.a", baseNamesOf(getFilesToBuild(emptylib))); + assertThat(baseNamesOf(getFilesToBuild(emptylib))).isEqualTo("libemptylib.a"); } else { assertThat(getFilesToBuild(emptylib)).isEmpty(); } - assertTrue( - emptylib - .getProvider(CcExecutionDynamicLibrariesProvider.class) - .getExecutionDynamicLibraryArtifacts() - .isEmpty()); + assertThat( + emptylib + .getProvider(CcExecutionDynamicLibrariesProvider.class) + .getExecutionDynamicLibraryArtifacts() + .isEmpty()) + .isTrue(); } protected boolean emptyShouldOutputStaticLibrary() { @@ -132,8 +131,8 @@ public class CcCommonTest extends BuildViewTestCase { @Test public void testEmptyBinary() throws Exception { ConfiguredTarget emptybin = getConfiguredTarget("//empty:emptybinary"); - assertEquals( - "emptybinary" + OsUtils.executableExtension(), baseNamesOf(getFilesToBuild(emptybin))); + assertThat(baseNamesOf(getFilesToBuild(emptybin))) + .isEqualTo("emptybinary" + OsUtils.executableExtension()); } private List<String> getCopts(String target) throws Exception { @@ -229,11 +228,12 @@ public class CcCommonTest extends BuildViewTestCase { "cc_library(name = 'statically',", " srcs = ['statically.cc'],", " linkstatic=1)"); - assertTrue( - statically - .getProvider(CcExecutionDynamicLibrariesProvider.class) - .getExecutionDynamicLibraryArtifacts() - .isEmpty()); + assertThat( + statically + .getProvider(CcExecutionDynamicLibrariesProvider.class) + .getExecutionDynamicLibraryArtifacts() + .isEmpty()) + .isTrue(); Artifact staticallyDotA = getOnlyElement(getFilesToBuild(statically)); assertThat(getGeneratingAction(staticallyDotA)).isInstanceOf(CppLinkAction.class); PathFragment dotAPath = staticallyDotA.getExecPath(); @@ -272,7 +272,8 @@ public class CcCommonTest extends BuildViewTestCase { CppLinkAction action = (CppLinkAction) getGeneratingAction(getExecutable(target)); for (Artifact input : action.getInputs()) { String name = input.getFilename(); - assertTrue(!CppFileTypes.ARCHIVE.matches(name) && !CppFileTypes.PIC_ARCHIVE.matches(name)); + assertThat(!CppFileTypes.ARCHIVE.matches(name) && !CppFileTypes.PIC_ARCHIVE.matches(name)) + .isTrue(); } } @@ -625,7 +626,7 @@ public class CcCommonTest extends BuildViewTestCase { // make sure the binary is dependent on the static lib Action linkAction = getGeneratingAction(getOnlyElement(getFilesToBuild(theApp))); ImmutableList<Artifact> filesToBuild = ImmutableList.copyOf(getFilesToBuild(theLib)); - assertTrue(ImmutableSet.copyOf(linkAction.getInputs()).containsAll(filesToBuild)); + assertThat(ImmutableSet.copyOf(linkAction.getInputs()).containsAll(filesToBuild)).isTrue(); } @Test @@ -699,8 +700,8 @@ public class CcCommonTest extends BuildViewTestCase { } private void assertStamping(boolean enabled, String label) throws Exception { - assertEquals( - enabled, AnalysisUtils.isStampingEnabled(getRuleContext(getConfiguredTarget(label)))); + assertThat(AnalysisUtils.isStampingEnabled(getRuleContext(getConfiguredTarget(label)))) + .isEqualTo(enabled); } @Test @@ -768,7 +769,7 @@ public class CcCommonTest extends BuildViewTestCase { FileType.filterList( LinkerInputs.toLibraryArtifacts(linkingOutputs.getPreferredLibraries(true, true)), CppFileTypes.SHARED_LIBRARY); - assertEquals(sharedLibraries1, sharedLibraries2); + assertThat(sharedLibraries2).isEqualTo(sharedLibraries1); } /** Tests that shared libraries of the form "libfoo.so.1.2" are permitted within "srcs". */ |