Search in sources :

Example 1 with VersionPropagatorBuilder

use of com.facebook.buck.versions.VersionPropagatorBuilder in project buck by facebook.

the class CxxGenruleDescriptionTest method versionedTargetReferenceIsTranslatedInVersionedGraph.

@Test
public void versionedTargetReferenceIsTranslatedInVersionedGraph() throws Exception {
    VersionPropagatorBuilder dep = new VersionPropagatorBuilder("//:dep");
    VersionedAliasBuilder versionedDep = new VersionedAliasBuilder("//:versioned").setVersions("1.0", "//:dep");
    CxxGenruleBuilder genruleBuilder = new CxxGenruleBuilder(BuildTargetFactory.newInstance("//:genrule")).setCmd("$(ldflags-shared //:versioned)");
    TargetGraph graph = TargetGraphFactory.newInstance(dep.build(), versionedDep.build(), genruleBuilder.build());
    TargetGraphAndBuildTargets transformed = VersionedTargetGraphBuilder.transform(new NaiveVersionSelector(), TargetGraphAndBuildTargets.of(graph, ImmutableSet.of(genruleBuilder.getTarget())), POOL);
    CxxGenruleDescription.Arg arg = extractArg(transformed.getTargetGraph().get(genruleBuilder.getTarget()), CxxGenruleDescription.Arg.class);
    assertThat(arg.cmd, OptionalMatchers.present(Matchers.equalTo("$(ldflags-shared //:dep)")));
}
Also used : NaiveVersionSelector(com.facebook.buck.versions.NaiveVersionSelector) VersionPropagatorBuilder(com.facebook.buck.versions.VersionPropagatorBuilder) TargetGraph(com.facebook.buck.rules.TargetGraph) TargetGraphAndBuildTargets(com.facebook.buck.rules.TargetGraphAndBuildTargets) VersionedAliasBuilder(com.facebook.buck.versions.VersionedAliasBuilder) Test(org.junit.Test)

Example 2 with VersionPropagatorBuilder

use of com.facebook.buck.versions.VersionPropagatorBuilder in project buck by facebook.

the class CxxGenruleDescriptionTest method versionPropagatorTargetReferenceIsTranslatedInVersionedGraph.

@Test
public void versionPropagatorTargetReferenceIsTranslatedInVersionedGraph() throws Exception {
    VersionPropagatorBuilder transitiveDep = new VersionPropagatorBuilder("//:transitive_dep");
    VersionedAliasBuilder versionedDep = new VersionedAliasBuilder("//:versioned").setVersions("1.0", "//:transitive_dep");
    VersionPropagatorBuilder dep = new VersionPropagatorBuilder("//:dep").setDeps("//:versioned");
    CxxGenruleBuilder genruleBuilder = new CxxGenruleBuilder(BuildTargetFactory.newInstance("//:genrule")).setCmd("$(ldflags-shared //:dep)");
    TargetGraph graph = TargetGraphFactory.newInstance(transitiveDep.build(), versionedDep.build(), dep.build(), genruleBuilder.build());
    TargetGraphAndBuildTargets transformed = VersionedTargetGraphBuilder.transform(new NaiveVersionSelector(), TargetGraphAndBuildTargets.of(graph, ImmutableSet.of(genruleBuilder.getTarget())), POOL);
    CxxGenruleDescription.Arg arg = extractArg(transformed.getTargetGraph().get(genruleBuilder.getTarget()), CxxGenruleDescription.Arg.class);
    assertThat(arg.cmd, OptionalMatchers.present(Matchers.matchesPattern(Pattern.quote("$(ldflags-shared //:dep#v") + "[a-zA-Z0-9]*" + Pattern.quote(")"))));
}
Also used : NaiveVersionSelector(com.facebook.buck.versions.NaiveVersionSelector) VersionPropagatorBuilder(com.facebook.buck.versions.VersionPropagatorBuilder) TargetGraph(com.facebook.buck.rules.TargetGraph) TargetGraphAndBuildTargets(com.facebook.buck.rules.TargetGraphAndBuildTargets) VersionedAliasBuilder(com.facebook.buck.versions.VersionedAliasBuilder) Test(org.junit.Test)

Aggregations

TargetGraph (com.facebook.buck.rules.TargetGraph)2 TargetGraphAndBuildTargets (com.facebook.buck.rules.TargetGraphAndBuildTargets)2 NaiveVersionSelector (com.facebook.buck.versions.NaiveVersionSelector)2 VersionPropagatorBuilder (com.facebook.buck.versions.VersionPropagatorBuilder)2 VersionedAliasBuilder (com.facebook.buck.versions.VersionedAliasBuilder)2 Test (org.junit.Test)2