use of com.facebook.buck.rules.TestCellBuilder in project buck by facebook.
the class DaemonIntegrationTest method whenAndroidNdkVersionChangesParserInvalidated.
@Test
public void whenAndroidNdkVersionChangesParserInvalidated() throws IOException, InterruptedException {
ProjectFilesystem filesystem = new ProjectFilesystem(tmp.getRoot());
BuckConfig buckConfig1 = FakeBuckConfig.builder().setSections(ImmutableMap.of("ndk", ImmutableMap.of("ndk_version", "something"))).build();
BuckConfig buckConfig2 = FakeBuckConfig.builder().setSections(ImmutableMap.of("ndk", ImmutableMap.of("ndk_version", "different"))).build();
Object daemon = Main.getDaemon(new TestCellBuilder().setBuckConfig(buckConfig1).setFilesystem(filesystem).build(), ObjectMappers.newDefaultInstance());
assertNotEquals("Daemon should be replaced when not equal.", daemon, Main.getDaemon(new TestCellBuilder().setBuckConfig(buckConfig2).setFilesystem(filesystem).build(), ObjectMappers.newDefaultInstance()));
}
use of com.facebook.buck.rules.TestCellBuilder in project buck by facebook.
the class OwnersReportTest method verifyInputsAgainstRulesThatListDirectoryInputs.
@Test
public void verifyInputsAgainstRulesThatListDirectoryInputs() throws IOException, InterruptedException {
// Inputs that should be treated as existing files
ImmutableSet<String> inputs = ImmutableSet.of("java/somefolder/badfolder/somefile.java", "java/somefolder/perfect.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, ImmutableSet.of(filesystem.getPath("java/somefolder")));
Cell cell = new TestCellBuilder().setFilesystem(filesystem).build();
OwnersReport report = OwnersReport.generateOwnersReport(cell, targetNode, inputs);
assertTrue(report.owners.containsKey(targetNode));
assertEquals(inputPaths, report.owners.get(targetNode));
assertTrue(report.nonFileInputs.isEmpty());
assertTrue(report.nonExistentInputs.isEmpty());
assertTrue(report.inputsWithNoOwners.isEmpty());
}
use of com.facebook.buck.rules.TestCellBuilder in project buck by facebook.
the class OwnersReportTest method verifyMissingFilesAreCorrectlyReported.
@Test
public void verifyMissingFilesAreCorrectlyReported() throws CmdLineException, IOException, InterruptedException {
// Inputs that should be treated as missing files
ImmutableSet<String> inputs = ImmutableSet.of("java/somefolder/badfolder/somefile.java", "java/somefolder/perfect.java", "com/test/subtest/random.java");
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.inputsWithNoOwners.isEmpty());
assertEquals(inputs, report.nonExistentInputs);
}
use of com.facebook.buck.rules.TestCellBuilder in project buck by facebook.
the class QueryCommandTest method setUp.
@Before
public void setUp() throws IOException, InterruptedException {
TestConsole console = new TestConsole();
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "query_command", tmp);
workspace.setUp();
ProjectFilesystem filesystem = new ProjectFilesystem(workspace.getDestPath().toRealPath().normalize());
Cell cell = new TestCellBuilder().setFilesystem(filesystem).build();
AndroidDirectoryResolver androidDirectoryResolver = new FakeAndroidDirectoryResolver();
ArtifactCache artifactCache = new NoopArtifactCache();
BuckEventBus eventBus = BuckEventBusFactory.newInstance();
ObjectMapper objectMapper = ObjectMappers.newDefaultInstance();
queryCommand = new QueryCommand();
queryCommand.outputAttributes = Suppliers.ofInstance(ImmutableSet.<String>of());
params = CommandRunnerParamsForTesting.createCommandRunnerParamsForTesting(console, cell, androidDirectoryResolver, artifactCache, eventBus, FakeBuckConfig.builder().build(), Platform.detect(), ImmutableMap.copyOf(System.getenv()), new FakeJavaPackageFinder(), objectMapper, Optional.empty());
executor = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
}
use of com.facebook.buck.rules.TestCellBuilder in project buck by facebook.
the class TargetsCommandTest method setUp.
@Before
public void setUp() throws IOException, InterruptedException {
console = new TestConsole();
workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "target_command", tmp);
workspace.setUp();
filesystem = new ProjectFilesystem(workspace.getDestPath().toRealPath().normalize());
Cell cell = new TestCellBuilder().setFilesystem(filesystem).build();
AndroidDirectoryResolver androidDirectoryResolver = new FakeAndroidDirectoryResolver();
ArtifactCache artifactCache = new NoopArtifactCache();
BuckEventBus eventBus = BuckEventBusFactory.newInstance();
objectMapper = ObjectMappers.newDefaultInstance();
targetsCommand = new TargetsCommand();
params = CommandRunnerParamsForTesting.createCommandRunnerParamsForTesting(console, cell, androidDirectoryResolver, artifactCache, eventBus, FakeBuckConfig.builder().build(), Platform.detect(), ImmutableMap.copyOf(System.getenv()), new FakeJavaPackageFinder(), objectMapper, Optional.empty());
executor = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
}
Aggregations