Search in sources :

Example 6 with FixedTargetNodeTranslator

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

the class LocationMacroTest method translateTargets.

@Test
public void translateTargets() {
    BuildTarget target = BuildTargetFactory.newInstance("//:rule");
    BuildTarget otherTarget = BuildTargetFactory.newInstance("//:other");
    BuildTarget newTarget = BuildTargetFactory.newInstance("//something:else");
    TargetNodeTranslator translator = new FixedTargetNodeTranslator(ImmutableMap.of(target, newTarget));
    assertThat(translator.translate(CELL_PATH_RESOLVER, PATTERN, LocationMacro.of(otherTarget)), Matchers.equalTo(Optional.empty()));
    assertThat(translator.translate(CELL_PATH_RESOLVER, PATTERN, LocationMacro.of(target)), Matchers.equalTo(Optional.of(LocationMacro.of(newTarget))));
}
Also used : BuildTarget(com.facebook.buck.model.BuildTarget) FixedTargetNodeTranslator(com.facebook.buck.versions.FixedTargetNodeTranslator) TargetNodeTranslator(com.facebook.buck.versions.TargetNodeTranslator) FixedTargetNodeTranslator(com.facebook.buck.versions.FixedTargetNodeTranslator) Test(org.junit.Test)

Example 7 with FixedTargetNodeTranslator

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

the class PatternMatchedCollectionTest method untranslatedTargets.

@Test
public void untranslatedTargets() {
    BuildTarget target = BuildTargetFactory.newInstance("//:rule");
    TargetNodeTranslator translator = new FixedTargetNodeTranslator(ImmutableMap.of());
    PatternMatchedCollection<BuildTarget> collection = PatternMatchedCollection.<BuildTarget>builder().add(Pattern.compile("something"), target).build();
    assertThat(translator.translate(CELL_PATH_RESOLVER, PATTERN, collection), Matchers.equalTo(Optional.empty()));
}
Also used : BuildTarget(com.facebook.buck.model.BuildTarget) FixedTargetNodeTranslator(com.facebook.buck.versions.FixedTargetNodeTranslator) TargetNodeTranslator(com.facebook.buck.versions.TargetNodeTranslator) FixedTargetNodeTranslator(com.facebook.buck.versions.FixedTargetNodeTranslator) Test(org.junit.Test)

Example 8 with FixedTargetNodeTranslator

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

the class CxxGenruleDescriptionTest method targetTranslateConstructorArg.

@Test
public void targetTranslateConstructorArg() throws NoSuchBuildTargetException {
    BuildTarget target = BuildTargetFactory.newInstance("//foo:lib");
    BuildTarget original = BuildTargetFactory.newInstance("//hello:world");
    BuildTarget translated = BuildTargetFactory.newInstance("//something:else");
    CxxGenruleBuilder builder = new CxxGenruleBuilder(target).setCmd(String.format("$(cppflags %s)", original));
    TargetNode<CxxGenruleDescription.Arg, CxxGenruleDescription> node = builder.build();
    TargetNodeTranslator translator = new FixedTargetNodeTranslator(ImmutableMap.of(original, translated));
    Optional<CxxGenruleDescription.Arg> translatedArg = node.getDescription().translateConstructorArg(target, node.getCellNames(), translator, node.getConstructorArg());
    assertThat(translatedArg.get().cmd.get(), Matchers.equalTo("$(cppflags //something:else)"));
}
Also used : BuildTarget(com.facebook.buck.model.BuildTarget) Arg(com.facebook.buck.rules.args.Arg) FixedTargetNodeTranslator(com.facebook.buck.versions.FixedTargetNodeTranslator) TargetNodeTranslator(com.facebook.buck.versions.TargetNodeTranslator) FixedTargetNodeTranslator(com.facebook.buck.versions.FixedTargetNodeTranslator) Test(org.junit.Test)

Example 9 with FixedTargetNodeTranslator

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

the class StringWithMacrosTest method translateTargets.

@Test
public void translateTargets() {
    BuildTarget target = BuildTargetFactory.newInstance("//:rule");
    BuildTarget newTarget = BuildTargetFactory.newInstance("//something:else");
    TargetNodeTranslator translator = new FixedTargetNodeTranslator(ImmutableMap.of(target, newTarget));
    assertThat(translator.translate(CELL_PATH_RESOLVER, PATTERN, StringWithMacrosUtils.format("--flag")), Matchers.equalTo(Optional.empty()));
    assertThat(translator.translate(CELL_PATH_RESOLVER, PATTERN, StringWithMacrosUtils.format("--flag=%s", LocationMacro.of(target))), Matchers.equalTo(Optional.of(StringWithMacrosUtils.format("--flag=%s", LocationMacro.of(newTarget)))));
}
Also used : BuildTarget(com.facebook.buck.model.BuildTarget) FixedTargetNodeTranslator(com.facebook.buck.versions.FixedTargetNodeTranslator) TargetNodeTranslator(com.facebook.buck.versions.TargetNodeTranslator) FixedTargetNodeTranslator(com.facebook.buck.versions.FixedTargetNodeTranslator) Test(org.junit.Test)

Example 10 with FixedTargetNodeTranslator

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

the class SourceListTest method translatedNamedSourcesTargets.

@Test
public void translatedNamedSourcesTargets() {
    BuildTarget target = BuildTargetFactory.newInstance("//:rule");
    BuildTarget newTarget = BuildTargetFactory.newInstance("//something:else");
    TargetNodeTranslator translator = new FixedTargetNodeTranslator(ImmutableMap.of(target, newTarget));
    assertThat(translator.translate(CELL_PATH_RESOLVER, PATTERN, SourceList.ofNamedSources(ImmutableSortedMap.of("name", new DefaultBuildTargetSourcePath(target)))), Matchers.equalTo(Optional.of(SourceList.ofNamedSources(ImmutableSortedMap.of("name", new DefaultBuildTargetSourcePath(newTarget))))));
}
Also used : BuildTarget(com.facebook.buck.model.BuildTarget) FixedTargetNodeTranslator(com.facebook.buck.versions.FixedTargetNodeTranslator) DefaultBuildTargetSourcePath(com.facebook.buck.rules.DefaultBuildTargetSourcePath) TargetNodeTranslator(com.facebook.buck.versions.TargetNodeTranslator) FixedTargetNodeTranslator(com.facebook.buck.versions.FixedTargetNodeTranslator) Test(org.junit.Test)

Aggregations

BuildTarget (com.facebook.buck.model.BuildTarget)11 FixedTargetNodeTranslator (com.facebook.buck.versions.FixedTargetNodeTranslator)11 TargetNodeTranslator (com.facebook.buck.versions.TargetNodeTranslator)11 Test (org.junit.Test)11 DefaultBuildTargetSourcePath (com.facebook.buck.rules.DefaultBuildTargetSourcePath)4 Arg (com.facebook.buck.rules.args.Arg)1