Search in sources :

Example 11 with TestRule

use of com.facebook.buck.rules.TestRule 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 12 with TestRule

use of com.facebook.buck.rules.TestRule 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 13 with TestRule

use of com.facebook.buck.rules.TestRule 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

TestRule (com.facebook.buck.rules.TestRule)13 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)9 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)9 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)8 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)8 FakeTestRule (com.facebook.buck.rules.FakeTestRule)8 Test (org.junit.Test)8 DefaultJavaLibrary (com.facebook.buck.jvm.java.DefaultJavaLibrary)2 JavaLibrary (com.facebook.buck.jvm.java.JavaLibrary)2 BuildTarget (com.facebook.buck.model.BuildTarget)2 ExternalTestRunnerRule (com.facebook.buck.rules.ExternalTestRunnerRule)2 ExternalTestRunnerTestSpec (com.facebook.buck.rules.ExternalTestRunnerTestSpec)2 TestRunningOptions (com.facebook.buck.test.TestRunningOptions)2 ForwardingProcessListener (com.facebook.buck.util.ForwardingProcessListener)2 ListeningProcessExecutor (com.facebook.buck.util.ListeningProcessExecutor)2 ProcessExecutorParams (com.facebook.buck.util.ProcessExecutorParams)2 Path (java.nio.file.Path)2 Build (com.facebook.buck.command.Build)1 ConsoleEvent (com.facebook.buck.event.ConsoleEvent)1 BuildFileParseException (com.facebook.buck.json.BuildFileParseException)1