Source:
public void shouldInvokeSignerIfRequested() throws IOException, NoSuchBuildTargetException, InterruptedException, DeploymentException { ProjectFilesystem filesystem = new ProjectFilesystem(temp.getRoot()); MavenPublishable publishable = (MavenPublishable) JavaLibraryBuilder.createBuilder(BuildTargetFactory.newInstance(" .setMavenCoords("com.example:lib:1.0") .addSrc(new FakeSourcePath("Foo.java")) .build(new BuildRuleResolver( TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())); filesystem.createParentDirs(publishable.getPathToOutput()); filesystem.touch(publishable.getPathToOutput()); Set<String> signatures = new HashSet<>(); ImmutableMap.Builder<ProcessExecutorParams, FakeProcess> commands = ImmutableMap.builder(); ImmutableSet<String> outputs = ImmutableSet.of( publishable.getPathToOutput().toString(), "buck-out/gen/lib#maven.pom"); for (String out : outputs) { Path path = filesystem.getPathForRelativePath(out); Path signed = filesystem.getPathForRelativePath(out + ".asc"); commands.put( ProcessExecutorParams.builder().addCommand( "gpg", "-ab", "--batch", "--passphrase", "passphrase", path.toString()).build(), new FakeProcess(0, "", "")); signatures.add(signed.toString()); filesystem.touch(path); } FakeProcessExecutor executor = new FakeProcessExecutor(commands.build()); Publisher publisher = new Publisher( filesystem, Optional.of(temp.newFolder().toUri().toURL()), Optional.empty(), Optional.empty(), Optional.of("passphrase"), false) { @Override protected ProcessExecutor createProcessExecutor(PrintStream stdout, PrintStream stderr) { try { for (String signature : signatures) { Path path = filesystem.getRootPath().getFileSystem().getPath(signature); filesystem.touch(path); } } catch (IOException e) { throw new RuntimeException(e); } return executor; } }; publisher.publish(ImmutableSet.of(publishable)); }

Target:
public void shouldInvokeSignerIfRequested() throws IOException, NoSuchBuildTargetException, InterruptedException, DeploymentException { ProjectFilesystem filesystem = new ProjectFilesystem(temp.getRoot()); MavenPublishable publishable = (MavenPublishable) JavaLibraryBuilder.createBuilder(BuildTargetFactory.newInstance(" .setMavenCoords("com.example:lib:1.0") .addSrc(new FakeSourcePath("Foo.java")) .build(new BuildRuleResolver( TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())); filesystem.createParentDirs(publishable.getPathToOutput()); filesystem.touch(publishable.getPathToOutput()); Set<String> signatures = new HashSet<>(); ImmutableMap.Builder<ProcessExecutorParams, FakeProcess> commandBuilder = ImmutableMap.builder(); ImmutableSet<String> outputs = ImmutableSet.of( publishable.getPathToOutput().toString(), "buck-out/gen/lib#maven.pom"); for (String out : outputs) { Path path = filesystem.getPathForRelativePath(out); Path signed = filesystem.getPathForRelativePath(out + ".asc"); ProcessExecutorParams signingCommand = ProcessExecutorParams.builder() .addCommand("gpg", "-ab", "--batch", "--passphrase", "passphrase", path.toString()) .build(); commandBuilder.put( signingCommand, new FakeProcess(0, "", "")); signatures.add(signed.toString()); filesystem.touch(path); } ImmutableMap<ProcessExecutorParams, FakeProcess> commands = commandBuilder.build(); FakeProcessExecutor executor = new FakeProcessExecutor(commands); Publisher publisher = new Publisher( filesystem, Optional.of(temp.newFolder().toUri().toURL()), Optional.empty(), Optional.empty(), Optional.of("passphrase"), false) { @Override protected ProcessExecutor createProcessExecutor(PrintStream stdout, PrintStream stderr) { try { for (String signature : signatures) { Path path = filesystem.getRootPath().getFileSystem().getPath(signature); filesystem.touch(path); } } catch (IOException e) { throw new RuntimeException(e); } return executor; } }; publisher.publish(ImmutableSet.of(publishable)); for (ProcessExecutorParams params : commands.keySet()) { assertTrue(executor.isProcessLaunched(params)); } }