Search in sources :

Example 21 with Step

use of com.facebook.buck.step.Step in project buck by facebook.

the class ProGuardObfuscateStepTest method testProguardJvmArgs.

@Test
public void testProguardJvmArgs() {
    List<String> proguardJvmArgs = Arrays.asList("-Dparam1=value1", "-Dparam2=value2");
    ImmutableList.Builder<Step> steps = ImmutableList.builder();
    ProGuardObfuscateStep.create(JavaCompilationConstants.DEFAULT_JAVA_OPTIONS.getJavaRuntimeLauncher(), new FakeProjectFilesystem(), /* proguardJarOverride */
    Optional.empty(), "1024M", Optional.empty(), Paths.get("generated/proguard.txt"), /* customProguardConfigs */
    ImmutableSet.of(), ProGuardObfuscateStep.SdkProguardType.DEFAULT, /* optimizationPasses */
    Optional.empty(), Optional.of(proguardJvmArgs), /* inputAndOutputEntries */
    ImmutableMap.of(), /* additionalLibraryJarsForProguard */
    ImmutableSet.of(Paths.get("myfavorite.jar"), Paths.get("another.jar")), Paths.get("proguard-directory"), new FakeBuildableContext(), false, steps);
    ProGuardObfuscateStep proguardStep = (ProGuardObfuscateStep) steps.build().get(2);
    ImmutableList<String> parameters = proguardStep.getShellCommandInternal(executionContext);
    for (String s : proguardJvmArgs) {
        assertNotEquals(-1, parameters.indexOf(s));
    }
}
Also used : FakeBuildableContext(com.facebook.buck.rules.FakeBuildableContext) ImmutableList(com.google.common.collect.ImmutableList) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) Step(com.facebook.buck.step.Step) Test(org.junit.Test)

Example 22 with Step

use of com.facebook.buck.step.Step in project buck by facebook.

the class SmartDexingStepTest method testCreateDxStepForDxPseudoRuleWithDexOutput.

@Test
public void testCreateDxStepForDxPseudoRuleWithDexOutput() throws IOException {
    ProjectFilesystem filesystem = FakeProjectFilesystem.createJavaOnlyFilesystem();
    ImmutableList<Path> filesToDex = ImmutableList.of(Paths.get("foo.dex.jar"), Paths.get("bar.dex.jar"));
    Path outputPath = Paths.get("classes.dex");
    EnumSet<DxStep.Option> dxOptions = EnumSet.noneOf(DxStep.Option.class);
    Step dxStep = SmartDexingStep.createDxStepForDxPseudoRule(filesystem, filesToDex, outputPath, dxOptions, Optional.empty(), Optional.empty());
    assertEquals(Joiner.on(" ").join("(cd", filesystem.getRootPath(), "&&", Paths.get("/usr/bin/dx"), "--dex --output", filesystem.resolve("classes.dex"), filesystem.resolve("foo.dex.jar"), filesystem.resolve("bar.dex.jar") + ")"), dxStep.getDescription(createMockedExecutionContext()));
    verifyAll();
}
Also used : Path(java.nio.file.Path) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) Step(com.facebook.buck.step.Step) CompositeStep(com.facebook.buck.step.CompositeStep) Test(org.junit.Test)

Example 23 with Step

use of com.facebook.buck.step.Step in project buck by facebook.

the class MultiarchFileTest method descriptionWithMultiplePlatformArgsShouldGenerateMultiarchFile.

@SuppressWarnings({ "unchecked" })
@Test
public void descriptionWithMultiplePlatformArgsShouldGenerateMultiarchFile() throws Exception {
    BuildTarget target = BuildTargetFactory.newInstance("//foo:thing#iphoneos-i386,iphoneos-x86_64");
    BuildTarget sandboxTarget = BuildTargetFactory.newInstance("//foo:thing#iphoneos-i386,iphoneos-x86_64,sandbox");
    BuildRuleResolver resolver = new BuildRuleResolver(TargetGraphFactory.newInstance(new AppleLibraryBuilder(sandboxTarget).build()), new DefaultTargetNodeToBuildRuleTransformer());
    SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
    ProjectFilesystem filesystem = new FakeProjectFilesystem();
    BuildRule multiarchRule = nodeBuilderFactory.getNodeBuilder(target).build(resolver, filesystem);
    assertThat(multiarchRule, instanceOf(MultiarchFile.class));
    ImmutableList<Step> steps = multiarchRule.getBuildSteps(FakeBuildContext.withSourcePathResolver(pathResolver), new FakeBuildableContext());
    ShellStep step = Iterables.getLast(Iterables.filter(steps, ShellStep.class));
    ExecutionContext executionContext = TestExecutionContext.newInstance();
    ImmutableList<String> command = step.getShellCommand(executionContext);
    assertThat(command, Matchers.contains(endsWith("lipo"), equalTo("-create"), equalTo("-output"), containsString("foo/thing#"), containsString("/thing#"), containsString("/thing#")));
}
Also used : FakeBuildableContext(com.facebook.buck.rules.FakeBuildableContext) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) Step(com.facebook.buck.step.Step) ShellStep(com.facebook.buck.shell.ShellStep) Matchers.containsString(org.hamcrest.Matchers.containsString) 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) BuildTarget(com.facebook.buck.model.BuildTarget) ShellStep(com.facebook.buck.shell.ShellStep) BuildRule(com.facebook.buck.rules.BuildRule) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) Test(org.junit.Test)

Example 24 with Step

use of com.facebook.buck.step.Step in project buck by facebook.

the class AbstractElfExtractSectionsStep method execute.

