From a470aef9bbe89d9f4ca352f6b2a5c4f72c92eebc Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Thu, 10 Dec 2020 12:20:40 +0100
Subject: [PATCH] Fix Windows poetry add command.

---
 ProcessLib/HeatTransportBHE/Tests.cmake |  2 +-
 scripts/cmake/test/AddTest.cmake        | 11 ++++++++---
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/ProcessLib/HeatTransportBHE/Tests.cmake b/ProcessLib/HeatTransportBHE/Tests.cmake
index 8767b1eb41e..ad9a21f086e 100644
--- a/ProcessLib/HeatTransportBHE/Tests.cmake
+++ b/ProcessLib/HeatTransportBHE/Tests.cmake
@@ -92,7 +92,7 @@ AddTest(
     WRAPPER time
     TESTER vtkdiff
     REQUIREMENTS OGS_USE_PYTHON AND NOT OGS_USE_MPI AND (${Python3_VERSION} VERSION_LESS 3.9)
-    PYTHON_PACKAGES TESPy=0.3.2 --python ">=3.6,<3.9"
+    PYTHON_PACKAGES "TESPy=0.3.2 --python \">=3.6,<3.9\""
     DIFF_DATA
     3bhes_1U_ts_10_t_600.000000.vtu 3bhes_1U_ts_10_t_600.000000.vtu temperature_soil temperature_soil 1e-12 1e-13
     3bhes_1U_ts_10_t_600.000000.vtu 3bhes_1U_ts_10_t_600.000000.vtu temperature_BHE1 temperature_BHE1 1e-10 1e-13
diff --git a/scripts/cmake/test/AddTest.cmake b/scripts/cmake/test/AddTest.cmake
index 08dfceda927..ddca63d31ba 100644
--- a/scripts/cmake/test/AddTest.cmake
+++ b/scripts/cmake/test/AddTest.cmake
@@ -292,10 +292,15 @@ Use six arguments version of AddTest with absolute and relative tolerances")
 
     if(AddTest_PYTHON_PACKAGES)
         if(POETRY)
+            file(WRITE ${PROJECT_BINARY_DIR}/tmp_poetry_add.bat "poetry add ${AddTest_PYTHON_PACKAGES}")
+            if(WIN32)
+                set(EXEC_CMD tmp_poetry_add.bat)
+            else()
+                set(EXEC_CMD ${BASH_TOOL_PATH} tmp_poetry_add.bat)
+            endif()
             execute_process(
-                COMMAND ${CMD_COMMAND} poetry add ${AddTest_PYTHON_PACKAGES}
-                WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
-            )
+                    COMMAND ${EXEC_CMD}
+                    WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
         else()
             message(STATUS "Warning: Benchmark ${AddTest_NAME} requires these "
                 "Python packages: ${AddTest_PYTHON_PACKAGES}!\n Make sure to "
-- 
GitLab