Search in sources :

Example 11 with AlwaysFoundExecutableFinder

use of com.facebook.buck.io.AlwaysFoundExecutableFinder in project buck by facebook.

the class WorkspaceAndProjectGeneratorTest method workspaceAndProjectsWithoutDependenciesTests.

@Test
public void workspaceAndProjectsWithoutDependenciesTests() throws IOException, InterruptedException {
    WorkspaceAndProjectGenerator generator = new WorkspaceAndProjectGenerator(rootCell, targetGraph, workspaceNode.getConstructorArg(), workspaceNode.getBuildTarget(), ImmutableSet.of(ProjectGenerator.Option.INCLUDE_TESTS), false, /* combinedProject */
    false, /* buildWithBuck */
    ImmutableList.of(), Optional.empty(), false, /* parallelizeBuild */
    new AlwaysFoundExecutableFinder(), ImmutableMap.of(), PLATFORMS, DEFAULT_PLATFORM, "BUCK", getBuildRuleResolverForNodeFunction(targetGraph), getFakeBuckEventBus(), halideBuckConfig, cxxBuckConfig, appleConfig, swiftBuckConfig);
    Map<Path, ProjectGenerator> projectGenerators = new HashMap<>();
    generator.generateWorkspaceAndDependentProjects(projectGenerators, MoreExecutors.newDirectExecutorService());
    Optional<XCScheme> scheme = Iterables.getOnlyElement(generator.getSchemeGenerators().values()).getOutputScheme();
    assertThat(scheme.isPresent(), is(true));
    assertThat("Test for project FooBin should have been generated", scheme.get().getBuildAction().get().getBuildActionEntries(), hasItem(withNameAndBuildingFor("bin-xctest", equalTo(XCScheme.BuildActionEntry.BuildFor.TEST_ONLY))));
    assertThat("Test for project FooLib should not be generated at all", scheme.get().getBuildAction().get().getBuildActionEntries(), not(hasItem(withNameAndBuildingFor("lib-xctest", equalTo(XCScheme.BuildActionEntry.BuildFor.TEST_ONLY)))));
}
Also used : Path(java.nio.file.Path) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) DefaultBuildTargetSourcePath(com.facebook.buck.rules.DefaultBuildTargetSourcePath) HashMap(java.util.HashMap) AlwaysFoundExecutableFinder(com.facebook.buck.io.AlwaysFoundExecutableFinder) XCScheme(com.facebook.buck.apple.xcode.XCScheme) Test(org.junit.Test)

Example 12 with AlwaysFoundExecutableFinder

use of com.facebook.buck.io.AlwaysFoundExecutableFinder in project buck by facebook.

the class PythonTestDescriptionTest method pexExecutorRuleIsAddedToParseTimeDeps.

@Test
public void pexExecutorRuleIsAddedToParseTimeDeps() throws Exception {
    ShBinaryBuilder pexExecutorBuilder = new ShBinaryBuilder(BuildTargetFactory.newInstance("//:pex_executor")).setMain(new FakeSourcePath("run.sh"));
    PythonTestBuilder builder = new PythonTestBuilder(BuildTargetFactory.newInstance("//:bin"), new PythonBuckConfig(FakeBuckConfig.builder().setSections(ImmutableMap.of("python", ImmutableMap.of("path_to_pex_executer", pexExecutorBuilder.getTarget().toString()))).build(), new AlwaysFoundExecutableFinder()), PythonTestUtils.PYTHON_PLATFORMS, CxxPlatformUtils.DEFAULT_PLATFORM, CxxPlatformUtils.DEFAULT_PLATFORMS);
    builder.setPackageStyle(PythonBuckConfig.PackageStyle.STANDALONE);
    assertThat(builder.build().getExtraDeps(), Matchers.hasItem(pexExecutorBuilder.getTarget()));
}
Also used : FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) ShBinaryBuilder(com.facebook.buck.shell.ShBinaryBuilder) AlwaysFoundExecutableFinder(com.facebook.buck.io.AlwaysFoundExecutableFinder) Test(org.junit.Test)

Example 13 with AlwaysFoundExecutableFinder

use of com.facebook.buck.io.AlwaysFoundExecutableFinder in project buck by facebook.

the class PythonBinaryDescriptionTest method pexBuilderAddedToParseTimeDeps.

@Test
public void pexBuilderAddedToParseTimeDeps() {
    final BuildTarget pexBuilder = BuildTargetFactory.newInstance("//:pex_builder");
    PythonBuckConfig config = new PythonBuckConfig(FakeBuckConfig.builder().build(), new AlwaysFoundExecutableFinder()) {

        @Override
        public Optional<BuildTarget> getPexExecutorTarget() {
            return Optional.of(pexBuilder);
        }
    };
    PythonBinaryBuilder inplaceBinary = new PythonBinaryBuilder(BuildTargetFactory.newInstance("//:bin"), config, PythonTestUtils.PYTHON_PLATFORMS, CxxPlatformUtils.DEFAULT_PLATFORM, CxxPlatformUtils.DEFAULT_PLATFORMS).setPackageStyle(PythonBuckConfig.PackageStyle.INPLACE);
    assertThat(inplaceBinary.findImplicitDeps(), Matchers.not(Matchers.hasItem(pexBuilder)));
    PythonBinaryBuilder standaloneBinary = new PythonBinaryBuilder(BuildTargetFactory.newInstance("//:bin"), config, PythonTestUtils.PYTHON_PLATFORMS, CxxPlatformUtils.DEFAULT_PLATFORM, CxxPlatformUtils.DEFAULT_PLATFORMS).setPackageStyle(PythonBuckConfig.PackageStyle.STANDALONE);
    assertThat(standaloneBinary.findImplicitDeps(), Matchers.hasItem(pexBuilder));
}
Also used : BuildTarget(com.facebook.buck.model.BuildTarget) AlwaysFoundExecutableFinder(com.facebook.buck.io.AlwaysFoundExecutableFinder) Test(org.junit.Test)

