use of com.facebook.buck.rules.TestCellBuilder in project buck by facebook.
the class AppleBuildRulesTest method testAppleLibraryIsXcodeTargetDescription.
@Test
public void testAppleLibraryIsXcodeTargetDescription() throws Exception {
Cell rootCell = (new TestCellBuilder()).build();
BuildTarget libraryTarget = BuildTarget.builder(rootCell.getRoot(), "//foo", "lib").build();
TargetNode<AppleLibraryDescription.Arg, ?> library = AppleLibraryBuilder.createBuilder(libraryTarget).setSrcs(ImmutableSortedSet.of()).build();
assertTrue(AppleBuildRules.isXcodeTargetDescription(library.getDescription()));
}
use of com.facebook.buck.rules.TestCellBuilder in project buck by facebook.
the class OwnersReportTest method verifyInputsWithOneOwnerAreCorrectlyReported.
/**
* Verify that owners are correctly detected:
* - one owner, multiple inputs
*/
@Test
public void verifyInputsWithOneOwnerAreCorrectlyReported() throws CmdLineException, IOException, InterruptedException {
ImmutableSet<String> inputs = ImmutableSet.of("java/somefolder/badfolder/somefile.java", "java/somefolder/perfect.java", "com/test/subtest/random.java");
ImmutableSet<Path> inputPaths = RichStream.from(inputs).map(filesystem::getPath).toImmutableSet();
for (Path path : inputPaths) {
filesystem.mkdirs(path.getParent());
filesystem.writeContentsToPath("", path);
}
BuildTarget target = BuildTargetFactory.newInstance("//base:name");
TargetNode<?, ?> targetNode = createTargetNode(target, inputPaths);
Cell cell = new TestCellBuilder().setFilesystem(filesystem).build();
OwnersReport report = OwnersReport.generateOwnersReport(cell, targetNode, inputs);
assertTrue(report.nonFileInputs.isEmpty());
assertTrue(report.nonExistentInputs.isEmpty());
assertTrue(report.inputsWithNoOwners.isEmpty());
assertEquals(inputs.size(), report.owners.size());
assertTrue(report.owners.containsKey(targetNode));
assertEquals(targetNode.getInputs(), report.owners.get(targetNode));
}
use of com.facebook.buck.rules.TestCellBuilder in project buck by facebook.
the class OwnersReportTest method verifyInputsWithoutOwnersAreCorrectlyReported.
@Test
public void verifyInputsWithoutOwnersAreCorrectlyReported() throws CmdLineException, IOException, InterruptedException {
// Inputs that should be treated as existing files
ImmutableSet<String> inputs = ImmutableSet.of("java/somefolder/badfolder/somefile.java", "java/somefolder/perfect.java", "com/test/subtest/random.java");
ImmutableSet<Path> inputPaths = RichStream.from(inputs).map(filesystem::getPath).toImmutableSet();
// Write dummy files.
for (Path path : inputPaths) {
filesystem.mkdirs(path.getParent());
filesystem.writeContentsToPath("", path);
}
BuildTarget target = BuildTargetFactory.newInstance("//base:name");
TargetNode<?, ?> targetNode = createTargetNode(target, ImmutableSet.of());
Cell cell = new TestCellBuilder().setFilesystem(filesystem).build();
OwnersReport report = OwnersReport.generateOwnersReport(cell, targetNode, inputs);
assertTrue(report.owners.isEmpty());
assertTrue(report.nonFileInputs.isEmpty());
assertTrue(report.nonExistentInputs.isEmpty());
assertEquals(inputPaths, report.inputsWithNoOwners);
}
use of com.facebook.buck.rules.TestCellBuilder in project buck by facebook.
the class OwnersReportTest method verifyInputsWithMultipleOwnersAreCorrectlyReported.
/**
* Verify that owners are correctly detected:
* - inputs that belong to multiple targets
*/
@Test
public void verifyInputsWithMultipleOwnersAreCorrectlyReported() throws CmdLineException, IOException, InterruptedException {
ImmutableSet<String> inputs = ImmutableSet.of("java/somefolder/badfolder/somefile.java", "java/somefolder/perfect.java", "com/test/subtest/random.java");
ImmutableSet<Path> inputPaths = RichStream.from(inputs).map(filesystem::getPath).toImmutableSet();
for (Path path : inputPaths) {
filesystem.mkdirs(path.getParent());
filesystem.writeContentsToPath("", path);
}
BuildTarget target1 = BuildTargetFactory.newInstance("//base/name1:name");
BuildTarget target2 = BuildTargetFactory.newInstance("//base/name2:name");
TargetNode<?, ?> targetNode1 = createTargetNode(target1, inputPaths);
TargetNode<?, ?> targetNode2 = createTargetNode(target2, inputPaths);
Cell cell = new TestCellBuilder().setFilesystem(filesystem).build();
OwnersReport report = OwnersReport.emptyReport();
report = report.updatedWith(OwnersReport.generateOwnersReport(cell, targetNode1, inputs));
report = report.updatedWith(OwnersReport.generateOwnersReport(cell, targetNode2, inputs));
assertTrue(report.nonFileInputs.isEmpty());
assertTrue(report.nonExistentInputs.isEmpty());
assertTrue(report.inputsWithNoOwners.isEmpty());
assertTrue(report.owners.containsKey(targetNode1));
assertTrue(report.owners.containsKey(targetNode2));
assertEquals(targetNode1.getInputs(), report.owners.get(targetNode1));
assertEquals(targetNode2.getInputs(), report.owners.get(targetNode2));
}
use of com.facebook.buck.rules.TestCellBuilder in project buck by facebook.
the class OwnersReportTest method verifyPathsThatAreNotFilesAreCorrectlyReported.
@Test
public void verifyPathsThatAreNotFilesAreCorrectlyReported() throws CmdLineException, IOException, InterruptedException {
filesystem.mkdirs(filesystem.getPath("java/somefolder/badfolder"));
filesystem.mkdirs(filesystem.getPath("com/test/subtest"));
// Inputs that should be treated as "non-files", i.e. as directories
ImmutableSet<String> inputs = ImmutableSet.of("java/somefolder/badfolder", "java/somefolder", "com/test/subtest");
BuildTarget target = BuildTargetFactory.newInstance("//base:name");
TargetNode<?, ?> targetNode = createTargetNode(target, ImmutableSet.of());
Cell cell = new TestCellBuilder().setFilesystem(filesystem).build();
OwnersReport report = OwnersReport.generateOwnersReport(cell, targetNode, inputs);
assertTrue(report.owners.isEmpty());
assertTrue(report.nonExistentInputs.isEmpty());
assertTrue(report.inputsWithNoOwners.isEmpty());
assertEquals(inputs, report.nonFileInputs);
}
Aggregations