Esempio 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));
  }
Esempio n. 2
0
  @Test
  public void testIfALabelIsIncludedItShouldNotBeExcluded() throws CmdLineException {
    TestCommandOptions options = new TestCommandOptions(new FakeBuckConfig());

    new CmdLineParserAdditionalOptions(options)
        .parseArgument("-e", "e2e", "--exclude", "other", "--include", "e2e");

    ImmutableSet<String> excluded = options.getExcludedLabels();
    assertEquals("other", Iterables.getOnlyElement(excluded));
  }
Esempio n. 3
0
  @Test
  public void testIfALabelIsIncludedItShouldNotBeExcludedEvenIfTheExcludeIsGlobal()
      throws CmdLineException {
    BuckConfig config =
        new FakeBuckConfig(
            ImmutableMap.<String, Map<String, String>>of(
                "test", ImmutableMap.of("excluded_labels", "e2e")));
    assertThat(config.getDefaultExcludedLabels(), contains("e2e"));
    TestCommandOptions options = new TestCommandOptions(config);

    new CmdLineParserAdditionalOptions(options).parseArgument("--include", "e2e");

    ImmutableSet<String> included = options.getIncludedLabels();
    assertEquals("e2e", Iterables.getOnlyElement(included));
  }