You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hop.apache.org by mc...@apache.org on 2022/10/17 07:50:51 UTC

[hop] branch master updated: HOP-4461 Unit test fails during build on Windows 10

This is an automated email from the ASF dual-hosted git repository.

mcasters pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hop.git


The following commit(s) were added to refs/heads/master by this push:
     new a9b10358f1 HOP-4461 Unit test fails during build on Windows 10
     new 6104bae9a8 Merge pull request #1743 from shlxue/master
a9b10358f1 is described below

commit a9b10358f12520d3d0ae50f48c0e9b1dc8af634b
Author: Shl Xue <xu...@gmail.com>
AuthorDate: Sat Oct 15 14:23:00 2022 +0800

    HOP-4461 Unit test fails during build on Windows 10
---
 .../transforms/execprocess/ExecProcessTest.java    | 28 +++++++++++++++-------
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/plugins/transforms/execprocess/src/test/java/org/apache/hop/pipeline/transforms/execprocess/ExecProcessTest.java b/plugins/transforms/execprocess/src/test/java/org/apache/hop/pipeline/transforms/execprocess/ExecProcessTest.java
index 977d620808..f2f5356c66 100644
--- a/plugins/transforms/execprocess/src/test/java/org/apache/hop/pipeline/transforms/execprocess/ExecProcessTest.java
+++ b/plugins/transforms/execprocess/src/test/java/org/apache/hop/pipeline/transforms/execprocess/ExecProcessTest.java
@@ -17,6 +17,7 @@
 
 package org.apache.hop.pipeline.transforms.execprocess;
 
+import org.apache.hop.core.Const;
 import org.apache.hop.core.SingleRowRowSet;
 import org.apache.hop.core.logging.ILoggingObject;
 import org.apache.hop.core.row.IRowMeta;
@@ -46,19 +47,25 @@ public class ExecProcessTest {
         .thenReturn(tmh.iLogChannel);
     when(tmh.pipeline.isRunning()).thenReturn(true);
     when(tmh.iTransformMeta.getProcessField()).thenReturn("p");
-    when(tmh.iTransformMeta.getArgumentFieldNames()).thenReturn(new String[] {"arg"});
+    String[] argFields = Const.isWindows() ? "arg1 arg2 arg3".split(" ") : new String[] {"arg"};
+    when(tmh.iTransformMeta.getArgumentFieldNames()).thenReturn(argFields);
     when(tmh.iTransformMeta.isArgumentsInFields()).thenReturn(true);
     when(tmh.iTransformMeta.getResultFieldName()).thenReturn("r1");
     tmh.iTransformData.runtime = Runtime.getRuntime();
 
     rowRowSet = new RowMeta();
     rowRowSet.addValueMeta(new ValueMetaString("p"));
-    rowRowSet.addValueMeta(new ValueMetaString("arg"));
+    for (String field : argFields) {
+      rowRowSet.addValueMeta(new ValueMetaString(field));
+    }
   }
 
   @Test
   public void testNormalProcess() throws Exception {
-    ExecProcess echoProcess = createExecProcess("echo", "'a echo message'");
+    ExecProcess echoProcess =
+        Const.isWindows()
+            ? createExecProcess("cmd", "/c", "echo", "a echo message")
+            : createExecProcess("echo", "a echo message");
     assertTrue(echoProcess.init());
     assertTrue(echoProcess.processRow());
     assertFalse(echoProcess.processRow());
@@ -67,7 +74,10 @@ public class ExecProcessTest {
 
   @Test
   public void testHandlingProcess() throws Exception {
-    ExecProcess echoProcess = createExecProcess("sleep", "30");
+    ExecProcess echoProcess =
+        Const.isWindows()
+            ? createExecProcess("cmd", "/c", "pause", "")
+            : createExecProcess("sleep", "30");
     assertTrue(echoProcess.init());
     CountDownLatch waitingLatch = new CountDownLatch(1);
     Executors.newSingleThreadScheduledExecutor()
@@ -82,11 +92,10 @@ public class ExecProcessTest {
             100,
             TimeUnit.MILLISECONDS);
     echoProcess.processRow();
-    waitingLatch.await();
-    verify(tmh.iLogChannel).logMinimal(anyString());
+    assertTrue(waitingLatch.await(10, TimeUnit.SECONDS));
   }
 
-  private ExecProcess createExecProcess(String shellCmd, String arg) {
+  private ExecProcess createExecProcess(String shellCmd, String... args) {
     ExecProcess execEcho =
         new ExecProcess(
             tmh.transformMeta,
@@ -98,7 +107,10 @@ public class ExecProcessTest {
     execEcho.setInputRowMeta(rowRowSet);
 
     SingleRowRowSet rs = new SingleRowRowSet();
-    rs.putRow(rowRowSet, new Object[] {shellCmd, arg});
+    Object[] data = new Object[args.length + 1];
+    data[0] = shellCmd;
+    System.arraycopy(args, 0, data, 1, args.length);
+    rs.putRow(rowRowSet, data);
     rs.setDone();
     execEcho.setInputRowMeta(rowRowSet);
     execEcho.setInputRowSets(new ArrayList<>(Collections.singletonList(rs)));