use of com.facebook.buck.util.HumanReadableException in project buck by facebook.
the class AndroidPlatformTargetTest method testThrowsExceptionWhenAddOnsDirectoryIsMissing.
@Test
public void testThrowsExceptionWhenAddOnsDirectoryIsMissing() throws IOException {
File androidSdkDir = tempDir.newFolder();
String platformId = "Google Inc.:Google APIs:17";
AndroidDirectoryResolver androidDirectoryResolver = new FakeAndroidDirectoryResolver(Optional.of(androidSdkDir.toPath()), /* buildToolsDir */
Optional.empty(), /* androidNdkDir */
Optional.empty(), /* ndkVersion */
Optional.empty());
try {
AndroidPlatformTarget.getTargetForId(platformId, androidDirectoryResolver, /* aaptOverride */
Optional.empty());
fail("Should have thrown HumanReadableException");
} catch (HumanReadableException e) {
assertEquals(String.format("Google APIs not found in %s.\n" + "Please run '%s/tools/android sdk' and select both 'SDK Platform' and " + "'Google APIs' under Android (API 17)", new File(androidSdkDir, "add-ons/addon-google_apis-google-17/libs").getAbsolutePath(), androidSdkDir.getPath()), e.getMessage());
}
}
use of com.facebook.buck.util.HumanReadableException in project buck by facebook.
the class MultiarchFileTest method descriptionWithMultipleDifferentSdksShouldFail.
@Test
public void descriptionWithMultipleDifferentSdksShouldFail() throws Exception {
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
HumanReadableException exception = null;
try {
nodeBuilderFactory.getNodeBuilder(BuildTargetFactory.newInstance("//foo:xctest#iphoneos-i386,macosx-x86_64")).build(resolver);
} catch (HumanReadableException e) {
exception = e;
}
assertThat(exception, notNullValue());
assertThat("Should throw exception about different architectures", exception.getHumanReadableErrorMessage(), endsWith("Fat binaries can only be generated from binaries compiled for the same SDK."));
}
use of com.facebook.buck.util.HumanReadableException in project buck by facebook.
the class BuckConfigTest method testDuplicateAliasDefinitionThrows.
@Test
public void testDuplicateAliasDefinitionThrows() throws IOException, NoSuchBuildTargetException {
Reader reader = new StringReader(Joiner.on('\n').join("[alias]", "foo = //java/com/example:foo", "foo = //java/com/example:foo"));
try {
BuckConfigTestUtils.createWithDefaultFilesystem(temporaryFolder, reader);
fail("Should have thrown HumanReadableException.");
} catch (HumanReadableException e) {
assertEquals("Throw an exception if there are duplicate definitions for an alias, " + "even if the values are the same.", "Duplicate definition for foo in the [alias] section of your .buckconfig or " + ".buckconfig.local.", e.getHumanReadableErrorMessage());
}
}
use of com.facebook.buck.util.HumanReadableException in project buck by facebook.
the class BuckConfigTest method testConstructorThrowsForMalformedBuildTarget.
@Test
public void testConstructorThrowsForMalformedBuildTarget() throws IOException {
Reader reader = new StringReader(Joiner.on('\n').join("[alias]", "fb4a = :fb4a"));
ProjectFilesystem projectFilesystem = EasyMock.createMock(ProjectFilesystem.class);
EasyMock.replay(projectFilesystem);
try {
BuckConfigTestUtils.createWithDefaultFilesystem(temporaryFolder, reader);
fail("Should have thrown HumanReadableException.");
} catch (HumanReadableException e) {
assertEquals("Path in :fb4a must start with //", e.getHumanReadableErrorMessage());
}
EasyMock.verify(projectFilesystem);
}
use of com.facebook.buck.util.HumanReadableException in project buck by facebook.
the class BuckConfigTest method testUnresolvedAliasThrows.
@Test
public void testUnresolvedAliasThrows() throws IOException, NoSuchBuildTargetException {
Reader reader = new StringReader(Joiner.on('\n').join("[alias]", "foo = //java/com/example:foo", "bar = food"));
try {
BuckConfigTestUtils.createWithDefaultFilesystem(temporaryFolder, reader);
fail("Should have thrown HumanReadableException.");
} catch (HumanReadableException e) {
assertEquals("No alias for: food.", e.getHumanReadableErrorMessage());
}
}
Aggregations