Migrate tests to Truth.
RELNOTES: None.
PiperOrigin-RevId: 157374805
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java
index 1728c29d..7b3064d 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java
@@ -366,7 +366,8 @@
getConfiguredTarget("//hello:hello");
fail("Should fail");
} catch (AssertionError e) {
- assertThat(e.getMessage())
+ assertThat(e)
+ .hasMessageThat()
.contains("Invalid toolchain configuration: Cannot find variable named 'bad_variable'");
}
}
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeaturesTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeaturesTest.java
index 3cd50be..a697c6e 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeaturesTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeaturesTest.java
@@ -732,7 +732,7 @@
createVariables("v1", "1", "v1", "2", "v2", "1", "v2", "2"));
fail("Expected ExpansionException");
} catch (ExpansionException e) {
- assertThat(e.getMessage()).contains("'v1' and 'v2'");
+ assertThat(e).hasMessageThat().contains("'v1' and 'v2'");
}
}
@@ -782,7 +782,7 @@
getCommandLineForFlagGroups(nestedGroup, createNestedVariables("v", 2, 3));
fail("Expected ExpansionException");
} catch (ExpansionException e) {
- assertThat(e.getMessage()).contains("'v'");
+ assertThat(e).hasMessageThat().contains("'v'");
}
try {
@@ -799,7 +799,7 @@
"}");
fail("Expected ExpansionException");
} catch (ExpansionException e) {
- assertThat(e.getMessage()).contains("Invalid toolchain configuration");
+ assertThat(e).hasMessageThat().contains("Invalid toolchain configuration");
}
}
@@ -906,7 +906,7 @@
"feature { name: '<<<collision>>>' }");
fail("Expected InvalidConfigurationException");
} catch (InvalidConfigurationException e) {
- assertThat(e.getMessage()).contains("<<<collision>>>");
+ assertThat(e).hasMessageThat().contains("<<<collision>>>");
}
}
@@ -916,7 +916,7 @@
buildFeatures("feature { name: 'a' implies: '<<<undefined>>>' }");
fail("Expected InvalidConfigurationException");
} catch (InvalidConfigurationException e) {
- assertThat(e.getMessage()).contains("<<<undefined>>>");
+ assertThat(e).hasMessageThat().contains("<<<undefined>>>");
}
}
@@ -1319,7 +1319,8 @@
noFeaturesConfiguration.getToolForAction("action-a").getToolPath(crosstoolPath);
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException e) {
- assertThat(e.getMessage())
+ assertThat(e)
+ .hasMessageThat()
.contains("Matching tool for action action-a not found for given feature configuration");
}
}
@@ -1380,7 +1381,8 @@
"}");
fail("Expected InvalidConfigurationException");
} catch (InvalidConfigurationException e) {
- assertThat(e.getMessage())
+ assertThat(e)
+ .hasMessageThat()
.contains("feature or action config 'action-a' was specified multiple times.");
}
}
@@ -1399,7 +1401,7 @@
"}");
fail("Expected InvalidConfigurationException");
} catch (InvalidConfigurationException e) {
- assertThat(e.getMessage()).contains("multiple action configs for action 'action-a'");
+ assertThat(e).hasMessageThat().contains("multiple action configs for action 'action-a'");
}
}
@@ -1436,7 +1438,8 @@
.getFeatureConfiguration("c++-compile");
fail("Should throw InvalidConfigurationException");
} catch (InvalidConfigurationException e) {
- assertThat(e.getMessage())
+ assertThat(e)
+ .hasMessageThat()
.contains(String.format(ActionConfig.FLAG_SET_WITH_ACTION_ERROR, "c++-compile"));
}
}
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionTest.java
index 254d4e9..2081445 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionTest.java
@@ -429,9 +429,12 @@
// Ensure that minima are enforced.
ResourceSet resources = linkAction.estimateResourceConsumptionLocal();
- assertTrue(resources.getMemoryMb() >= CppLinkAction.MIN_STATIC_LINK_RESOURCES.getMemoryMb());
- assertTrue(resources.getCpuUsage() >= CppLinkAction.MIN_STATIC_LINK_RESOURCES.getCpuUsage());
- assertTrue(resources.getIoUsage() >= CppLinkAction.MIN_STATIC_LINK_RESOURCES.getIoUsage());
+ assertThat(resources.getMemoryMb())
+ .isAtLeast(CppLinkAction.MIN_STATIC_LINK_RESOURCES.getMemoryMb());
+ assertThat(resources.getCpuUsage())
+ .isAtLeast(CppLinkAction.MIN_STATIC_LINK_RESOURCES.getCpuUsage());
+ assertThat(resources.getIoUsage())
+ .isAtLeast(CppLinkAction.MIN_STATIC_LINK_RESOURCES.getIoUsage());
final int linkSize = Iterables.size(linkAction.getLinkCommandLine().getLinkerInputs());
ResourceSet scaledSet = ResourceSet.createWithRamCpuIo(
@@ -513,7 +516,7 @@
builder.build();
fail();
} catch (RuntimeException e) {
- assertThat(e.getMessage()).contains(expectedSubstring);
+ assertThat(e).hasMessageThat().contains(expectedSubstring);
}
}
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CrosstoolConfigurationLoaderTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CrosstoolConfigurationLoaderTest.java
index 7c0c8ad..4647573 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CrosstoolConfigurationLoaderTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CrosstoolConfigurationLoaderTest.java
@@ -922,7 +922,7 @@
create(loader, "--cpu=cpu");
fail();
} catch (IllegalArgumentException e) {
- assertThat(e.getMessage()).contains("Tool path for 'strip' is missing");
+ assertThat(e).hasMessageThat().contains("Tool path for 'strip' is missing");
}
}
@@ -937,7 +937,7 @@
create(loader, "--cpu=cpu");
fail("Expected failed check on 'dwp' tool path");
} catch (IllegalArgumentException e) {
- assertThat(e.getMessage()).contains("Tool path for 'dwp' is missing");
+ assertThat(e).hasMessageThat().contains("Tool path for 'dwp' is missing");
}
}