use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class StackedDownloaderTest method shouldUseRetryingDownloaderIfMaxNumberOfRetriesIsSet.
@Test
public void shouldUseRetryingDownloaderIfMaxNumberOfRetriesIsSet() throws IOException {
BuckConfig config = FakeBuckConfig.builder().setSections("[download]", "max_number_of_retries = 1").build();
Downloader downloader = StackedDownloader.createFromConfig(config, Optional.empty());
assertThat(downloader, includes(RetryingDownloader.class));
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class StackedDownloaderTest method createDownloadersForEachEntryInTheMavenRepositoriesSection.
@Test
public void createDownloadersForEachEntryInTheMavenRepositoriesSection() throws IOException {
boolean isWindows = Platform.detect() == Platform.WINDOWS;
Configuration configuration = isWindows ? Configuration.windows() : Configuration.unix();
FileSystem vfs = Jimfs.newFileSystem(configuration);
Path m2Root = vfs.getPath(jimfAbsolutePath("/home/user/.m2/repository"));
Files.createDirectories(m2Root);
// Set up a config so we expect to see both a local and a remote maven repo.
Path projectRoot = vfs.getPath(jimfAbsolutePath("/opt/local/src"));
Files.createDirectories(projectRoot);
BuckConfig config = FakeBuckConfig.builder().setFilesystem(new ProjectFilesystem(projectRoot)).setSections("[maven_repositories]", "local = " + m2Root.toString(), "central = https://repo1.maven.org/maven2").build();
Downloader downloader = StackedDownloader.createFromConfig(config, Optional.empty());
List<Downloader> downloaders = unpackDownloaders(downloader);
boolean seenRemote = false;
boolean seenLocal = false;
for (Downloader seen : downloaders) {
if (seen instanceof RemoteMavenDownloader) {
seenRemote = true;
} else if (seen instanceof OnDiskMavenDownloader) {
seenLocal = true;
}
}
assertTrue(seenLocal);
assertTrue(seenRemote);
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class JavaBuckConfigTest method whenJavacIsNotSetInBuckConfigConfiguredRulesCreateJavaLibraryRuleWithJsr199Javac.
@Test
public void whenJavacIsNotSetInBuckConfigConfiguredRulesCreateJavaLibraryRuleWithJsr199Javac() throws IOException, NoSuchBuildTargetException, InterruptedException {
BuckConfig buckConfig = FakeBuckConfig.builder().build();
JavaBuckConfig javaConfig = buckConfig.getView(JavaBuckConfig.class);
JavacOptions javacOptions = javaConfig.getDefaultJavacOptions();
Javac javac = javacOptions.getJavac();
assertTrue(javac.getClass().toString(), javac instanceof Jsr199Javac);
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class MissingSymbolsHandlerIntegrationTest method shouldFindNeededDependenciesFromSymbols.
@Test
public void shouldFindNeededDependenciesFromSymbols() throws IOException, InterruptedException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "symbol_finder", temporaryFolder);
workspace.setUp();
ProjectFilesystem projectFilesystem = new ProjectFilesystem(temporaryFolder.getRoot());
ImmutableMap<String, String> environment = ImmutableMap.copyOf(System.getenv());
Config rawConfig = Configs.createDefaultConfig(projectFilesystem.getRootPath());
BuckConfig config = new BuckConfig(rawConfig, projectFilesystem, Architecture.detect(), Platform.detect(), environment, new DefaultCellPathResolver(projectFilesystem.getRootPath(), rawConfig));
ImmutableSet<Description<?>> allDescriptions = KnownBuildRuleTypesTestUtil.getDefaultKnownBuildRuleTypes(projectFilesystem, environment).getAllDescriptions();
BuckEventBus buckEventBus = BuckEventBusFactory.newInstance();
MissingSymbolsHandler missingSymbolsHandler = MissingSymbolsHandler.create(projectFilesystem, allDescriptions, config, buckEventBus, new TestConsole(), DEFAULT_JAVAC_OPTIONS, environment);
MissingSymbolEvent missingSymbolEvent = MissingSymbolEvent.create(BuildTargetFactory.newInstance(workspace.getDestPath(), "//java/com/example/b:b"), "com.example.a.A", MissingSymbolEvent.SymbolType.Java);
ImmutableSetMultimap<BuildTarget, BuildTarget> neededDeps = missingSymbolsHandler.getNeededDependencies(ImmutableList.of(missingSymbolEvent));
assertEquals("MissingSymbolsHandler failed to find the needed dependency.", neededDeps, ImmutableSetMultimap.of(BuildTargetFactory.newInstance(workspace.getDestPath(), "//java/com/example/b:b"), BuildTargetFactory.newInstance(workspace.getDestPath(), "//java/com/example/a:a")));
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class JavaSymbolFinderIntegrationTest method shouldFindTargetDefiningSymbol.
@Test
public void shouldFindTargetDefiningSymbol() throws IOException, InterruptedException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "symbol_finder", temporaryFolder);
workspace.setUp();
ProjectFilesystem projectFilesystem = new ProjectFilesystem(temporaryFolder.getRoot());
ImmutableMap<String, String> environment = ImmutableMap.copyOf(System.getenv());
Config rawConfig = Configs.createDefaultConfig(projectFilesystem.getRootPath());
BuckConfig config = new BuckConfig(rawConfig, projectFilesystem, Architecture.detect(), Platform.detect(), environment, new DefaultCellPathResolver(projectFilesystem.getRootPath(), rawConfig));
ParserConfig parserConfig = config.getView(ParserConfig.class);
PythonBuckConfig pythonBuckConfig = new PythonBuckConfig(config, new ExecutableFinder());
ImmutableSet<Description<?>> allDescriptions = KnownBuildRuleTypesTestUtil.getDefaultKnownBuildRuleTypes(projectFilesystem, environment).getAllDescriptions();
SrcRootsFinder srcRootsFinder = new SrcRootsFinder(projectFilesystem);
ProjectBuildFileParserFactory projectBuildFileParserFactory = new DefaultProjectBuildFileParserFactory(ProjectBuildFileParserOptions.builder().setProjectRoot(projectFilesystem.getRootPath()).setPythonInterpreter(pythonBuckConfig.getPythonInterpreter()).setAllowEmptyGlobs(parserConfig.getAllowEmptyGlobs()).setIgnorePaths(projectFilesystem.getIgnorePaths()).setBuildFileName(parserConfig.getBuildFileName()).setDefaultIncludes(parserConfig.getDefaultIncludes()).setDescriptions(allDescriptions).setBuildFileImportWhitelist(parserConfig.getBuildFileImportWhitelist()).build());
BuckEventBus buckEventBus = BuckEventBusFactory.newInstance();
JavaSymbolFinder finder = new JavaSymbolFinder(projectFilesystem, srcRootsFinder, DEFAULT_JAVAC_OPTIONS, new ConstructorArgMarshaller(new DefaultTypeCoercerFactory(ObjectMappers.newDefaultInstance())), projectBuildFileParserFactory, config, buckEventBus, new TestConsole(), environment);
SetMultimap<String, BuildTarget> foundTargets = finder.findTargetsForSymbols(ImmutableSet.of("com.example.a.A"));
assertEquals("JavaSymbolFinder failed to find the right target.", ImmutableSetMultimap.of("com.example.a.A", BuildTargetFactory.newInstance(projectFilesystem, "//java/com/example/a:a")), foundTargets);
}
Aggregations