command line: Forward --timeout values to caliper as --time-limit. am: 341c080d7b am: a01cb358e1 am: 7b0b977b46
am: 69fafaa12a

Change-Id: If593fb7dc900d8be8df9fb856cce8ec7a62eefbb
diff --git a/src/vogar/tasks/RunActionTask.java b/src/vogar/tasks/RunActionTask.java
index 3c43d7b..26b4e3e 100644
--- a/src/vogar/tasks/RunActionTask.java
+++ b/src/vogar/tasks/RunActionTask.java
@@ -45,7 +45,7 @@
     };
 
     protected final Run run;
-    private final boolean useLargeTimeout;
+    private final int timeoutSeconds;
     private final Action action;
     private final String actionName;
     private Command currentCommand;
@@ -57,7 +57,10 @@
         this.run = run;
         this.action = action;
         this.actionName = action.getName();
-        this.useLargeTimeout = useLargeTimeout;
+
+        this.timeoutSeconds = useLargeTimeout
+                ? run.largeTimeoutSeconds
+                : run.smallTimeoutSeconds;
     }
 
     @Override public boolean isAction() {
@@ -80,9 +83,6 @@
             try {
                 currentCommand.start();
 
-                int timeoutSeconds = useLargeTimeout
-                        ? run.largeTimeoutSeconds
-                        : run.smallTimeoutSeconds;
                 if (timeoutSeconds != 0) {
                     currentCommand.scheduleTimeout(timeoutSeconds);
                 }
@@ -151,6 +151,11 @@
         if (skipPast != null) {
             vmCommandBuilder.args("--skipPast", skipPast);
         }
+
+        // Forward timeout value to Caliper which has its own separate timeout.
+        if (run.runnerType.supportsCaliper()) {
+          vmCommandBuilder.args("--time-limit", String.format("%ds", timeoutSeconds));
+        }
         return vmCommandBuilder
                 .temp(workingDirectory)
                 .debugPort(run.debugPort)
@@ -181,8 +186,8 @@
         if (run.runnerType.supportsCaliper()) {
             run.console.verbose("running " + outcomeName + " with unlimited timeout");
             Command command = currentCommand;
-            if (command != null && run.smallTimeoutSeconds != 0) {
-                command.scheduleTimeout(run.smallTimeoutSeconds);
+            if (command != null && timeoutSeconds != 0) {
+                command.scheduleTimeout(timeoutSeconds);
             }
             run.driver.recordResults = false;
         } else {
@@ -198,8 +203,8 @@
 
     @Override public void finish(Outcome outcome) {
         Command command = currentCommand;
-        if (command != null && run.smallTimeoutSeconds != 0) {
-            command.scheduleTimeout(run.smallTimeoutSeconds);
+        if (command != null && timeoutSeconds != 0) {
+            command.scheduleTimeout(timeoutSeconds);
         }
         lastFinishedOutcome = toQualifiedOutcomeName(outcome.getName());
         // TODO: support flexible timeouts for JUnit tests