Search in sources :

Example 31 with FakeBuildableContext

use of com.facebook.buck.rules.FakeBuildableContext in project buck by facebook.

the class GenAidlTest method testSimpleGenAidlRule.

@Test
public void testSimpleGenAidlRule() throws IOException {
    ProjectFilesystem stubFilesystem = FakeProjectFilesystem.createJavaOnlyFilesystem();
    Files.createDirectories(stubFilesystem.getRootPath().resolve("java/com/example/base"));
    FakeSourcePath pathToAidl = new FakeSourcePath(stubFilesystem, "java/com/example/base/IWhateverService.aidl");
    String importPath = Paths.get("java/com/example/base").toString();
    BuildTarget target = BuildTargetFactory.newInstance(stubFilesystem.getRootPath(), "//java/com/example/base:IWhateverService");
    BuildRuleParams params = new FakeBuildRuleParamsBuilder(target).setProjectFilesystem(stubFilesystem).build();
    SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
    GenAidl genAidlRule = new GenAidl(params, pathToAidl, importPath);
    GenAidlDescription description = new GenAidlDescription();
    assertEquals(Description.getBuildRuleType(GenAidlDescription.class), Description.getBuildRuleType(description));
    assertTrue(genAidlRule.getProperties().is(ANDROID));
    List<Step> steps = genAidlRule.getBuildSteps(FakeBuildContext.withSourcePathResolver(pathResolver), new FakeBuildableContext());
    final String pathToAidlExecutable = Paths.get("/usr/local/bin/aidl").toString();
    final String pathToFrameworkAidl = Paths.get("/home/root/android/platforms/android-16/framework.aidl").toString();
    final AndroidPlatformTarget androidPlatformTarget = createMock(AndroidPlatformTarget.class);
    expect(androidPlatformTarget.getAidlExecutable()).andReturn(Paths.get(pathToAidlExecutable));
    expect(androidPlatformTarget.getAndroidFrameworkIdlFile()).andReturn(Paths.get(pathToFrameworkAidl));
    replay(androidPlatformTarget);
    ExecutionContext executionContext = TestExecutionContext.newBuilder().setAndroidPlatformTargetSupplier(Suppliers.ofInstance(androidPlatformTarget)).build();
    assertEquals(executionContext.getAndroidPlatformTarget(), androidPlatformTarget);
    Path outputDirectory = BuildTargets.getScratchPath(stubFilesystem, target, "__%s.aidl");
    MakeCleanDirectoryStep mkdirStep = (MakeCleanDirectoryStep) steps.get(1);
    assertEquals("gen_aidl() should make a directory at " + outputDirectory, outputDirectory, mkdirStep.getPath());
    ShellStep aidlStep = (ShellStep) steps.get(2);
    assertEquals("gen_aidl() should use the aidl binary to write .java files.", String.format("(cd %s && %s -p%s -I%s -o%s %s)", stubFilesystem.getRootPath(), pathToAidlExecutable, pathToFrameworkAidl, stubFilesystem.resolve(importPath), stubFilesystem.resolve(outputDirectory), pathToAidl.getRelativePath()), aidlStep.getDescription(executionContext));
    assertEquals(5, steps.size());
    verify(androidPlatformTarget);
}
Also used : FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) Path(java.nio.file.Path) FakeBuildableContext(com.facebook.buck.rules.FakeBuildableContext) FakeBuildRuleParamsBuilder(com.facebook.buck.rules.FakeBuildRuleParamsBuilder) Step(com.facebook.buck.step.Step) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) ShellStep(com.facebook.buck.shell.ShellStep) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) ExecutionContext(com.facebook.buck.step.ExecutionContext) TestExecutionContext(com.facebook.buck.step.TestExecutionContext) BuildRuleParams(com.facebook.buck.rules.BuildRuleParams) BuildTarget(com.facebook.buck.model.BuildTarget) ShellStep(com.facebook.buck.shell.ShellStep) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) Test(org.junit.Test)

