use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class ParserConfigTest method shouldReturnOneThreadCountIfParallelParsingIsNotEnabled.
@Test
public void shouldReturnOneThreadCountIfParallelParsingIsNotEnabled() {
BuckConfig config = FakeBuckConfig.builder().setSections("[project]", "parsing_threads = 3", "parallel_parsing = false").build();
ParserConfig parserConfig = config.getView(ParserConfig.class);
assertFalse(parserConfig.getEnableParallelParsing());
assertEquals(1, parserConfig.getNumParsingThreads());
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class DaemonicCellStateTest method setUp.
@Before
public void setUp() throws IOException, InterruptedException {
Path root = tempDir.getRoot().toRealPath();
filesystem = new ProjectFilesystem(root);
BuckConfig config = FakeBuckConfig.builder().setFilesystem(filesystem).build();
cell = new TestCellBuilder().setFilesystem(filesystem).setBuckConfig(config).build();
state = new DaemonicCellState(cell, 1);
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class DaemonicCellStateTest method testTrackCellAgnosticTargetConfig.
@Test
public void testTrackCellAgnosticTargetConfig() throws BuildTargetException, IOException, InterruptedException {
BuckConfig config = FakeBuckConfig.builder().setFilesystem(filesystem).setSections("[project]", "track_cell_agnostic_target = false").build();
Cell cell = new TestCellBuilder().setFilesystem(filesystem).setBuckConfig(config).build();
DaemonicCellState state = new DaemonicCellState(cell, 1);
Cache<BuildTarget, Boolean> cache = state.getOrCreateCache(Boolean.class);
Path targetPath = cell.getRoot().resolve("path/to/BUCK");
BuildTarget target = BuildTargetFactory.newInstance(filesystem, "xplat//path/to:target");
cache.putComputedNodeIfNotPresent(cell, target, true);
assertEquals(Optional.of(true), cache.lookupComputedNode(cell, target));
state.putRawNodesIfNotPresentAndStripMetaEntries(targetPath, ImmutableSet.of(// Forms the target "//path/to:target"
ImmutableMap.of("buck.base_path", "path/to", "name", "target")), ImmutableSet.of(), ImmutableMap.of(), ImmutableMap.of());
assertEquals("One raw node should be invalidated", 1, state.invalidatePath(targetPath));
assertEquals("Cell-named target should not have been removed", Optional.of(true), cache.lookupComputedNode(cell, target));
// If we change the config, then eviction does happen
config = FakeBuckConfig.builder().setFilesystem(filesystem).setSections("[project]", "track_cell_agnostic_target = true").build();
cell = new TestCellBuilder().setFilesystem(filesystem).setBuckConfig(config).build();
state = new DaemonicCellState(cell, 1);
cache = state.getOrCreateCache(Boolean.class);
cache.putComputedNodeIfNotPresent(cell, target, true);
assertEquals(Optional.of(true), cache.lookupComputedNode(cell, target));
state.putRawNodesIfNotPresentAndStripMetaEntries(targetPath, ImmutableSet.of(// Forms the target "//path/to:target"
ImmutableMap.of("buck.base_path", "path/to", "name", "target")), ImmutableSet.of(), ImmutableMap.of(), ImmutableMap.of());
assertEquals("Still only one invalidated node", 1, state.invalidatePath(targetPath));
assertEquals("Cell-named target should still be invalidated", Optional.empty(), cache.lookupComputedNode(cell, target));
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class ParserConfigTest method shouldReturnThreadCountIfParallelParsingIsEnabled.
@Test
public void shouldReturnThreadCountIfParallelParsingIsEnabled() {
BuckConfig config = FakeBuckConfig.builder().setSections("[project]", "parsing_threads = 2", "parallel_parsing = true").build();
ParserConfig parserConfig = config.getView(ParserConfig.class);
assertTrue(parserConfig.getEnableParallelParsing());
assertEquals(2, parserConfig.getNumParsingThreads());
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class ParserTest method whenBuckConfigEntryChangesThenCachedRulesAreInvalidated.
@Test
public void whenBuckConfigEntryChangesThenCachedRulesAreInvalidated() throws Exception {
Path buckFile = cellRoot.resolve("BUCK");
Files.write(buckFile, Joiner.on("").join(ImmutableList.of("read_config('foo', 'bar')\n", "genrule(name = 'cake', out = 'file.txt', cmd = 'touch $OUT')\n")).getBytes(UTF_8));
BuckConfig config = FakeBuckConfig.builder().setSections(ImmutableMap.of("foo", ImmutableMap.of("bar", "value"))).setFilesystem(filesystem).build();
Cell cell = new TestCellBuilder().setFilesystem(filesystem).setBuckConfig(config).build();
parser.getAllTargetNodes(eventBus, cell, false, executorService, buckFile);
// Call filterAllTargetsInProject to request cached rules.
config = FakeBuckConfig.builder().setFilesystem(filesystem).setSections(ImmutableMap.of("foo", ImmutableMap.of("bar", "other value"))).build();
cell = new TestCellBuilder().setFilesystem(filesystem).setBuckConfig(config).build();
parser.getAllTargetNodes(eventBus, cell, false, executorService, buckFile);
// Test that the second parseBuildFile call repopulated the cache.
assertEquals("Should have invalidated.", 2, counter.calls);
}
Aggregations