Search in sources :

Example 31 with FakeBuildRule

use of com.facebook.buck.rules.FakeBuildRule in project buck by facebook.

the class JavaTestDescriptionTest method rulesExportedFromDepsBecomeFirstOrderDeps.

@Test
public void rulesExportedFromDepsBecomeFirstOrderDeps() throws Exception {
    BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
    SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
    FakeBuildRule exportedRule = resolver.addToIndex(new FakeBuildRule("//:exported_rule", pathResolver));
    FakeExportDependenciesRule exportingRule = resolver.addToIndex(new FakeExportDependenciesRule("//:exporting_rule", pathResolver, exportedRule));
    BuildTarget target = BuildTargetFactory.newInstance("//:rule");
    JavaTest javaTest = JavaTestBuilder.createBuilder(target).addDep(exportingRule.getBuildTarget()).build(resolver);
    ImmutableSortedSet<BuildRule> deps = javaTest.getCompiledTestsLibrary().getDeps();
    assertThat(deps, Matchers.<BuildRule>hasItem(exportedRule));
}
Also used : FakeExportDependenciesRule(com.facebook.buck.rules.FakeExportDependenciesRule) FakeBuildRule(com.facebook.buck.rules.FakeBuildRule) BuildTarget(com.facebook.buck.model.BuildTarget) FakeBuildRule(com.facebook.buck.rules.FakeBuildRule) BuildRule(com.facebook.buck.rules.BuildRule) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) Test(org.junit.Test)

Example 32 with FakeBuildRule

use of com.facebook.buck.rules.FakeBuildRule in project buck by facebook.

the class JavaLibraryDescriptionTest method setUp.

@Before
public void setUp() {
    resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
    SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
    exportedRule = resolver.addToIndex(new FakeBuildRule("//:exported_rule", pathResolver));
    exportingRule = resolver.addToIndex(new FakeExportDependenciesRule("//:exporting_rule", pathResolver, exportedRule));
}
Also used : FakeExportDependenciesRule(com.facebook.buck.rules.FakeExportDependenciesRule) FakeBuildRule(com.facebook.buck.rules.FakeBuildRule) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) Before(org.junit.Before)

Example 33 with FakeBuildRule

use of com.facebook.buck.rules.FakeBuildRule in project buck by facebook.

the class WorkerMacroArgTest method testWorkerMacroArgWithBadReference.

@Test
public void testWorkerMacroArgWithBadReference() throws MacroException, NoSuchBuildTargetException {
    BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
    BuildRule nonWorkerBuildRule = new FakeBuildRule(BuildTargetFactory.newInstance("//:not_worker_rule"), new SourcePathResolver(new SourcePathRuleFinder(resolver)));
    resolver.addToIndex(nonWorkerBuildRule);
    MacroHandler macroHandler = new MacroHandler(ImmutableMap.of("worker", new WorkerMacroExpander()));
    ProjectFilesystem filesystem = new FakeProjectFilesystem();
    try {
        new WorkerMacroArg(macroHandler, BuildTargetFactory.newInstance("//:rule"), TestCellBuilder.createCellRoots(filesystem), resolver, "$(worker //:not_worker_rule)");
    } catch (MacroException e) {
        assertThat(e.getMessage(), Matchers.containsString("does not correspond to a worker_tool"));
    }
}
Also used : MacroHandler(com.facebook.buck.rules.macros.MacroHandler) FakeBuildRule(com.facebook.buck.rules.FakeBuildRule) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) FakeBuildRule(com.facebook.buck.rules.FakeBuildRule) BuildRule(com.facebook.buck.rules.BuildRule) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) WorkerMacroExpander(com.facebook.buck.rules.macros.WorkerMacroExpander) MacroException(com.facebook.buck.model.MacroException) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) Test(org.junit.Test)

Example 34 with FakeBuildRule

use of com.facebook.buck.rules.FakeBuildRule in project buck by facebook.

the class AndroidManifestDescriptionTest method testGeneratedSkeletonAppearsInDeps.