Example 32 with FakeBuildableContext

use of com.facebook.buck.rules.FakeBuildableContext in project buck by facebook.

the class ApkGenruleTest method testCreateAndRunApkGenrule.

@Test
@SuppressWarnings("PMD.AvoidUsingHardCodedIP")
public void testCreateAndRunApkGenrule() throws IOException, NoSuchBuildTargetException {
    ProjectFilesystem projectFilesystem = FakeProjectFilesystem.createJavaOnlyFilesystem();
    FileSystem fileSystem = projectFilesystem.getRootPath().getFileSystem();
    BuildRuleResolver ruleResolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
    createSampleAndroidBinaryRule(ruleResolver, projectFilesystem);
    // From the Python object, create a ApkGenruleBuildRuleFactory to create a ApkGenrule.Builder
    // that builds a ApkGenrule from the Python object.
    BuildTargetParser parser = EasyMock.createNiceMock(BuildTargetParser.class);
    final BuildTarget apkTarget = BuildTargetFactory.newInstance(projectFilesystem.getRootPath(), "//:fb4a");
    EasyMock.expect(parser.parse(EasyMock.eq(":fb4a"), EasyMock.anyObject(BuildTargetPatternParser.class), EasyMock.anyObject())).andStubReturn(apkTarget);
    EasyMock.replay(parser);
    BuildTarget buildTarget = BuildTargetFactory.newInstance(projectFilesystem.getRootPath(), "//src/com/facebook:sign_fb4a");
    ApkGenruleDescription description = new ApkGenruleDescription();
    ApkGenruleDescription.Arg arg = description.createUnpopulatedConstructorArg();
    SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(ruleResolver));
    arg.apk = new FakeInstallable(apkTarget, pathResolver).getBuildTarget();
    arg.bash = Optional.of("");
    arg.cmd = Optional.of("python signer.py $APK key.properties > $OUT");
    arg.cmdExe = Optional.of("");
    arg.type = Optional.empty();
    arg.out = "signed_fb4a.apk";
    arg.srcs = ImmutableList.of(new PathSourcePath(projectFilesystem, fileSystem.getPath("src/com/facebook/signer.py")), new PathSourcePath(projectFilesystem, fileSystem.getPath("src/com/facebook/key.properties")));
    arg.tests = ImmutableSortedSet.of();
    BuildRuleParams params = new FakeBuildRuleParamsBuilder(buildTarget).setProjectFilesystem(projectFilesystem).build();
    ApkGenrule apkGenrule = (ApkGenrule) description.createBuildRule(TargetGraph.EMPTY, params, ruleResolver, arg);
    ruleResolver.addToIndex(apkGenrule);
    // Verify all of the observers of the Genrule.
    String expectedApkOutput = projectFilesystem.resolve(projectFilesystem.getBuckPaths().getGenDir().toString() + "/src/com/facebook/sign_fb4a/sign_fb4a.apk").toString();
    assertEquals(expectedApkOutput, apkGenrule.getAbsoluteOutputFilePath(pathResolver));
    assertEquals("The apk that this rule is modifying must have the apk in its deps.", ImmutableSet.of(apkTarget.toString()), apkGenrule.getDeps().stream().map(Object::toString).collect(MoreCollectors.toImmutableSet()));
    BuildContext buildContext = FakeBuildContext.withSourcePathResolver(pathResolver);
    Iterable<Path> expectedInputsToCompareToOutputs = ImmutableList.of(fileSystem.getPath("src/com/facebook/signer.py"), fileSystem.getPath("src/com/facebook/key.properties"));
    MoreAsserts.assertIterablesEquals(expectedInputsToCompareToOutputs, pathResolver.filterInputsToCompareToOutput(apkGenrule.getSrcs()));
    // Verify that the shell commands that the genrule produces are correct.
    List<Step> steps = apkGenrule.getBuildSteps(buildContext, new FakeBuildableContext());
    assertEquals(6, steps.size());
    ExecutionContext executionContext = newEmptyExecutionContext();
    Step firstStep = steps.get(0);
    assertTrue(firstStep instanceof MakeCleanDirectoryStep);
    MakeCleanDirectoryStep mkdirCommand = (MakeCleanDirectoryStep) firstStep;
    Path mkdirDir = projectFilesystem.getBuckPaths().getGenDir().resolve("src/com/facebook/sign_fb4a");
    assertEquals("First command should make sure the output directory exists and is empty.", mkdirDir, mkdirCommand.getPath());
    Step secondStep = steps.get(1);
    assertTrue(secondStep instanceof MakeCleanDirectoryStep);
    MakeCleanDirectoryStep secondMkdirCommand = (MakeCleanDirectoryStep) secondStep;
    Path relativePathToTmpDir = projectFilesystem.getBuckPaths().getGenDir().resolve("src/com/facebook/sign_fb4a__tmp");
    assertEquals("Second command should make sure the temp directory exists.", relativePathToTmpDir, secondMkdirCommand.getPath());
    Step thirdStep = steps.get(2);
    assertTrue(thirdStep instanceof MakeCleanDirectoryStep);
    MakeCleanDirectoryStep thirdMkdirCommand = (MakeCleanDirectoryStep) thirdStep;
    Path relativePathToSrcDir = projectFilesystem.getBuckPaths().getGenDir().resolve("src/com/facebook/sign_fb4a__srcs");
    assertEquals("Third command should make sure the temp directory exists.", relativePathToSrcDir, thirdMkdirCommand.getPath());
    MkdirAndSymlinkFileStep linkSource1 = (MkdirAndSymlinkFileStep) steps.get(3);
    assertEquals(fileSystem.getPath("src/com/facebook/signer.py"), linkSource1.getSource());
    assertEquals(fileSystem.getPath(relativePathToSrcDir + "/signer.py"), linkSource1.getTarget());
    MkdirAndSymlinkFileStep linkSource2 = (MkdirAndSymlinkFileStep) steps.get(4);
    assertEquals(fileSystem.getPath("src/com/facebook/key.properties"), linkSource2.getSource());
    assertEquals(fileSystem.getPath(relativePathToSrcDir + "/key.properties"), linkSource2.getTarget());
    Step sixthStep = steps.get(5);
    assertTrue(sixthStep instanceof AbstractGenruleStep);
    AbstractGenruleStep genruleCommand = (AbstractGenruleStep) sixthStep;
    assertEquals("genrule", genruleCommand.getShortName());
    ImmutableMap<String, String> environmentVariables = genruleCommand.getEnvironmentVariables(executionContext);
    assertEquals(new ImmutableMap.Builder<String, String>().put("APK", projectFilesystem.resolve(BuildTargets.getGenPath(projectFilesystem, apkTarget, "%s.apk")).toString()).put("OUT", expectedApkOutput).build(), environmentVariables);
    Path scriptFilePath = genruleCommand.getScriptFilePath(executionContext);
    String scriptFileContents = genruleCommand.getScriptFileContents(executionContext);
    assertEquals(ImmutableList.of("/bin/bash", "-e", scriptFilePath.toString()), genruleCommand.getShellCommand(executionContext));
    assertEquals("python signer.py $APK key.properties > $OUT", scriptFileContents);
    EasyMock.verify(parser);
}
Also used : KeystoreBuilder(com.facebook.buck.jvm.java.KeystoreBuilder) JavaLibraryBuilder(com.facebook.buck.jvm.java.JavaLibraryBuilder) FakeBuildRuleParamsBuilder(com.facebook.buck.rules.FakeBuildRuleParamsBuilder) FakeBuildRuleParamsBuilder(com.facebook.buck.rules.FakeBuildRuleParamsBuilder) Step(com.facebook.buck.step.Step) MkdirAndSymlinkFileStep(com.facebook.buck.step.fs.MkdirAndSymlinkFileStep) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) AbstractGenruleStep(com.facebook.buck.shell.AbstractGenruleStep) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) BuildTarget(com.facebook.buck.model.BuildTarget) FileSystem(java.nio.file.FileSystem) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) MkdirAndSymlinkFileStep(com.facebook.buck.step.fs.MkdirAndSymlinkFileStep) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) Path(java.nio.file.Path) PathSourcePath(com.facebook.buck.rules.PathSourcePath) FakeBuildableContext(com.facebook.buck.rules.FakeBuildableContext) BuildTargetParser(com.facebook.buck.parser.BuildTargetParser) PathSourcePath(com.facebook.buck.rules.PathSourcePath) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) AbstractGenruleStep(com.facebook.buck.shell.AbstractGenruleStep) ExecutionContext(com.facebook.buck.step.ExecutionContext) TestExecutionContext(com.facebook.buck.step.TestExecutionContext) BuildRuleParams(com.facebook.buck.rules.BuildRuleParams) FakeBuildContext(com.facebook.buck.rules.FakeBuildContext) BuildContext(com.facebook.buck.rules.BuildContext) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) BuildTargetPatternParser(com.facebook.buck.parser.BuildTargetPatternParser) Test(org.junit.Test)

