Ejemplo n.º 1
0
  @Test
  public void testGetCandidateRulesByIncludedLabels() throws CmdLineException {
    TestRule rule1 =
        new FakeTestRule(
            BuildRuleType.JAVA_TEST,
            ImmutableSet.of("windows", "linux"),
            BuildTargetFactory.newInstance("//:for"),
            ImmutableSortedSet.<BuildRule>of(),
            ImmutableSet.<BuildTargetPattern>of());

    TestRule rule2 =
        new FakeTestRule(
            BuildRuleType.JAVA_TEST,
            ImmutableSet.of("android"),
            BuildTargetFactory.newInstance("//:teh"),
            ImmutableSortedSet.<BuildRule>of(rule1),
            ImmutableSet.<BuildTargetPattern>of());

    TestRule rule3 =
        new FakeTestRule(
            BuildRuleType.JAVA_TEST,
            ImmutableSet.of("windows"),
            BuildTargetFactory.newInstance("//:lulz"),
            ImmutableSortedSet.<BuildRule>of(rule2),
            ImmutableSet.<BuildTargetPattern>of());

    Iterable<TestRule> rules = Lists.newArrayList(rule1, rule2, rule3);
    DependencyGraph graph = createDependencyGraphFromBuildRules(rules);
    TestCommandOptions options = getOptions("--include", "linux", "windows");

    Iterable<TestRule> result =
        TestCommand.getCandidateRulesByIncludedLabels(graph, options.getIncludedLabels());
    assertThat(result, IsIterableContainingInAnyOrder.containsInAnyOrder(rule1, rule3));
  }