Search in sources :

Example 6 with FakeTestRule

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);
}
Also used : FakeTestRule(com.facebook.buck.rules.FakeTestRule) TestRule(com.facebook.buck.rules.TestRule) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) FakeTestRule(com.facebook.buck.rules.FakeTestRule) Test(org.junit.Test)

Example 7 with FakeTestRule

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);
}
Also used : FakeTestRule(com.facebook.buck.rules.FakeTestRule) TestRule(com.facebook.buck.rules.TestRule) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) FakeTestRule(com.facebook.buck.rules.FakeTestRule) Test(org.junit.Test)

Example 8 with FakeTestRule

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));
}
Also used : FakeTestRule(com.facebook.buck.rules.FakeTestRule) TestRule(com.facebook.buck.rules.TestRule) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) FakeTestRule(com.facebook.buck.rules.FakeTestRule) Test(org.junit.Test)

Example 9 with FakeTestRule

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));
}
Also used : FakeTestRule(com.facebook.buck.rules.FakeTestRule) TestRule(com.facebook.buck.rules.TestRule) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) FakeTestRule(com.facebook.buck.rules.FakeTestRule) Test(org.junit.Test)

Example 10 with FakeTestRule

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));
}
Also used : FakeTestRule(com.facebook.buck.rules.FakeTestRule) TestRule(com.facebook.buck.rules.TestRule) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) FakeTestRule(com.facebook.buck.rules.FakeTestRule) Test(org.junit.Test)

Aggregations

BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)16 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)16 FakeTestRule (com.facebook.buck.rules.FakeTestRule)16 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)16 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)16 Test (org.junit.Test)16 TestRule (com.facebook.buck.rules.TestRule)8 ExecutionContext (com.facebook.buck.step.ExecutionContext)8 TestExecutionContext (com.facebook.buck.step.TestExecutionContext)8 FakeTestResults (com.facebook.buck.test.FakeTestResults)8 TestResults (com.facebook.buck.test.TestResults)8 BuildResult (com.facebook.buck.rules.BuildResult)6 CachingBuildEngine (com.facebook.buck.rules.CachingBuildEngine)5 TestCaseSummary (com.facebook.buck.test.TestCaseSummary)4 TestResultSummary (com.facebook.buck.test.TestResultSummary)4 BuildTarget (com.facebook.buck.model.BuildTarget)3 FakeBuildEngine (com.facebook.buck.rules.FakeBuildEngine)3 FakeBuildRuleParamsBuilder (com.facebook.buck.rules.FakeBuildRuleParamsBuilder)3 RuleKey (com.facebook.buck.rules.RuleKey)3 DefaultStepRunner (com.facebook.buck.step.DefaultStepRunner)3