@Override
public StepExecutionResult execute(ExecutionContext context) throws IOException, InterruptedException {
    ImmutableMap<String, Long> addresses = getNewSectionAddresses();
    Step objcopy = new DefaultShellStep(getFilesystem().getRootPath(), /* args */
    getObjcopyCommand(addresses), /* env */
    ImmutableMap.of());
    return objcopy.execute(context);
}
Also used : DefaultShellStep(com.facebook.buck.shell.DefaultShellStep) Step(com.facebook.buck.step.Step) DefaultShellStep(com.facebook.buck.shell.DefaultShellStep)

Example 25 with Step

use of com.facebook.buck.step.Step in project buck by facebook.

the class GoTest method runTests.

@Override
public ImmutableList<Step> runTests(ExecutionContext executionContext, TestRunningOptions options, SourcePathResolver pathResolver, TestReportingCallback testReportingCallback) {
    Optional<Long> processTimeoutMs = testRuleTimeoutMs.isPresent() ? Optional.of(testRuleTimeoutMs.get() + PROCESS_TIMEOUT_EXTRA_MS) : Optional.empty();
    ImmutableList.Builder<String> args = ImmutableList.builder();
    args.addAll(testMain.getExecutableCommand().getCommandPrefix(pathResolver));
    args.add("-test.v");
    if (testRuleTimeoutMs.isPresent()) {
        args.add("-test.timeout", testRuleTimeoutMs.get() + "ms");
    }
    return ImmutableList.of(new MakeCleanDirectoryStep(getProjectFilesystem(), getPathToTestOutputDirectory()), new MakeCleanDirectoryStep(getProjectFilesystem(), getPathToTestWorkingDirectory()), new SymlinkTreeStep(getProjectFilesystem(), getPathToTestWorkingDirectory(), ImmutableMap.copyOf(FluentIterable.from(resources).transform(input -> Maps.immutableEntry(getProjectFilesystem().getPath(pathResolver.getSourcePathName(getBuildTarget(), input)), pathResolver.getAbsolutePath(input))))), new GoTestStep(getProjectFilesystem(), getPathToTestWorkingDirectory(), args.build(), testMain.getExecutableCommand().getEnvironment(pathResolver), getPathToTestExitCode(), processTimeoutMs, getPathToTestResults()));
}
Also used : BinaryBuildRule(com.facebook.buck.rules.BinaryBuildRule) ExternalTestRunnerRule(com.facebook.buck.rules.ExternalTestRunnerRule) Step(com.facebook.buck.step.Step) HasRuntimeDeps(com.facebook.buck.rules.HasRuntimeDeps) SymlinkTreeStep(com.facebook.buck.step.fs.SymlinkTreeStep) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) ResultType(com.facebook.buck.test.result.type.ResultType) SourcePath(com.facebook.buck.rules.SourcePath) Callable(java.util.concurrent.Callable) TestCaseSummary(com.facebook.buck.test.TestCaseSummary) BuildRule(com.facebook.buck.rules.BuildRule) ExecutionContext(com.facebook.buck.step.ExecutionContext) NoopBuildRule(com.facebook.buck.rules.NoopBuildRule) TestRunningOptions(com.facebook.buck.test.TestRunningOptions) Lists(com.google.common.collect.Lists) Matcher(java.util.regex.Matcher) Label(com.facebook.buck.rules.Label) Tool(com.facebook.buck.rules.Tool) TestResults(com.facebook.buck.test.TestResults) ImmutableList(com.google.common.collect.ImmutableList) FluentIterable(com.google.common.collect.FluentIterable) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) TestResultSummary(com.facebook.buck.test.TestResultSummary) TestRule(com.facebook.buck.rules.TestRule) BuildRuleParams(com.facebook.buck.rules.BuildRuleParams) Path(java.nio.file.Path) MoreCollectors(com.facebook.buck.util.MoreCollectors) ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet) Charsets(com.google.common.base.Charsets) ImmutableSet(com.google.common.collect.ImmutableSet) AddToRuleKey(com.facebook.buck.rules.AddToRuleKey) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) ImmutableMap(com.google.common.collect.ImmutableMap) Files(java.nio.file.Files) Throwables(com.google.common.base.Throwables) IOException(java.io.IOException) BuildTarget(com.facebook.buck.model.BuildTarget) Maps(com.google.common.collect.Maps) List(java.util.List) Stream(java.util.stream.Stream) ExternalTestRunnerTestSpec(com.facebook.buck.rules.ExternalTestRunnerTestSpec) Optional(java.util.Optional) BufferedReader(java.io.BufferedReader) Pattern(java.util.regex.Pattern) BuildTargets(com.facebook.buck.model.BuildTargets) Joiner(com.google.common.base.Joiner) ImmutableList(com.google.common.collect.ImmutableList) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) SymlinkTreeStep(com.facebook.buck.step.fs.SymlinkTreeStep)

Aggregations

Step (com.facebook.buck.step.Step)143 ImmutableList (com.google.common.collect.ImmutableList)82 Path (java.nio.file.Path)79 SourcePath (com.facebook.buck.rules.SourcePath)65 MakeCleanDirectoryStep (com.facebook.buck.step.fs.MakeCleanDirectoryStep)62 Test (org.junit.Test)54 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)49 MkdirStep (com.facebook.buck.step.fs.MkdirStep)44 FakeBuildableContext (com.facebook.buck.rules.FakeBuildableContext)42 ExplicitBuildTargetSourcePath (com.facebook.buck.rules.ExplicitBuildTargetSourcePath)41 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)40 BuildTarget (com.facebook.buck.model.BuildTarget)39 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)36 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)35 ExecutionContext (com.facebook.buck.step.ExecutionContext)34 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)31 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)30 BuildContext (com.facebook.buck.rules.BuildContext)25 RmStep (com.facebook.buck.step.fs.RmStep)24 CopyStep (com.facebook.buck.step.fs.CopyStep)23