Search in sources :

Example 16 with BuckConfig

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));
}
Also used : BuckConfig(com.facebook.buck.cli.BuckConfig) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) Test(org.junit.Test)

Example 17 with BuckConfig

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);
}
Also used : Path(java.nio.file.Path) Configuration(com.google.common.jimfs.Configuration) BuckConfig(com.facebook.buck.cli.BuckConfig) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) FileSystem(java.nio.file.FileSystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) Test(org.junit.Test)

Example 18 with BuckConfig

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);
}
Also used : BuckConfig(com.facebook.buck.cli.BuckConfig) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) Test(org.junit.Test)

Example 19 with BuckConfig

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")));
}
Also used : BuckEventBus(com.facebook.buck.event.BuckEventBus) DefaultCellPathResolver(com.facebook.buck.rules.DefaultCellPathResolver) Description(com.facebook.buck.rules.Description) Config(com.facebook.buck.config.Config) BuckConfig(com.facebook.buck.cli.BuckConfig) Matchers.containsString(org.hamcrest.Matchers.containsString) MissingSymbolsHandler(com.facebook.buck.cli.MissingSymbolsHandler) MissingSymbolEvent(com.facebook.buck.event.MissingSymbolEvent) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) BuckConfig(com.facebook.buck.cli.BuckConfig) BuildTarget(com.facebook.buck.model.BuildTarget) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) TestConsole(com.facebook.buck.testutil.TestConsole) Test(org.junit.Test)

Example 20 with BuckConfig

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);
}
Also used : PythonBuckConfig(com.facebook.buck.python.PythonBuckConfig) BuckEventBus(com.facebook.buck.event.BuckEventBus) ExecutableFinder(com.facebook.buck.io.ExecutableFinder) DefaultCellPathResolver(com.facebook.buck.rules.DefaultCellPathResolver) Description(com.facebook.buck.rules.Description) Config(com.facebook.buck.config.Config) BuckConfig(com.facebook.buck.cli.BuckConfig) ParserConfig(com.facebook.buck.parser.ParserConfig) PythonBuckConfig(com.facebook.buck.python.PythonBuckConfig) DefaultProjectBuildFileParserFactory(com.facebook.buck.json.DefaultProjectBuildFileParserFactory) DefaultTypeCoercerFactory(com.facebook.buck.rules.coercer.DefaultTypeCoercerFactory) ProjectBuildFileParserFactory(com.facebook.buck.json.ProjectBuildFileParserFactory) DefaultProjectBuildFileParserFactory(com.facebook.buck.json.DefaultProjectBuildFileParserFactory) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) ConstructorArgMarshaller(com.facebook.buck.rules.ConstructorArgMarshaller) BuckConfig(com.facebook.buck.cli.BuckConfig) PythonBuckConfig(com.facebook.buck.python.PythonBuckConfig) BuildTarget(com.facebook.buck.model.BuildTarget) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) TestConsole(com.facebook.buck.testutil.TestConsole) ParserConfig(com.facebook.buck.parser.ParserConfig) Test(org.junit.Test)

Aggregations

BuckConfig (com.facebook.buck.cli.BuckConfig)98 FakeBuckConfig (com.facebook.buck.cli.FakeBuckConfig)89 Test (org.junit.Test)74 Path (java.nio.file.Path)46 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)37 TestCellBuilder (com.facebook.buck.rules.TestCellBuilder)29 PathSourcePath (com.facebook.buck.rules.PathSourcePath)27 Cell (com.facebook.buck.rules.Cell)22 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)17 ImmutableMap (com.google.common.collect.ImmutableMap)17 Config (com.facebook.buck.config.Config)15 DefaultCellPathResolver (com.facebook.buck.rules.DefaultCellPathResolver)14 BuildTarget (com.facebook.buck.model.BuildTarget)12 FakeAndroidDirectoryResolver (com.facebook.buck.android.FakeAndroidDirectoryResolver)9 ParserConfig (com.facebook.buck.parser.ParserConfig)8 ConstructorArgMarshaller (com.facebook.buck.rules.ConstructorArgMarshaller)7 DefaultTypeCoercerFactory (com.facebook.buck.rules.coercer.DefaultTypeCoercerFactory)7 TestConsole (com.facebook.buck.testutil.TestConsole)7 Optional (java.util.Optional)7 BuildJobState (com.facebook.buck.distributed.thrift.BuildJobState)6