@Test
public void testGeneratedSkeletonAppearsInDeps() {
    BuildRuleResolver buildRuleResolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
    BuildRule ruleWithOutput = new FakeBuildRule(BuildTargetFactory.newInstance("//foo:bar"), new SourcePathResolver(new SourcePathRuleFinder(buildRuleResolver))) {

        @Override
        public SourcePath getSourcePathToOutput() {
            return new ExplicitBuildTargetSourcePath(getBuildTarget(), Paths.get("buck-out/gen/foo/bar/AndroidManifest.xml"));
        }
    };
    SourcePath skeleton = ruleWithOutput.getSourcePathToOutput();
    buildRuleResolver.addToIndex(ruleWithOutput);
    AndroidManifestDescription.Arg arg = new AndroidManifestDescription.Arg();
    arg.skeleton = skeleton;
    arg.deps = ImmutableSortedSet.of();
    BuildRuleParams params = new FakeBuildRuleParamsBuilder("//foo:baz").setDeclaredDeps(buildRuleResolver.getAllRules(arg.deps)).build();
    BuildRule androidManifest = new AndroidManifestDescription().createBuildRule(TargetGraph.EMPTY, params, buildRuleResolver, arg);
    assertEquals(ImmutableSortedSet.of(ruleWithOutput), androidManifest.getDeps());
}
Also used : FakeBuildRuleParamsBuilder(com.facebook.buck.rules.FakeBuildRuleParamsBuilder) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) SourcePath(com.facebook.buck.rules.SourcePath) BuildRuleParams(com.facebook.buck.rules.BuildRuleParams) FakeBuildRule(com.facebook.buck.rules.FakeBuildRule) FakeBuildRule(com.facebook.buck.rules.FakeBuildRule) BuildRule(com.facebook.buck.rules.BuildRule) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) Test(org.junit.Test)

Example 35 with FakeBuildRule

use of com.facebook.buck.rules.FakeBuildRule in project buck by facebook.

the class AndroidLibraryDescriptionTest method rulesExportedFromDepsBecomeFirstOrderDeps.

@Test
public void rulesExportedFromDepsBecomeFirstOrderDeps() throws Exception {
    BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
    SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
    FakeBuildRule transitiveExportedRule = resolver.addToIndex(new FakeBuildRule("//:transitive_exported_rule", pathResolver));
    FakeExportDependenciesRule exportedRule = resolver.addToIndex(new FakeExportDependenciesRule("//:exported_rule", pathResolver, transitiveExportedRule));
    FakeExportDependenciesRule exportingRule = resolver.addToIndex(new FakeExportDependenciesRule("//:exporting_rule", pathResolver, exportedRule));
    BuildTarget target = BuildTargetFactory.newInstance("//:rule");
    BuildRule javaLibrary = AndroidLibraryBuilder.createBuilder(target).addDep(exportingRule.getBuildTarget()).build(resolver);
    assertThat(javaLibrary.getDeps(), Matchers.allOf(Matchers.hasItem(exportedRule), Matchers.hasItem(transitiveExportedRule)));
}
Also used : FakeExportDependenciesRule(com.facebook.buck.rules.FakeExportDependenciesRule) FakeBuildRule(com.facebook.buck.rules.FakeBuildRule) BuildTarget(com.facebook.buck.model.BuildTarget) FakeBuildRule(com.facebook.buck.rules.FakeBuildRule) BuildRule(com.facebook.buck.rules.BuildRule) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) Test(org.junit.Test)

Aggregations

FakeBuildRule (com.facebook.buck.rules.FakeBuildRule)48 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)46 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)46 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)44 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)43 Test (org.junit.Test)43 BuildTarget (com.facebook.buck.model.BuildTarget)34 BuildRule (com.facebook.buck.rules.BuildRule)24 FakeBuildRuleParamsBuilder (com.facebook.buck.rules.FakeBuildRuleParamsBuilder)14 BuildRuleParams (com.facebook.buck.rules.BuildRuleParams)12 RuleKey (com.facebook.buck.rules.RuleKey)11 SourcePath (com.facebook.buck.rules.SourcePath)10 BuildRuleEvent (com.facebook.buck.rules.BuildRuleEvent)9 BuckEventBus (com.facebook.buck.event.BuckEventBus)8 BuildEvent (com.facebook.buck.rules.BuildEvent)8 DefaultBuildTargetSourcePath (com.facebook.buck.rules.DefaultBuildTargetSourcePath)8 Clock (com.facebook.buck.timing.Clock)8 IncrementingFakeClock (com.facebook.buck.timing.IncrementingFakeClock)8 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)7 ParseEvent (com.facebook.buck.parser.ParseEvent)7