Thomas Vachuska
Committed by Gerrit Code Review

Added end-of-run summary.

Change-Id: I5f749bf08d49544156309c0e0cdaff077ab6398b
...@@ -27,6 +27,7 @@ import java.text.SimpleDateFormat; ...@@ -27,6 +27,7 @@ import java.text.SimpleDateFormat;
27 import java.util.Date; 27 import java.util.Date;
28 import java.util.List; 28 import java.util.List;
29 import java.util.Objects; 29 import java.util.Objects;
30 +import java.util.Set;
30 31
31 import static java.lang.System.currentTimeMillis; 32 import static java.lang.System.currentTimeMillis;
32 import static org.onlab.stc.Coordinator.Status.*; 33 import static org.onlab.stc.Coordinator.Status.*;
...@@ -43,6 +44,9 @@ public final class Main { ...@@ -43,6 +44,9 @@ public final class Main {
43 private static final String GREEN = "\u001B[32;1m"; 44 private static final String GREEN = "\u001B[32;1m";
44 private static final String BLUE = "\u001B[36m"; 45 private static final String BLUE = "\u001B[36m";
45 46
47 + private static final String SUCCESS_SUMMARY = "%sPassed! %d steps succeeded%s";
48 + private static final String FAILURE_SUMMARY = "%sFailed! %d steps succeeded; %d steps failed; %d steps skipped%s";
49 +
46 private enum Command { 50 private enum Command {
47 LIST, RUN, RUN_RANGE, HELP 51 LIST, RUN, RUN_RANGE, HELP
48 } 52 }
...@@ -180,12 +184,26 @@ public final class Main { ...@@ -180,12 +184,26 @@ public final class Main {
180 coordinator.start(); 184 coordinator.start();
181 int exitCode = coordinator.waitFor(); 185 int exitCode = coordinator.waitFor();
182 pause(100); // allow stdout to flush 186 pause(100); // allow stdout to flush
187 + printSummary(exitCode);
183 System.exit(exitCode); 188 System.exit(exitCode);
184 } catch (InterruptedException e) { 189 } catch (InterruptedException e) {
185 print("Unable to execute scenario %s", scenarioFile); 190 print("Unable to execute scenario %s", scenarioFile);
186 } 191 }
187 } 192 }
188 193
194 + private void printSummary(int exitCode) {
195 + Set<Step> steps = coordinator.getSteps();
196 + int count = steps.size();
197 + if (exitCode == 0) {
198 + print(SUCCESS_SUMMARY, color(SUCCEEDED), count, color(null));
199 + } else {
200 + long success = steps.stream().filter(s -> coordinator.getStatus(s) == SUCCEEDED).count();
201 + long failed = steps.stream().filter(s -> coordinator.getStatus(s) == FAILED).count();
202 + long skipped = steps.stream().filter(s -> coordinator.getStatus(s) == SKIPPED).count();
203 + print(FAILURE_SUMMARY, color(FAILED), success, failed, skipped, color(null));
204 + }
205 + }
206 +
189 /** 207 /**
190 * Internal delegate to monitor the process execution. 208 * Internal delegate to monitor the process execution.
191 */ 209 */
......