Example 33 with FakeBuildableContext

use of com.facebook.buck.rules.FakeBuildableContext in project buck by facebook.

the class AssembleDirectoriesTest method testAssembleFoldersWithRelativePath.

@Test
public void testAssembleFoldersWithRelativePath() throws IOException, InterruptedException {
    Path tmp = filesystem.getRootPath();
    Files.createDirectories(tmp.resolve("folder_a"));
    Files.write(tmp.resolve("folder_a/a.txt"), "".getBytes(UTF_8));
    Files.write(tmp.resolve("folder_a/b.txt"), "".getBytes(UTF_8));
    Files.createDirectories(tmp.resolve("folder_b"));
    Files.write(tmp.resolve("folder_b/c.txt"), "".getBytes(UTF_8));
    Files.write(tmp.resolve("folder_b/d.txt"), "".getBytes(UTF_8));
    BuildTarget target = BuildTargetFactory.newInstance(filesystem.getRootPath(), "//:output_folder");
    BuildRuleParams buildRuleParams = new FakeBuildRuleParamsBuilder(target).setProjectFilesystem(filesystem).build();
    ImmutableList<SourcePath> directories = ImmutableList.of(new FakeSourcePath(filesystem, "folder_a"), new FakeSourcePath(filesystem, "folder_b"));
    BuildRuleResolver ruleResolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
    SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(ruleResolver));
    AssembleDirectories assembleDirectories = new AssembleDirectories(buildRuleParams, directories);
    ruleResolver.addToIndex(assembleDirectories);
    ImmutableList<Step> steps = assembleDirectories.getBuildSteps(FakeBuildContext.withSourcePathResolver(pathResolver), new FakeBuildableContext());
    for (Step step : steps) {
        assertEquals(0, step.execute(context).getExitCode());
    }
    Path outputFile = pathResolver.getAbsolutePath(assembleDirectories.getSourcePathToOutput());
    try (DirectoryStream<Path> dir = Files.newDirectoryStream(outputFile)) {
        assertEquals(4, Iterables.size(dir));
    }
}
Also used : SourcePath(com.facebook.buck.rules.SourcePath) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) Path(java.nio.file.Path) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) FakeBuildableContext(com.facebook.buck.rules.FakeBuildableContext) FakeBuildRuleParamsBuilder(com.facebook.buck.rules.FakeBuildRuleParamsBuilder) Step(com.facebook.buck.step.Step) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) SourcePath(com.facebook.buck.rules.SourcePath) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) BuildRuleParams(com.facebook.buck.rules.BuildRuleParams) BuildTarget(com.facebook.buck.model.BuildTarget) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) Test(org.junit.Test)

