use of com.facebook.buck.rules.FakeTestRule in project buck by facebook.
the class TestCommandTest method testLabelPriority.
@Test
public void testLabelPriority() throws CmdLineException {
TestCommand command = getCommand("--exclude", "c", "--include", "a+b");
TestRule rule = new FakeTestRule(ImmutableSet.of(Label.of("a"), Label.of("b"), Label.of("c")), BuildTargetFactory.newInstance("//:for"), new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer()))), ImmutableSortedSet.of());
List<TestRule> testRules = ImmutableList.of(rule);
Iterable<TestRule> result = command.filterTestRules(FakeBuckConfig.builder().build(), ImmutableSet.of(), testRules);
assertEquals(ImmutableSet.of(), result);
}
use of com.facebook.buck.rules.FakeTestRule in project buck by facebook.
the class TestCommandTest method testLabelConjunctionsWithExclude.
@Test
public void testLabelConjunctionsWithExclude() throws CmdLineException {
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
TestCommand command = getCommand("--exclude", "windows+linux");
TestRule rule1 = new FakeTestRule(ImmutableSet.of(Label.of("windows"), Label.of("linux")), BuildTargetFactory.newInstance("//:for"), pathResolver, ImmutableSortedSet.of());
TestRule rule2 = new FakeTestRule(ImmutableSet.of(Label.of("windows")), BuildTargetFactory.newInstance("//:lulz"), pathResolver, ImmutableSortedSet.of());
List<TestRule> testRules = ImmutableList.of(rule1, rule2);
Iterable<TestRule> result = command.filterTestRules(FakeBuckConfig.builder().build(), ImmutableSet.of(), testRules);
assertEquals(ImmutableSet.of(rule2), result);
}
use of com.facebook.buck.rules.FakeTestRule in project buck by facebook.
the class TestCommandTest method testNoTransitiveTestsWhenLabelExcludeWins.
@Test
public void testNoTransitiveTestsWhenLabelExcludeWins() throws CmdLineException {
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
TestCommand command = getCommand("--labels", "!linux", "--always-exclude", "--exclude-transitive-tests", "//:for", "//:lulz");
FakeTestRule rule1 = new FakeTestRule(ImmutableSet.of(Label.of("windows"), Label.of("linux")), BuildTargetFactory.newInstance("//:for"), pathResolver, ImmutableSortedSet.of());
FakeTestRule rule2 = new FakeTestRule(ImmutableSet.of(Label.of("windows")), BuildTargetFactory.newInstance("//:lulz"), pathResolver, ImmutableSortedSet.of(rule1));
List<TestRule> testRules = ImmutableList.of(rule1, rule2);
Iterable<TestRule> filtered = command.filterTestRules(FakeBuckConfig.builder().build(), ImmutableSet.of(BuildTargetFactory.newInstance("//:for"), BuildTargetFactory.newInstance("//:lulz")), testRules);
assertEquals(rule2, Iterables.getOnlyElement(filtered));
}
use of com.facebook.buck.rules.FakeTestRule in project buck by facebook.
the class TestCommandTest method testFilterBuilds.
@Test
public void testFilterBuilds() throws CmdLineException {
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
TestCommand command = getCommand("--exclude", "linux", "windows");
TestRule rule1 = new FakeTestRule(ImmutableSet.of(Label.of("windows"), Label.of("linux")), BuildTargetFactory.newInstance("//:for"), pathResolver, ImmutableSortedSet.of());
TestRule rule2 = new FakeTestRule(ImmutableSet.of(Label.of("android")), BuildTargetFactory.newInstance("//:teh"), pathResolver, ImmutableSortedSet.of());
TestRule rule3 = new FakeTestRule(ImmutableSet.of(Label.of("windows")), BuildTargetFactory.newInstance("//:lulz"), pathResolver, ImmutableSortedSet.of());
List<TestRule> testRules = ImmutableList.of(rule1, rule2, rule3);
Iterable<TestRule> result = command.filterTestRules(FakeBuckConfig.builder().build(), ImmutableSet.of(), testRules);
assertThat(result, contains(rule2));
}
use of com.facebook.buck.rules.FakeTestRule in project buck by facebook.
the class TestCommandTest method testNoTransitiveTests.
@Test
public void testNoTransitiveTests() throws CmdLineException {
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
TestCommand command = getCommand("--exclude-transitive-tests", "//:wow");
FakeTestRule rule1 = new FakeTestRule(ImmutableSet.of(Label.of("windows"), Label.of("linux")), BuildTargetFactory.newInstance("//:for"), pathResolver, ImmutableSortedSet.of());
FakeTestRule rule2 = new FakeTestRule(ImmutableSet.of(Label.of("windows")), BuildTargetFactory.newInstance("//:lulz"), pathResolver, ImmutableSortedSet.of(rule1));
FakeTestRule rule3 = new FakeTestRule(ImmutableSet.of(Label.of("linux")), BuildTargetFactory.newInstance("//:wow"), pathResolver, ImmutableSortedSet.of(rule2));
List<TestRule> testRules = ImmutableList.of(rule1, rule2, rule3);
Iterable<TestRule> filtered = command.filterTestRules(FakeBuckConfig.builder().build(), ImmutableSet.of(BuildTargetFactory.newInstance("//:wow")), testRules);
assertEquals(rule3, Iterables.getOnlyElement(filtered));
}
Aggregations