You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by cs...@apache.org on 2017/05/31 20:40:44 UTC
[incubator-openwhisk] branch master updated: Support interactive
cli testing via input file (#2315)
This is an automated email from the ASF dual-hosted git repository.
csantanapr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
The following commit(s) were added to refs/heads/master by this push:
new 93aa3c6 Support interactive cli testing via input file (#2315)
93aa3c6 is described below
commit 93aa3c64dc75e49afeb63421af6511cc44cdad0a
Author: Mark Deuser <md...@us.ibm.com>
AuthorDate: Wed May 31 16:40:41 2017 -0400
Support interactive cli testing via input file (#2315)
---
tests/src/test/scala/common/TestUtils.java | 19 +++++++++++++++++++
tests/src/test/scala/common/Wsk.scala | 3 ++-
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/tests/src/test/scala/common/TestUtils.java b/tests/src/test/scala/common/TestUtils.java
index 852d4b3..9bca87f 100644
--- a/tests/src/test/scala/common/TestUtils.java
+++ b/tests/src/test/scala/common/TestUtils.java
@@ -254,11 +254,30 @@ public class TestUtils {
* @throws IOException
*/
public static RunResult runCmd(int expectedExitCode, File dir, Logger logger, Map<String, String> env, String... params) throws IOException {
+ return runCmd(expectedExitCode, dir, logger, env, null, params);
+ }
+
+ /**
+ * Runs a command in another process.
+ *
+ * @param expectedExitCode the exit code expected from the command when it exists
+ * @param dir the working directory the command runs with
+ * @param logger the object to manage logging message
+ * @param env an environment map
+ * @param fileStdin a file to use as the command's stdin input
+ * @param params the parameters (including executable) to run
+ * @return RunResult instance
+ * @throws IOException
+ */
+ public static RunResult runCmd(int expectedExitCode, File dir, Logger logger, Map<String, String> env, File fileStdin, String... params) throws IOException {
ProcessBuilder pb = new ProcessBuilder(params);
pb.directory(dir);
if (env != null) {
pb.environment().putAll(env);
}
+ if (fileStdin != null ) {
+ pb.redirectInput(fileStdin);
+ }
Process p = pb.start();
String stdout = inputStreamToString(p.getInputStream());
diff --git a/tests/src/test/scala/common/Wsk.scala b/tests/src/test/scala/common/Wsk.scala
index 21dbd9f..6b7d5e2 100644
--- a/tests/src/test/scala/common/Wsk.scala
+++ b/tests/src/test/scala/common/Wsk.scala
@@ -1003,11 +1003,12 @@ trait RunWskCmd extends Matchers {
verbose: Boolean = false,
env: Map[String, String] = Map("WSK_CONFIG_FILE" -> ""),
workingDir: File = new File("."),
+ stdinFile: Option[File] = None,
showCmd: Boolean = false): RunResult = {
val args = baseCommand
if (verbose) args += "--verbose"
if (showCmd) println(args.mkString(" ") + " " + params.mkString(" "))
- val rr = TestUtils.runCmd(DONTCARE_EXIT, workingDir, TestUtils.logger, sys.env ++ env, args ++ params: _*)
+ val rr = TestUtils.runCmd(DONTCARE_EXIT, workingDir, TestUtils.logger, sys.env ++ env, stdinFile.getOrElse(null), args ++ params: _*)
withClue(reportFailure(args ++ params, expectedExitCode, rr)) {
if (expectedExitCode != TestUtils.DONTCARE_EXIT) {
--
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>'].