Example 34 with FakeBuildableContext

use of com.facebook.buck.rules.FakeBuildableContext in project buck by facebook.

the class DuplicateResourcesTest method getAaptStepShellCommand.

private ImmutableList<String> getAaptStepShellCommand(TargetNode<AndroidBinaryDescription.Arg, AndroidBinaryDescription> binary) {
    TargetGraph targetGraph = TargetGraphFactory.newInstance(binary, mainRes, directDepRes, transitiveDepRes, transitiveDepLib, bottomDepRes, library, keystore);
    ActionGraphAndResolver actionGraphAndResolver = ActionGraphCache.getFreshActionGraph(BuckEventBusFactory.newInstance(new IncrementingFakeClock(TimeUnit.SECONDS.toNanos(1))), new DefaultTargetNodeToBuildRuleTransformer(), targetGraph);
    SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(actionGraphAndResolver.getResolver()));
    ImmutableSet<ImmutableList<Step>> ruleSteps = RichStream.from(actionGraphAndResolver.getActionGraph().getNodes()).filter(AaptPackageResources.class).filter(r -> androidBinaryTarget.getUnflavoredBuildTarget().equals(r.getBuildTarget().getUnflavoredBuildTarget())).map(b -> b.getBuildSteps(FakeBuildContext.withSourcePathResolver(pathResolver), new FakeBuildableContext())).map(steps -> steps.stream().filter(step -> step instanceof AaptStep).collect(MoreCollectors.toImmutableList())).filter(steps -> !steps.isEmpty()).collect(MoreCollectors.toImmutableSet());
    assertEquals(1, ruleSteps.size());
    assertEquals(1, Iterables.getOnlyElement(ruleSteps).size());
    AaptStep step = (AaptStep) Iterables.getOnlyElement(Iterables.getOnlyElement(ruleSteps));
    AndroidDirectoryResolver androidDirectoryResolver = new FakeAndroidDirectoryResolver(Optional.of(filesystem.getPath("/android-sdk")), Optional.of(filesystem.getPath("/android-build-tools")), Optional.empty(), Optional.empty());
    AndroidPlatformTarget androidPlatformTarget = AndroidPlatformTarget.createFromDefaultDirectoryStructure("", androidDirectoryResolver, "", ImmutableSet.of(), Optional.empty());
    ExecutionContext context = TestExecutionContext.newBuilder().setAndroidPlatformTargetSupplier(Suppliers.ofInstance(androidPlatformTarget)).build();
    return step.getShellCommand(context);
}
Also used : Iterables(com.google.common.collect.Iterables) FakeBuildContext(com.facebook.buck.rules.FakeBuildContext) Step(com.facebook.buck.step.Step) Assume.assumeFalse(org.junit.Assume.assumeFalse) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) RichStream(com.facebook.buck.util.RichStream) FakeBuildableContext(com.facebook.buck.rules.FakeBuildableContext) BuckEventBusFactory(com.facebook.buck.event.BuckEventBusFactory) ArrayList(java.util.ArrayList) Assert.assertThat(org.junit.Assert.assertThat) KeystoreBuilder(com.facebook.buck.jvm.java.KeystoreBuilder) ExecutionContext(com.facebook.buck.step.ExecutionContext) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) ImmutableList(com.google.common.collect.ImmutableList) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) TestExecutionContext(com.facebook.buck.step.TestExecutionContext) BuildTargetFactory(com.facebook.buck.model.BuildTargetFactory) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) Suppliers(com.google.common.base.Suppliers) ActionGraphCache(com.facebook.buck.rules.ActionGraphCache) MoreCollectors(com.facebook.buck.util.MoreCollectors) Before(org.junit.Before) ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet) ImmutableSet(com.google.common.collect.ImmutableSet) TargetGraph(com.facebook.buck.rules.TargetGraph) TargetNode(com.facebook.buck.rules.TargetNode) Platform(com.facebook.buck.util.environment.Platform) Matchers(org.hamcrest.Matchers) Test(org.junit.Test) BuildTarget(com.facebook.buck.model.BuildTarget) ActionGraphAndResolver(com.facebook.buck.rules.ActionGraphAndResolver) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) TargetGraphFactory(com.facebook.buck.testutil.TargetGraphFactory) Matcher(org.hamcrest.Matcher) IncrementingFakeClock(com.facebook.buck.timing.IncrementingFakeClock) Optional(java.util.Optional) Assert.assertEquals(org.junit.Assert.assertEquals) KeystoreDescription(com.facebook.buck.jvm.java.KeystoreDescription) Joiner(com.google.common.base.Joiner) FakeBuildableContext(com.facebook.buck.rules.FakeBuildableContext) ImmutableList(com.google.common.collect.ImmutableList) IncrementingFakeClock(com.facebook.buck.timing.IncrementingFakeClock) TargetGraph(com.facebook.buck.rules.TargetGraph) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) ExecutionContext(com.facebook.buck.step.ExecutionContext) TestExecutionContext(com.facebook.buck.step.TestExecutionContext) ActionGraphAndResolver(com.facebook.buck.rules.ActionGraphAndResolver) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)

