use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class DBuckConfigTest method testDLinkerFlagsOverridden.
@Test
public void testDLinkerFlagsOverridden() throws IOException {
Path yooserBin = tmp.newFolder("yooser", "bin");
Path yooserLib = tmp.newFolder("yooser", "lib");
makeFakeExecutable(yooserBin, "dmd");
Path phobos2So = yooserLib.resolve("libphobos2.so");
Files.createFile(phobos2So);
BuckConfig delegate = FakeBuckConfig.builder().setEnvironment(ImmutableMap.of("PATH", yooserBin.toRealPath().toString())).setSections("[d]", "linker_flags = -L/opt/doesnotexist/dmd/lib \"-L/path with spaces\"").build();
DBuckConfig dBuckConfig = new DBuckConfig(delegate);
ImmutableList<String> linkerFlags = dBuckConfig.getLinkerFlags();
assertContains(linkerFlags, "-L/opt/doesnotexist/dmd/lib");
assertContains(linkerFlags, "-L/path with spaces");
assertDoesNotContain(linkerFlags, "-L" + yooserLib.toRealPath());
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class DBuckConfigTest method testCompilerOverridden.
@Test
public void testCompilerOverridden() throws IOException {
Path yooserBeen = tmp.newFolder("yooser", "been");
makeFakeExecutable(yooserBeen, "dmd");
Path ldc = makeFakeExecutable(yooserBeen, "ldc");
BuckConfig delegate = FakeBuckConfig.builder().setEnvironment(ImmutableMap.of("PATH", yooserBeen.toRealPath().toString())).setSections("[d]", "compiler=" + ldc.toRealPath()).build();
DBuckConfig dBuckConfig = new DBuckConfig(delegate);
assertEquals(ldc.toRealPath().toString(), toolPath(dBuckConfig.getDCompiler()));
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class DBuckConfigTest method testDRuntimeNearCompiler.
@Test
public void testDRuntimeNearCompiler() throws IOException {
Path yooserBin = tmp.newFolder("yooser", "bin");
Path yooserLib = tmp.newFolder("yooser", "lib");
makeFakeExecutable(yooserBin, "dmd");
Path phobos2So = yooserLib.resolve("libphobos2.so");
Files.createFile(phobos2So);
BuckConfig delegate = FakeBuckConfig.builder().setEnvironment(ImmutableMap.of("PATH", yooserBin.toRealPath().toString())).build();
DBuckConfig dBuckConfig = new DBuckConfig(delegate);
ImmutableList<String> linkerFlags = dBuckConfig.getLinkerFlags();
assertContains(linkerFlags, "-L" + yooserLib.toRealPath());
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class DistBuildStateTest method throwsOnPlatformMismatch.
@Test
public void throwsOnPlatformMismatch() throws IOException, InterruptedException {
ProjectFilesystem filesystem = createJavaOnlyFilesystem("/opt/buck");
Config config = new Config(ConfigBuilder.rawFromLines());
BuckConfig buckConfig = new BuckConfig(config, filesystem, Architecture.MIPSEL, Platform.UNKNOWN, ImmutableMap.<String, String>builder().putAll(System.getenv()).put("envKey", "envValue").build(), new DefaultCellPathResolver(filesystem.getRootPath(), config));
Cell cell = new TestCellBuilder().setFilesystem(filesystem).setBuckConfig(buckConfig).build();
BuildJobState dump = DistBuildState.dump(new DistBuildCellIndexer(cell), emptyActionGraph(), createDefaultCodec(cell, Optional.empty()), createTargetGraph(filesystem), ImmutableSet.of(BuildTargetFactory.newInstance(filesystem.getRootPath(), "//:dummy")));
expectedException.expect(IllegalStateException.class);
DistBuildState.load(Optional.empty(), dump, cell, knownBuildRuleTypesFactory);
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class DistBuildStateTest method worksCrossCell.
@Test
public void worksCrossCell() throws IOException, InterruptedException {
ProjectFilesystem parentFs = createJavaOnlyFilesystem("/saving");
Path cell1Root = parentFs.resolve("cell1");
Path cell2Root = parentFs.resolve("cell2");
parentFs.mkdirs(cell1Root);
parentFs.mkdirs(cell2Root);
ProjectFilesystem cell1Filesystem = new ProjectFilesystem(cell1Root);
ProjectFilesystem cell2Filesystem = new ProjectFilesystem(cell2Root);
Config config = new Config(ConfigBuilder.rawFromLines("[cache]", "repository=somerepo", "[repositories]", "cell2 = " + cell2Root.toString()));
BuckConfig buckConfig = new BuckConfig(config, cell1Filesystem, Architecture.detect(), Platform.detect(), ImmutableMap.<String, String>builder().putAll(System.getenv()).put("envKey", "envValue").build(), new DefaultCellPathResolver(cell1Root, config));
Cell rootCellWhenSaving = new TestCellBuilder().setFilesystem(cell1Filesystem).setBuckConfig(buckConfig).build();
BuildJobState dump = DistBuildState.dump(new DistBuildCellIndexer(rootCellWhenSaving), emptyActionGraph(), createDefaultCodec(rootCellWhenSaving, Optional.empty()), createCrossCellTargetGraph(cell1Filesystem, cell2Filesystem), ImmutableSet.of(BuildTargetFactory.newInstance(cell1Filesystem.getRootPath(), "//:dummy")));
Cell rootCellWhenLoading = new TestCellBuilder().setFilesystem(createJavaOnlyFilesystem("/loading")).build();
Config localConfig = new Config(ConfigBuilder.rawFromLines("[cache]", "slb_server_pool=http://someserver:8080"));
BuckConfig localBuckConfig = new BuckConfig(localConfig, cell1Filesystem, Architecture.detect(), Platform.detect(), ImmutableMap.<String, String>builder().putAll(System.getenv()).put("envKey", "envValue").build(), new DefaultCellPathResolver(cell1Root, localConfig));
DistBuildState distributedBuildState = DistBuildState.load(Optional.of(localBuckConfig), dump, rootCellWhenLoading, knownBuildRuleTypesFactory);
ImmutableMap<Integer, Cell> cells = distributedBuildState.getCells();
assertThat(cells, Matchers.aMapWithSize(2));
BuckConfig rootCellBuckConfig = cells.get(0).getBuckConfig();
Optional<ImmutableMap<String, String>> cacheSection = rootCellBuckConfig.getSection("cache");
assertTrue(cacheSection.isPresent());
assertTrue(cacheSection.get().containsKey("repository"));
assertThat(cacheSection.get().get("repository"), Matchers.equalTo("somerepo"));
assertThat(cacheSection.get().get("slb_server_pool"), Matchers.equalTo("http://someserver:8080"));
}
Aggregations