Skip to content

Commit

Permalink
Remove unused parseConduit
Browse files Browse the repository at this point in the history
  • Loading branch information
ascandella committed Aug 10, 2015
1 parent 82b481c commit 66b4ff5
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void processParentCoverage(CodeCoverageMetrics parentCoverage, String bra
}

public void processBuildResult(boolean commentOnSuccess, boolean commentWithConsoleLinkOnFailure, boolean runHarbormaster) {
if (result == result.SUCCESS) {
if (result == Result.SUCCESS) {
if (comment.length() == 0 && (commentOnSuccess || !runHarbormaster)) {
comment.append("Build is green");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@
import com.uber.jenkins.phabricator.utils.CommonUtils;
import hudson.Launcher;
import hudson.util.ArgumentListBuilder;
import net.sf.json.JSONObject;
import net.sf.json.groovy.JsonSlurper;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;

Expand Down Expand Up @@ -61,30 +58,4 @@ public int callConduit(Launcher.ProcStarter starter, PrintStream stderr) throws
Launcher.ProcStarter command = this.getCommand(starter);
return command.stdout(stderr).stderr(stderr).join();
}

public JSONObject parseConduit(Launcher.ProcStarter starter, PrintStream stderr)
throws ArcanistUsageException, IOException, InterruptedException {
Launcher.ProcStarter command = this.getCommand(starter);
ByteArrayOutputStream stdoutBuffer = new ByteArrayOutputStream();

int returnCode = command.
stdout(stdoutBuffer).
stderr(stderr).
join();

if (returnCode != 0) {
String errorMessage = stdoutBuffer.toString();
stderr.println("[arcanist] returned non-zero exit code " + returnCode);
stderr.println("[arcanist] output: " + errorMessage);
throw new ArcanistUsageException(errorMessage);
}

JsonSlurper jsonParser = new JsonSlurper();
try {
return (JSONObject) jsonParser.parseText(stdoutBuffer.toString());
} catch (net.sf.json.JSONException e) {
stderr.println("[arcanist] Unable to parse JSON from response: " + stdoutBuffer.toString());
throw e;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,11 @@
package com.uber.jenkins.phabricator.conduit;

import hudson.Launcher;
import net.sf.json.JSONException;
import net.sf.json.JSONObject;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class ArcanistClientTest {
@Rule
Expand All @@ -50,29 +47,6 @@ public void testEchoWithToken() throws Exception {
assertEquals(result, 0);
}

@Test
public void testParseConduit() throws Exception {
String jsonString = "{\"hello\": \"world\"}";
ArcanistClient client = new ArcanistClient("echo", jsonString, null);

JSONObject result = client.parseConduit(getLauncher().launch(), System.err);
assertTrue(result.has("hello"));
assertEquals(result.getString("hello"), "world");
}

@Test(expected = ArcanistUsageException.class)
public void testNonZeroExitCode() throws Exception {
ArcanistClient client = new ArcanistClient("false", "", null);

client.parseConduit(getLauncher().launch(), System.err);
}

@Test(expected = JSONException.class)
public void testNonJsonOutput() throws Exception {
ArcanistClient client = new ArcanistClient("echo", "not-json", null);
client.parseConduit(getLauncher().launch(), System.err);
}

private Launcher getLauncher() {
return j.createLocalLauncher();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ public class ApplyPatchTaskTest {
public void testApplyPatchWithValidArc() throws Exception {
ApplyPatchTask task = getTask("echo", "true");
Task.Result result = task.run();
assertEquals(result.SUCCESS, result);
assertEquals(Task.Result.SUCCESS, result);
}

@Test
public void testApplyPatchWithInvalidArc() throws Exception {
ApplyPatchTask task = getTask("false", "echo");
Task.Result result = task.run();
assertEquals(result.FAILURE, result);
assertEquals(Task.Result.FAILURE, result);
}

private ApplyPatchTask getTask(String arcPath, String gitPath) throws Exception {
Expand Down

0 comments on commit 66b4ff5

Please sign in to comment.