Example 14 with AlwaysFoundExecutableFinder

use of com.facebook.buck.io.AlwaysFoundExecutableFinder in project buck by facebook.

the class PythonBinaryDescriptionTest method preloadLibraries.

@Test
public void preloadLibraries() throws Exception {
    for (final NativeLinkStrategy strategy : NativeLinkStrategy.values()) {
        CxxLibraryBuilder cxxLibraryBuilder = new CxxLibraryBuilder(BuildTargetFactory.newInstance("//:dep")).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("test.c"))));
        PythonBuckConfig config = new PythonBuckConfig(FakeBuckConfig.builder().build(), new AlwaysFoundExecutableFinder()) {

            @Override
            public NativeLinkStrategy getNativeLinkStrategy() {
                return strategy;
            }
        };
        PythonBinaryBuilder binaryBuilder = new PythonBinaryBuilder(BuildTargetFactory.newInstance("//:bin"), config, PythonTestUtils.PYTHON_PLATFORMS, CxxPlatformUtils.DEFAULT_PLATFORM, CxxPlatformUtils.DEFAULT_PLATFORMS);
        binaryBuilder.setMainModule("main");
        binaryBuilder.setPreloadDeps(ImmutableSortedSet.of(cxxLibraryBuilder.getTarget()));
        BuildRuleResolver resolver = new BuildRuleResolver(TargetGraphFactory.newInstance(cxxLibraryBuilder.build(), binaryBuilder.build()), new DefaultTargetNodeToBuildRuleTransformer());
        cxxLibraryBuilder.build(resolver);
        PythonBinary binary = binaryBuilder.build(resolver);
        assertThat("Using " + strategy, binary.getPreloadLibraries(), Matchers.hasItems("libdep.so"));
        assertThat("Using " + strategy, binary.getComponents().getNativeLibraries().keySet(), Matchers.hasItems(Paths.get("libdep.so")));
    }
}
Also used : FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) NativeLinkStrategy(com.facebook.buck.cxx.NativeLinkStrategy) PrebuiltCxxLibraryBuilder(com.facebook.buck.cxx.PrebuiltCxxLibraryBuilder) CxxLibraryBuilder(com.facebook.buck.cxx.CxxLibraryBuilder) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) AlwaysFoundExecutableFinder(com.facebook.buck.io.AlwaysFoundExecutableFinder) Test(org.junit.Test)

Example 15 with AlwaysFoundExecutableFinder

use of com.facebook.buck.io.AlwaysFoundExecutableFinder in project buck by facebook.

the class PythonBuckConfigTest method testDefaultPythonLibrary.

@Test
public void testDefaultPythonLibrary() throws InterruptedException {
    BuildTarget library = BuildTargetFactory.newInstance("//:library");
    PythonBuckConfig config = new PythonBuckConfig(FakeBuckConfig.builder().setSections(ImmutableMap.of("python", ImmutableMap.of("library", library.toString()))).build(), new AlwaysFoundExecutableFinder());
    assertThat(config.getDefaultPythonPlatform(new FakeProcessExecutor(Functions.constant(new FakeProcess(0, "CPython 2 7", "")), new TestConsole())).getCxxLibrary(), Matchers.equalTo(Optional.of(library)));
}
Also used : FakeProcessExecutor(com.facebook.buck.util.FakeProcessExecutor) BuildTarget(com.facebook.buck.model.BuildTarget) FakeProcess(com.facebook.buck.util.FakeProcess) TestConsole(com.facebook.buck.testutil.TestConsole) AlwaysFoundExecutableFinder(com.facebook.buck.io.AlwaysFoundExecutableFinder) Test(org.junit.Test)

Aggregations

AlwaysFoundExecutableFinder (com.facebook.buck.io.AlwaysFoundExecutableFinder)39 Test (org.junit.Test)37 FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)30 Path (java.nio.file.Path)18 DefaultBuildTargetSourcePath (com.facebook.buck.rules.DefaultBuildTargetSourcePath)17 BuildTarget (com.facebook.buck.model.BuildTarget)16 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)14 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)14 TargetGraph (com.facebook.buck.rules.TargetGraph)14 HashMap (java.util.HashMap)12 PrebuiltCxxLibraryBuilder (com.facebook.buck.cxx.PrebuiltCxxLibraryBuilder)9 CxxLibraryBuilder (com.facebook.buck.cxx.CxxLibraryBuilder)8 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)8 XCScheme (com.facebook.buck.apple.xcode.XCScheme)6 PBXTarget (com.facebook.buck.apple.xcode.xcodeproj.PBXTarget)6 AllExistingProjectFilesystem (com.facebook.buck.testutil.AllExistingProjectFilesystem)6 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)6 AppleDependenciesCache (com.facebook.buck.apple.AppleDependenciesCache)5 SourcePath (com.facebook.buck.rules.SourcePath)5 ShBinaryBuilder (com.facebook.buck.shell.ShBinaryBuilder)5