package ciir.jfoley.chai;

import ciir.jfoley.chai.io.Streams;
import ciir.jfoley.chai.string.StrUtil;

import java.io.IOException;
import java.util.Arrays;

/**
 * Interface to Java's lackluster Process API.
 * @author jfoley.
 */
public class Spawn {
	public static void doProcess(String... args) throws IOException, InterruptedException {
		Process exec = Runtime.getRuntime().exec(args);
		int status = exec.waitFor();
		Streams.copy(exec.getErrorStream(), System.err);
		Streams.copy(exec.getInputStream(), System.err);
		System.err.println("# status: " + status + " for: " + StrUtil.join(Arrays.asList(args), " "));
		if(status != 0) throw new RuntimeException();
	}
}

@@ -276,16 +276,36 @@
 Process(
+int expectedStatus, 
 String..
@@ -654,9 +654,22 @@
  != 
-0
+expectedStatus
 ) th
@@ -698,11 +698,130 @@
 on();%0A%09%7D
+%0A%0A  public static void doProcess(String... args) throws IOException, InterruptedException %7B%0A    doProcess(0, args);%0A  %7D
 %0A%7D%0A

Allow expecting a different status code.