use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class ParserTest method whenNotifiedOfContainedFileAddCachedAncestorsAreInvalidatedWithoutBoundaryChecks.
@Test
public void whenNotifiedOfContainedFileAddCachedAncestorsAreInvalidatedWithoutBoundaryChecks() throws Exception {
BuckConfig config = FakeBuckConfig.builder().setFilesystem(filesystem).setSections("[buildfile]", "includes = //java/com/facebook/defaultIncludeFile", "[project]", "check_package_boundary = false", "temp_files = ''").build();
Cell cell = new TestCellBuilder().setFilesystem(filesystem).setBuckConfig(config).build();
Path testAncestorBuildFile = tempDir.newFile("java/BUCK").toRealPath();
Files.write(testAncestorBuildFile, "java_library(name = 'root')\n".getBytes(UTF_8));
// Call parseBuildFile to populate the cache.
getRawTargetNodes(parser, eventBus, cell, false, executorService, testAncestorBuildFile);
// Process event.
WatchEvent<Path> event = createPathEvent(Paths.get("java/com/facebook/SomeClass.java"), StandardWatchEventKinds.ENTRY_CREATE);
parser.onFileSystemChange(event);
// Call parseBuildFile to request cached rules.
getRawTargetNodes(parser, eventBus, cell, false, executorService, testAncestorBuildFile);
// Test that the second parseBuildFile call repopulated the cache.
assertEquals("Should have invalidated cache.", 2, counter.calls);
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class ParserTest method defaultFlavorsInArgsOverrideDefaultsFromConfig.
@Test
public void defaultFlavorsInArgsOverrideDefaultsFromConfig() throws Exception {
// We depend on Xcode platforms for this test.
assumeTrue(Platform.detect() == Platform.MACOS);
Path buckFile = cellRoot.resolve("lib/BUCK");
Files.createDirectories(buckFile.getParent());
Files.write(buckFile, ("cxx_library(" + " name = 'lib', " + " srcs=glob(['*.c']), " + " defaults={'platform':'macosx-x86_64'}" + ")").getBytes(UTF_8));
BuckConfig config = FakeBuckConfig.builder().setFilesystem(filesystem).setSections(ImmutableMap.of("defaults.cxx_library", ImmutableMap.of("platform", "iphoneos-arm64", "type", "shared"))).build();
cell = new TestCellBuilder().setFilesystem(filesystem).setBuckConfig(config).build();
ImmutableSet<BuildTarget> result = parser.buildTargetGraphForTargetNodeSpecs(eventBus, cell, false, executorService, ImmutableList.of(AbstractBuildTargetSpec.from(BuildTarget.builder(cellRoot, "//lib", "lib").build())), /* ignoreBuckAutodepsFiles */
false, ParserConfig.ApplyDefaultFlavorsMode.ENABLED).getBuildTargets();
assertThat(result, hasItems(BuildTarget.builder(cellRoot, "//lib", "lib").addFlavors(InternalFlavor.of("macosx-x86_64"), InternalFlavor.of("shared")).build()));
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class ParserTest method whenAllRulesAreRequestedWithDifferingIncludesThenRulesAreParsedTwice.
@Test
public void whenAllRulesAreRequestedWithDifferingIncludesThenRulesAreParsedTwice() throws BuildFileParseException, BuildTargetException, IOException, InterruptedException {
filterAllTargetsInProject(parser, cell, x -> true, eventBus, executorService);
BuckConfig config = FakeBuckConfig.builder().setFilesystem(filesystem).setSections(ImmutableMap.of(ParserConfig.BUILDFILE_SECTION_NAME, ImmutableMap.of(ParserConfig.INCLUDES_PROPERTY_NAME, "//bar.py"))).build();
Cell cell = new TestCellBuilder().setFilesystem(filesystem).setBuckConfig(config).build();
filterAllTargetsInProject(parser, cell, x -> true, eventBus, executorService);
assertEquals("Should have invalidated cache.", 2, counter.calls);
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class ParserTest method whenBuckConfigEntryRemovedThenCachedRulesAreInvalidated.
@Test
public void whenBuckConfigEntryRemovedThenCachedRulesAreInvalidated() 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).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);
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class ParserTest method whenEnvironmentNotChangedThenCacheRulesAreNotInvalidated.
@Test
public void whenEnvironmentNotChangedThenCacheRulesAreNotInvalidated() throws BuildFileParseException, BuildTargetException, IOException, InterruptedException {
BuckConfig config = FakeBuckConfig.builder().setFilesystem(filesystem).setEnvironment(ImmutableMap.of("Some Key", "Some Value", "PATH", System.getenv("PATH"))).build();
Cell cell = new TestCellBuilder().setFilesystem(filesystem).setBuckConfig(config).build();
// Call filterAllTargetsInProject to populate the cache.
filterAllTargetsInProject(parser, cell, x -> true, eventBus, executorService);
// Call filterAllTargetsInProject to request cached rules with identical environment.
filterAllTargetsInProject(parser, cell, x -> true, eventBus, executorService);
// Test that the second parseBuildFile call repopulated the cache.
assertEquals("Should not have invalidated cache.", 1, counter.calls);
}
Aggregations