use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class DistBuildFileHashesIntegrationTest method crossCellDoesNotCauseAbsolutePathSrcs.
@Test
public void crossCellDoesNotCauseAbsolutePathSrcs() throws Exception {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "cross_cell", temporaryFolder);
workspace.setUp();
ProjectFilesystem rootFs = new ProjectFilesystem(temporaryFolder.getRoot().toAbsolutePath().resolve("root_cell"));
ProjectFilesystem secondaryFs = new ProjectFilesystem(temporaryFolder.getRoot().toAbsolutePath().resolve("secondary_cell"));
BuckConfig rootCellConfig = FakeBuckConfig.builder().setFilesystem(rootFs).setSections("[repositories]", "cross_cell_secondary = " + secondaryFs.getRootPath().toAbsolutePath()).build();
Cell rootCell = new TestCellBuilder().setBuckConfig(rootCellConfig).setFilesystem(rootFs).build();
TypeCoercerFactory typeCoercerFactory = new DefaultTypeCoercerFactory(ObjectMappers.newDefaultInstance());
ConstructorArgMarshaller constructorArgMarshaller = new ConstructorArgMarshaller(typeCoercerFactory);
Parser parser = new Parser(new BroadcastEventListener(), rootCellConfig.getView(ParserConfig.class), typeCoercerFactory, constructorArgMarshaller);
TargetGraph targetGraph = parser.buildTargetGraph(BuckEventBusFactory.newInstance(), rootCell, /* enableProfiling */
false, MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()), ImmutableSet.of(BuildTargetFactory.newInstance(rootFs.getRootPath(), "//:libA")));
DistBuildTargetGraphCodec targetGraphCodec = DistBuildStateTest.createDefaultCodec(rootCell, Optional.of(parser));
BuildJobState dump = DistBuildState.dump(new DistBuildCellIndexer(rootCell), createDistBuildFileHashes(targetGraph, rootCell), targetGraphCodec, targetGraph, ImmutableSet.of(BuildTargetFactory.newInstance(rootFs.getRootPath(), "//:libA")));
assertNotNull(dump);
assertEquals(2, dump.getFileHashesSize());
List<BuildJobStateFileHashes> sortedHashes = dump.getFileHashes().stream().sorted(Comparator.comparingInt(BuildJobStateFileHashes::getCellIndex)).collect(Collectors.toList());
BuildJobStateFileHashes rootCellHashes = sortedHashes.get(0);
assertEquals(1, rootCellHashes.getEntriesSize());
assertEquals("A.java", rootCellHashes.getEntries().get(0).getPath().getPath());
BuildJobStateFileHashes secondaryCellHashes = sortedHashes.get(1);
assertEquals(1, secondaryCellHashes.getEntriesSize());
assertEquals("B.java", secondaryCellHashes.getEntries().get(0).getPath().getPath());
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class DistBuildFileHashesIntegrationTest method symlinkPathsRecordedInRootCell.
@Test
public void symlinkPathsRecordedInRootCell() throws Exception {
Assume.assumeTrue(Platform.detect() != Platform.WINDOWS);
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "symlink", temporaryFolder);
workspace.setUp();
ProjectFilesystem rootFs = new ProjectFilesystem(temporaryFolder.getRoot().toAbsolutePath().resolve("root_cell"));
Path absSymlinkFilePath = rootFs.resolve("../" + SYMLINK_FILE_NAME);
Path symLinkPath = rootFs.resolve(SYMLINK_FILE_NAME);
rootFs.createSymLink(symLinkPath, absSymlinkFilePath, false);
BuckConfig rootCellConfig = FakeBuckConfig.builder().setFilesystem(rootFs).build();
Cell rootCell = new TestCellBuilder().setBuckConfig(rootCellConfig).setFilesystem(rootFs).build();
TypeCoercerFactory typeCoercerFactory = new DefaultTypeCoercerFactory(ObjectMappers.newDefaultInstance());
ConstructorArgMarshaller constructorArgMarshaller = new ConstructorArgMarshaller(typeCoercerFactory);
Parser parser = new Parser(new BroadcastEventListener(), rootCellConfig.getView(ParserConfig.class), typeCoercerFactory, constructorArgMarshaller);
TargetGraph targetGraph = parser.buildTargetGraph(BuckEventBusFactory.newInstance(), rootCell, /* enableProfiling */
false, MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()), ImmutableSet.of(BuildTargetFactory.newInstance(rootFs.getRootPath(), "//:libA")));
DistBuildTargetGraphCodec targetGraphCodec = DistBuildStateTest.createDefaultCodec(rootCell, Optional.of(parser));
BuildJobState dump = DistBuildState.dump(new DistBuildCellIndexer(rootCell), createDistBuildFileHashes(targetGraph, rootCell), targetGraphCodec, targetGraph, ImmutableSet.of(BuildTargetFactory.newInstance(rootFs.getRootPath(), "//:libA")));
assertNotNull(dump);
assertEquals(1, dump.getFileHashesSize());
BuildJobStateFileHashes rootCellHashes = dump.getFileHashes().get(0);
assertEquals(2, rootCellHashes.getEntriesSize());
BuildJobStateFileHashEntry symLinkEntry = rootCellHashes.getEntries().stream().filter(x -> x.isSetRootSymLink()).findFirst().get();
String expectedPath = temporaryFolder.getRoot().resolve(SYMLINK_FILE_NAME).toAbsolutePath().toString();
assertEquals(MorePaths.pathWithUnixSeparators(expectedPath), symLinkEntry.getRootSymLinkTarget().getPath());
assertEquals(SYMLINK_FILE_NAME, symLinkEntry.getRootSymLink().getPath());
BuildJobStateFileHashEntry relPathEntry = rootCellHashes.getEntries().stream().filter(x -> !x.isPathIsAbsolute()).findFirst().get();
assertEquals("A.java", relPathEntry.getPath().getPath());
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class DBuckConfigTest method testDCompilerFlagsOverridden.
@Test
public void testDCompilerFlagsOverridden() throws IOException {
BuckConfig delegate = FakeBuckConfig.builder().setSections("[d]", "base_compiler_flags=-g -O3").build();
DBuckConfig dBuckConfig = new DBuckConfig(delegate);
ImmutableList<String> compilerFlags = dBuckConfig.getBaseCompilerFlags();
assertContains(compilerFlags, "-g");
assertContains(compilerFlags, "-O3");
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class DBuckConfigTest method testCompilerInPath.
@Test
public void testCompilerInPath() throws IOException {
Path yooserBeen = tmp.newFolder("yooser", "been");
Path dmd = makeFakeExecutable(yooserBeen, "dmd");
BuckConfig delegate = FakeBuckConfig.builder().setEnvironment(ImmutableMap.of("PATH", yooserBeen.toRealPath().toString())).build();
DBuckConfig dBuckConfig = new DBuckConfig(delegate);
assertEquals(dmd.toRealPath().toString(), toolPath(dBuckConfig.getDCompiler()));
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class DBuckConfigTest method testCompilerNotInPath.
@Test
public void testCompilerNotInPath() throws IOException {
Path yooserBeen = tmp.newFolder("yooser", "been");
Path userBean = tmp.newFolder("user", "bean").toRealPath();
makeFakeExecutable(yooserBeen, "dmd");
BuckConfig delegate = FakeBuckConfig.builder().setEnvironment(ImmutableMap.of("PATH", userBean.toString())).build();
DBuckConfig dBuckConfig = new DBuckConfig(delegate);
String msg = "";
Tool compiler = null;
try {
compiler = dBuckConfig.getDCompiler();
} catch (HumanReadableException e) {
msg = e.getMessage();
}
// we specify in the test.
if (delegate.getPlatform() == Platform.MACOS && msg.length() == 0) {
assertNotNull(compiler);
assertFalse(toolPath(compiler).contains(userBean.toString()));
assertFalse(toolPath(compiler).contains(yooserBeen.toString()));
} else {
assertEquals("Unable to locate dmd on PATH, or it's not marked as being executable", msg);
}
}
Aggregations