Example 35 with FakeBuildableContext

use of com.facebook.buck.rules.FakeBuildableContext in project buck by facebook.

the class CopyNativeLibrariesTest method testCopyNativeLibrariesCopiesLibDirsInReverseTopoOrder.

@Test
public void testCopyNativeLibrariesCopiesLibDirsInReverseTopoOrder() {
    BuildTarget target = BuildTargetFactory.newInstance("//:test");
    SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
    CopyNativeLibraries copyNativeLibraries = new CopyNativeLibraries(new FakeBuildRuleParamsBuilder(target).build(), ImmutableSet.of(new FakeSourcePath("lib1"), new FakeSourcePath("lib2")), ImmutableSet.of(), ImmutableSet.of(), ImmutableSet.of(), "dex");
    ImmutableList<Step> steps = copyNativeLibraries.getBuildSteps(FakeBuildContext.withSourcePathResolver(pathResolver), new FakeBuildableContext());
    Iterable<String> descriptions = Iterables.transform(steps, step -> step.getDescription(TestExecutionContext.newInstance()));
    assertThat("lib1 contents should be copied *after* lib2", Iterables.indexOf(descriptions, Predicates.containsPattern("lib1")), Matchers.greaterThan(Iterables.indexOf(descriptions, Predicates.containsPattern("lib2"))));
}
Also used : FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) FakeBuildableContext(com.facebook.buck.rules.FakeBuildableContext) FakeBuildRuleParamsBuilder(com.facebook.buck.rules.FakeBuildRuleParamsBuilder) Step(com.facebook.buck.step.Step) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) BuildTarget(com.facebook.buck.model.BuildTarget) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) Test(org.junit.Test)

Aggregations

FakeBuildableContext (com.facebook.buck.rules.FakeBuildableContext)48 Test (org.junit.Test)43 Step (com.facebook.buck.step.Step)42 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)33 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)32 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)29 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)28 BuildTarget (com.facebook.buck.model.BuildTarget)26 FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)20 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)20 BuildContext (com.facebook.buck.rules.BuildContext)18 FakeBuildContext (com.facebook.buck.rules.FakeBuildContext)18 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)17 BuildRule (com.facebook.buck.rules.BuildRule)15 FakeBuildRuleParamsBuilder (com.facebook.buck.rules.FakeBuildRuleParamsBuilder)14 Path (java.nio.file.Path)14 ExecutionContext (com.facebook.buck.step.ExecutionContext)11 TestExecutionContext (com.facebook.buck.step.TestExecutionContext)11 BuildRuleParams (com.facebook.buck.rules.BuildRuleParams)10 PathSourcePath (com.facebook.buck.rules.PathSourcePath)6