From 053dc1eb3be9b04eb15d7637e3c306dee06940ef Mon Sep 17 00:00:00 2001
From: Stanislav Bohm <stanislav.bohm@vsb.cz>
Date: Thu, 10 Nov 2016 10:35:23 +0100
Subject: [PATCH] FIX: Fixed problem with redirecting loom/run/run

---
 src/libloom/tasks/runtask.cpp |  9 +++++++--
 tests/client/py_test.py       | 14 ++++++++++++++
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/src/libloom/tasks/runtask.cpp b/src/libloom/tasks/runtask.cpp
index 277a976..5a3198c 100644
--- a/src/libloom/tasks/runtask.cpp
+++ b/src/libloom/tasks/runtask.cpp
@@ -67,8 +67,13 @@ void RunTask::start(DataVector &inputs)
       std::string path = get_path(name);
       std::string filename = inputs[i]->get_filename();
       assert(!filename.empty());
-      llog->debug("Creating symlink of '{}' for input id={} filename={}",
-                  msg.map_inputs(i), task->get_inputs()[i], filename);
+      if (!task->get_inputs().empty()) {
+        llog->debug("Creating symlink of '{}' for input id={} filename={}",
+                    msg.map_inputs(i), task->get_inputs()[i], filename);
+      } else {
+          llog->debug("Creating symlink of '{}' for filename={}",
+                      msg.map_inputs(i), filename);
+      }
       if (symlink(filename.c_str(), path.c_str())) {
          log_errno_abort("symlink");
       }
diff --git a/tests/client/py_test.py b/tests/client/py_test.py
index 967f0b2..c633428 100644
--- a/tests/client/py_test.py
+++ b/tests/client/py_test.py
@@ -74,6 +74,20 @@ def test_py_redirect2(loom_env):
     assert b"usr\n" in result
 
 
+def test_py_redirect3(loom_env):
+
+    def f(a):
+        return tasks.run("cat X", [(a, "X")])
+
+    loom_env.start(1)
+
+    c = tasks.const("DataData")
+    a = tasks.py_call(f, (c,))
+    result = loom_env.submit(a)
+    assert b"DataData" in result
+
+
+
 def test_py_fail_too_many_args(loom_env):
 
     def g():
-- 
GitLab