use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class CellTest method shouldResolveNamesOfCellsAgainstThoseGivenInTheBuckConfig.
@Test
public void shouldResolveNamesOfCellsAgainstThoseGivenInTheBuckConfig() throws IOException, InterruptedException {
FileSystem vfs = Jimfs.newFileSystem(Configuration.unix());
Path root = vfs.getPath("/opt/local/");
Path cell1Root = root.resolve("repo1");
Files.createDirectories(cell1Root);
Path cell2Root = root.resolve("repo2");
Files.createDirectories(cell2Root);
ProjectFilesystem filesystem1 = new ProjectFilesystem(cell1Root.toAbsolutePath());
ProjectFilesystem filesystem2 = new ProjectFilesystem(cell2Root.toAbsolutePath());
BuckConfig config = FakeBuckConfig.builder().setFilesystem(filesystem1).setSections("[repositories]", "example = " + filesystem2.getRootPath().toString()).build();
Cell cell1 = new TestCellBuilder().setBuckConfig(config).setFilesystem(filesystem1).build();
BuildTarget target = BuildTargetFactory.newInstance(filesystem2, "//does/not:matter");
Cell other = cell1.getCell(target);
assertEquals(cell2Root, other.getFilesystem().getRootPath());
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class KnownBuildRuleTypesTest method whenJavacIsSetInBuckConfigConfiguredRulesCreateJavaLibraryRuleWithDifferentRuleKey.
@Test
public void whenJavacIsSetInBuckConfigConfiguredRulesCreateJavaLibraryRuleWithDifferentRuleKey() throws Exception {
final Path javac;
if (Platform.detect() == Platform.WINDOWS) {
javac = Paths.get("C:/Windows/system32/rundll32.exe");
} else {
javac = temporaryFolder.newExecutableFile();
}
ProjectFilesystem filesystem = new ProjectFilesystem(temporaryFolder.getRoot());
ImmutableMap<String, ImmutableMap<String, String>> sections = ImmutableMap.of("tools", ImmutableMap.of("javac", javac.toString()));
BuckConfig buckConfig = FakeBuckConfig.builder().setFilesystem(filesystem).setSections(sections).build();
KnownBuildRuleTypes buildRuleTypes = KnownBuildRuleTypesTestUtil.getDefaultKnownBuildRuleTypes(filesystem, environment);
DefaultJavaLibrary libraryRule = createJavaLibrary(buildRuleTypes);
ProcessExecutor processExecutor = createExecutor(javac.toString(), "fakeVersion 0.1");
KnownBuildRuleTypes configuredBuildRuleTypes = KnownBuildRuleTypes.createBuilder(buckConfig, filesystem, processExecutor, new FakeAndroidDirectoryResolver()).build();
DefaultJavaLibrary configuredRule = createJavaLibrary(configuredBuildRuleTypes);
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer()));
SourcePathResolver resolver = new SourcePathResolver(ruleFinder);
FakeFileHashCache hashCache = new FakeFileHashCache(ImmutableMap.of(javac, MorePaths.asByteSource(javac).hash(Hashing.sha1())));
RuleKey configuredKey = new DefaultRuleKeyFactory(0, hashCache, resolver, ruleFinder).build(configuredRule);
RuleKey libraryKey = new DefaultRuleKeyFactory(0, hashCache, resolver, ruleFinder).build(libraryRule);
assertNotEquals(libraryKey, configuredKey);
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class KnownBuildRuleTypesTest method ocamlUsesConfiguredDefaultPlatform.
@Test
public void ocamlUsesConfiguredDefaultPlatform() throws Exception {
ProjectFilesystem filesystem = new ProjectFilesystem(temporaryFolder.getRoot());
Flavor flavor = InternalFlavor.of("flavor");
ImmutableMap<String, ImmutableMap<String, String>> sections = ImmutableMap.of("cxx", ImmutableMap.of("default_platform", flavor.toString()), "cxx#" + flavor, ImmutableMap.of());
BuckConfig buckConfig = FakeBuckConfig.builder().setSections(sections).build();
KnownBuildRuleTypes knownBuildRuleTypes = KnownBuildRuleTypes.createBuilder(buckConfig, filesystem, createExecutor(), new FakeAndroidDirectoryResolver()).build();
OcamlLibraryDescription ocamlLibraryDescription = (OcamlLibraryDescription) knownBuildRuleTypes.getDescription(knownBuildRuleTypes.getBuildRuleType("ocaml_library"));
assertThat(ocamlLibraryDescription.getOcamlBuckConfig().getCxxPlatform(), Matchers.equalTo(knownBuildRuleTypes.getCxxPlatforms().getValue(flavor)));
OcamlBinaryDescription ocamlBinaryDescription = (OcamlBinaryDescription) knownBuildRuleTypes.getDescription(knownBuildRuleTypes.getBuildRuleType("ocaml_binary"));
assertThat(ocamlBinaryDescription.getOcamlBuckConfig().getCxxPlatform(), Matchers.equalTo(knownBuildRuleTypes.getCxxPlatforms().getValue(flavor)));
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class KnownBuildRuleTypesTest method canOverrideDefaultHostPlatform.
@Test
public void canOverrideDefaultHostPlatform() throws Exception {
ProjectFilesystem filesystem = new ProjectFilesystem(temporaryFolder.getRoot());
Flavor flavor = InternalFlavor.of("flavor");
String flag = "-flag";
ImmutableMap<String, ImmutableMap<String, String>> sections = ImmutableMap.of("cxx#" + flavor, ImmutableMap.of("cflags", flag));
BuckConfig buckConfig = FakeBuckConfig.builder().setSections(sections).build();
KnownBuildRuleTypes knownBuildRuleTypes = KnownBuildRuleTypes.createBuilder(buckConfig, filesystem, createExecutor(), new FakeAndroidDirectoryResolver()).build();
assertThat(knownBuildRuleTypes.getCxxPlatforms().getValue(flavor).getCflags(), Matchers.contains(flag));
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class KnownBuildRuleTypesTest method canSetDefaultPlatformToDefault.
@Test
public void canSetDefaultPlatformToDefault() throws Exception {
ProjectFilesystem filesystem = new ProjectFilesystem(temporaryFolder.getRoot());
ImmutableMap<String, ImmutableMap<String, String>> sections = ImmutableMap.of("cxx", ImmutableMap.of("default_platform", "default"));
BuckConfig buckConfig = FakeBuckConfig.builder().setSections(sections).build();
// This would throw if "default" weren't available as a platform.
KnownBuildRuleTypes.createBuilder(buckConfig, filesystem, createExecutor(), new FakeAndroidDirectoryResolver()).build();
}
Aggregations