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))));
}
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()));
}
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)"));
}
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)))));
}
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))))));
}
Aggregations