use of java.io.Reader in project buck by facebook.
the class BuckConfigTest method testReferentialAliases.
@Test
public void testReferentialAliases() throws IOException, NoSuchBuildTargetException {
Reader reader = new StringReader(Joiner.on('\n').join("[alias]", "foo = //java/com/example:foo", "bar = //java/com/example:bar", "foo_codename = foo", "", "# Do not delete these: automation builds require these aliases to exist!", "automation_foo = foo_codename", "automation_bar = bar"));
BuckConfig config = BuckConfigTestUtils.createWithDefaultFilesystem(temporaryFolder, reader);
assertEquals(ImmutableSet.of("//java/com/example:foo"), config.getBuildTargetForAliasAsString("foo"));
assertEquals(ImmutableSet.of("//java/com/example:bar"), config.getBuildTargetForAliasAsString("bar"));
assertEquals(ImmutableSet.of("//java/com/example:foo"), config.getBuildTargetForAliasAsString("foo_codename"));
assertEquals(ImmutableSet.of("//java/com/example:foo"), config.getBuildTargetForAliasAsString("automation_foo"));
assertEquals(ImmutableSet.of("//java/com/example:bar"), config.getBuildTargetForAliasAsString("automation_bar"));
assertEquals(ImmutableSet.of(), config.getBuildTargetForAliasAsString("baz"));
}
use of java.io.Reader in project buck by facebook.
the class BuckConfigTest method testGettingResourceAmountsPerRuleType.
@Test
public void testGettingResourceAmountsPerRuleType() throws IOException {
Reader reader = new StringReader(Joiner.on('\n').join("[resources_per_rule]", "some_rule = 1, 20, 3, 4", "other_rule = 4,30,2,1"));
BuckConfig config = BuckConfigTestUtils.createWithDefaultFilesystem(temporaryFolder, reader);
ImmutableMap<String, ResourceAmounts> result = config.getResourceAmountsPerRuleType();
assertEquals(ImmutableMap.of("some_rule", ResourceAmounts.of(1, 20, 3, 4), "other_rule", ResourceAmounts.of(4, 30, 2, 1)), result);
}
use of java.io.Reader in project buck by facebook.
the class BuckConfigTest method testGetBuildTargetForAlias.
@Test
public void testGetBuildTargetForAlias() throws IOException, NoSuchBuildTargetException {
Reader reader = new StringReader(Joiner.on('\n').join("[alias]", "foo = //java/com/example:foo", "bar = //java/com/example:bar", "baz = //java/com/example:foo //java/com/example:bar", "bash = "));
BuckConfig config = BuckConfigTestUtils.createWithDefaultFilesystem(temporaryFolder, reader);
assertEquals(ImmutableSet.of("//java/com/example:foo"), config.getBuildTargetForAliasAsString("foo"));
assertEquals(ImmutableSet.of("//java/com/example:bar"), config.getBuildTargetForAliasAsString("bar"));
assertEquals(ImmutableSet.of("//java/com/example:foo", "//java/com/example:bar"), config.getBuildTargetForAliasAsString("baz"));
assertEquals(ImmutableSet.of(), config.getBuildTargetForAliasAsString("bash"));
// Flavors on alias.
assertEquals(ImmutableSet.of("//java/com/example:foo#src_jar"), config.getBuildTargetForAliasAsString("foo#src_jar"));
assertEquals(ImmutableSet.of("//java/com/example:bar#fl1,fl2"), config.getBuildTargetForAliasAsString("bar#fl1,fl2"));
assertEquals(ImmutableSet.of("//java/com/example:foo#fl1,fl2", "//java/com/example:bar#fl1,fl2"), config.getBuildTargetForAliasAsString("baz#fl1,fl2"));
assertEquals(ImmutableSet.of(), config.getBuildTargetForAliasAsString("bash#fl1,fl2"));
assertEquals("Invalid alias names, such as build targets, should be tolerated by this method.", ImmutableSet.of(), config.getBuildTargetForAliasAsString("//java/com/example:foo"));
assertEquals(ImmutableSet.of(), config.getBuildTargetForAliasAsString("notathing"));
assertEquals(ImmutableSet.of(), config.getBuildTargetForAliasAsString("notathing#src_jar"));
Reader noAliasesReader = new StringReader("");
BuckConfig noAliasesConfig = BuckConfigTestUtils.createWithDefaultFilesystem(temporaryFolder, noAliasesReader);
assertEquals(ImmutableSet.of(), noAliasesConfig.getBuildTargetForAliasAsString("foo"));
assertEquals(ImmutableSet.of(), noAliasesConfig.getBuildTargetForAliasAsString("bar"));
assertEquals(ImmutableSet.of(), noAliasesConfig.getBuildTargetForAliasAsString("baz"));
}
use of java.io.Reader 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());
}
}
use of java.io.Reader in project buck by facebook.
the class BuckConfigTest method testGetMap.
@Test
public void testGetMap() throws IOException {
Reader reader = new StringReader(Joiner.on('\n').join("[section]", "args_map = key0=>val0,key1=>val1"));
BuckConfig config = BuckConfigTestUtils.createWithDefaultFilesystem(temporaryFolder, reader);
assertEquals(ImmutableMap.of("key0", "val0", "key1", "val1"), config.getMap("section", "args_map"));
}
Aggregations