use of com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer in project buck by facebook.
the class TestCommandTest method testLabelPlingSyntax.
@Test
public void testLabelPlingSyntax() throws CmdLineException {
TestCommand command = getCommand("--labels", "!c", "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.DefaultTargetNodeToBuildRuleTransformer in project buck by facebook.
the class TestCommandTest method testLabelConjunctionsWithInclude.
@Test
public void testLabelConjunctionsWithInclude() throws CmdLineException {
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
TestCommand command = getCommand("--include", "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(rule1), result);
}
use of com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer in project buck by facebook.
the class TestCommandTest method testIncludingATestOnTheCommandLineMeansYouWouldLikeItRun.
@Test
public void testIncludingATestOnTheCommandLineMeansYouWouldLikeItRun() throws CmdLineException {
String excludedLabel = "exclude_me";
BuckConfig config = FakeBuckConfig.builder().setSections(ImmutableMap.of("test", ImmutableMap.of("excluded_labels", excludedLabel))).build();
assertThat(config.getDefaultRawExcludedLabelSelectors(), contains(excludedLabel));
TestCommand command = new TestCommand();
new AdditionalOptionsCmdLineParser(command).parseArgument("//example:test");
FakeTestRule rule = new FakeTestRule(/* labels */
ImmutableSet.of(Label.of(excludedLabel)), BuildTargetFactory.newInstance("//example:test"), new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer()))), /* deps */
ImmutableSortedSet.of());
Iterable<TestRule> filtered = command.filterTestRules(config, ImmutableSet.of(BuildTargetFactory.newInstance("//example:test")), ImmutableSet.of(rule));
assertEquals(rule, Iterables.getOnlyElement(filtered));
}
use of com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer 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.DefaultTargetNodeToBuildRuleTransformer in project buck by facebook.
the class TestRunningTest method testUnifiedSourceFile.
/**
* If the source paths specified are from the new unified source tmp then we should return
* the correct source tmp corresponding to the unified source path.
*/
@Test
public void testUnifiedSourceFile() throws Exception {
Path pathToNonGenFile = Paths.get("java/package/src/SourceFile1.java");
BuildTarget javaLibraryTarget = BuildTargetFactory.newInstance("//foo:bar");
TargetNode<JavaLibraryDescription.Arg, JavaLibraryDescription> javaLibraryNode = JavaLibraryBuilder.createBuilder(javaLibraryTarget).addSrc(pathToNonGenFile).build();
TargetGraph targetGraph = TargetGraphFactory.newInstance(javaLibraryNode);
BuildRuleResolver ruleResolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(ruleResolver);
SourcePathResolver resolver = new SourcePathResolver(ruleFinder);
JavaLibrary javaLibrary = (JavaLibrary) ruleResolver.requireRule(javaLibraryTarget);
DefaultJavaPackageFinder defaultJavaPackageFinder = createMock(DefaultJavaPackageFinder.class);
expect(defaultJavaPackageFinder.getPathsFromRoot()).andReturn(pathsFromRoot);
Object[] mocks = new Object[] { defaultJavaPackageFinder };
replay(mocks);
ImmutableSet<String> result = TestRunning.getPathToSourceFolders(javaLibrary, resolver, ruleFinder, defaultJavaPackageFinder);
assertEquals("All non-generated source files are under one source tmp.", ImmutableSet.of("java/"), result);
verify(mocks);
}
Aggregations