Search in sources :

Example 1 with FixedTargetNodeTranslator

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

the class NeededCoverageSpecTest method translatedTargets.

@Test
public void translatedTargets() {
    BuildTarget target = BuildTargetFactory.newInstance("//:rule");
    BuildTarget newTarget = BuildTargetFactory.newInstance("//something:else");
    TargetNodeTranslator translator = new FixedTargetNodeTranslator(ImmutableMap.of(target, newTarget));
    NeededCoverageSpec spec = NeededCoverageSpec.of(1.0f, target, Optional.empty());
    assertThat(translator.translate(CELL_PATH_RESOLVER, PATTERN, spec), Matchers.equalTo(Optional.of(spec.withBuildTarget(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 2 with FixedTargetNodeTranslator

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

the class SourceListTest method untranslatedUnnamedSourcesTargets.

@Test
public void untranslatedUnnamedSourcesTargets() {
    BuildTarget target = BuildTargetFactory.newInstance("//:rule");
    TargetNodeTranslator translator = new FixedTargetNodeTranslator(ImmutableMap.of());
    SourceList list = SourceList.ofUnnamedSources(ImmutableSortedSet.of(new DefaultBuildTargetSourcePath(target)));
    assertThat(translator.translate(CELL_PATH_RESOLVER, PATTERN, list), Matchers.equalTo(Optional.empty()));
}
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)

Example 3 with FixedTargetNodeTranslator

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

the class SourceListTest method translatedUnnamedSourcesTargets.

@Test
public void translatedUnnamedSourcesTargets() {
    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.ofUnnamedSources(ImmutableSortedSet.of(new DefaultBuildTargetSourcePath(target)))), Matchers.equalTo(Optional.of(SourceList.ofUnnamedSources(ImmutableSortedSet.of(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)

Example 4 with FixedTargetNodeTranslator

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

the class SourceListTest method untranslatedNamedSourcesTargets.

@Test
public void untranslatedNamedSourcesTargets() {
    BuildTarget target = BuildTargetFactory.newInstance("//:rule");
    TargetNodeTranslator translator = new FixedTargetNodeTranslator(ImmutableMap.of());
    SourceList list = SourceList.ofNamedSources(ImmutableSortedMap.of("name", new DefaultBuildTargetSourcePath(target)));
    assertThat(translator.translate(CELL_PATH_RESOLVER, PATTERN, list), Matchers.equalTo(Optional.empty()));
}
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)

Example 5 with FixedTargetNodeTranslator

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

the class PatternMatchedCollectionTest method translatedTargets.

@Test
public void translatedTargets() {
    BuildTarget target = BuildTargetFactory.newInstance("//:rule");
    BuildTarget newTarget = BuildTargetFactory.newInstance("//something:else");
    TargetNodeTranslator translator = new FixedTargetNodeTranslator(ImmutableMap.of(target, newTarget));
    PatternMatchedCollection<BuildTarget> collection = PatternMatchedCollection.<BuildTarget>builder().add(Pattern.compile("something"), target).build();
    assertThat(translator.translate(CELL_PATH_RESOLVER, PATTERN, collection).map(PatternMatchedCollection::getValues), Matchers.equalTo(Optional.of(ImmutableList.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)

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