Enhancing STC and scenarios.
Change-Id: I57a4d25b7fb726a1242073055474ff5c7c3c1087
diff --git a/utils/stc/src/main/java/org/onlab/stc/StepProcessor.java b/utils/stc/src/main/java/org/onlab/stc/StepProcessor.java
index b2d7635..95d5c86 100644
--- a/utils/stc/src/main/java/org/onlab/stc/StepProcessor.java
+++ b/utils/stc/src/main/java/org/onlab/stc/StepProcessor.java
@@ -22,6 +22,7 @@
import java.io.InputStreamReader;
import java.io.PrintWriter;
+import static java.lang.String.format;
import static org.onlab.stc.Coordinator.print;
/**
@@ -71,8 +72,8 @@
* @return exit code
*/
private int execute() {
- try (PrintWriter pw = new PrintWriter(logFile(step))) {
- process = Runtime.getRuntime().exec(launcher + step.command());
+ try (PrintWriter pw = new PrintWriter(logFile())) {
+ process = Runtime.getRuntime().exec(command());
processOutput(pw);
// Wait for the process to complete and get its exit code.
@@ -90,6 +91,18 @@
}
/**
+ * Returns ready-to-run command for the step.
+ *
+ * @return command to execute
+ */
+ private String command() {
+ return format("%s %s %s %s", launcher,
+ step.env() != null ? step.env() : "-",
+ step.cwd() != null ? step.cwd() : "-",
+ step.command());
+ }
+
+ /**
* Captures output of the step process.
*
* @param pw print writer to send output to
@@ -108,12 +121,11 @@
}
/**
- * Returns the log file for the specified step.
+ * Returns the log file for the step output.
*
- * @param step test step
* @return log file
*/
- private File logFile(Step step) {
+ private File logFile() {
return new File(logDir, step.name() + ".log");
}