From 3c99a0ec62726cc6e2275bc8c822ca4695cc099d Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Mon, 1 Feb 2016 12:12:07 +0100
Subject: [PATCH] Fixed test argument passing.

---
 SimpleTests/MeshTests/MPI/CMakeLists.txt | 8 ++++----
 scripts/cmake/test/AddTest.cmake         | 7 ++++---
 scripts/cmake/test/AddTestWrapper.cmake  | 5 ++---
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/SimpleTests/MeshTests/MPI/CMakeLists.txt b/SimpleTests/MeshTests/MPI/CMakeLists.txt
index 27270295980..ce6812080df 100644
--- a/SimpleTests/MeshTests/MPI/CMakeLists.txt
+++ b/SimpleTests/MeshTests/MPI/CMakeLists.txt
@@ -23,9 +23,9 @@ AddTest(
 	NAME NodePartitionedMeshTestASCII
 	PATH NodePartitionedMesh/ASCII
 	EXECUTABLE test_node_partitioned_mesh
-	EXECUTABLE_ARGS "mesh_3d ${Data_BINARY_DIR}/NodePartitionedMesh/ASCII"
+	EXECUTABLE_ARGS mesh_3d ${Data_BINARY_DIR}/NodePartitionedMesh/ASCII
 	WRAPPER mpirun
-	WRAPPER_ARGS "-np 3"
+	WRAPPER_ARGS -np 3
 	TESTER diff
 	DIFF_DATA mesh_3d_partition_0.msh mesh_3d_partition_1.msh mesh_3d_partition_2.msh
 )
@@ -34,9 +34,9 @@ AddTest(
 	NAME NodePartitionedMeshTestBinary
 	PATH NodePartitionedMesh/Binary
 	EXECUTABLE test_node_partitioned_mesh
-	EXECUTABLE_ARGS "mesh_3d ${Data_BINARY_DIR}/NodePartitionedMesh/Binary"
+	EXECUTABLE_ARGS mesh_3d ${Data_BINARY_DIR}/NodePartitionedMesh/Binary
 	WRAPPER mpirun
-	WRAPPER_ARGS "-np 3"
+	WRAPPER_ARGS -np 3
 	TESTER diff
 	DIFF_DATA mesh_3d_partition_0.msh mesh_3d_partition_1.msh mesh_3d_partition_2.msh
 )
diff --git a/scripts/cmake/test/AddTest.cmake b/scripts/cmake/test/AddTest.cmake
index fb9498e2241..c72d82db91a 100644
--- a/scripts/cmake/test/AddTest.cmake
+++ b/scripts/cmake/test/AddTest.cmake
@@ -43,7 +43,7 @@ function (AddTest)
 	file(MAKE_DIRECTORY ${AddTest_BINARY_PATH})
 	file(TO_NATIVE_PATH "${AddTest_BINARY_PATH}" AddTest_BINARY_PATH_NATIVE)
 
-	set(AddTest_EXECUTABLE_ARGS "${AddTest_EXECUTABLE_ARGS} -o ${AddTest_BINARY_PATH_NATIVE}")
+	set(AddTest_EXECUTABLE_ARGS ${AddTest_EXECUTABLE_ARGS} -o ${AddTest_BINARY_PATH_NATIVE})
 
 	# set defaults
 	if(NOT AddTest_EXECUTABLE)
@@ -157,10 +157,10 @@ function (AddTest)
 		NAME "${AddTest_EXECUTABLE}-${AddTest_NAME}-${AddTest_WRAPPER}"
 		COMMAND ${CMAKE_COMMAND}
 		-DEXECUTABLE=${AddTest_EXECUTABLE_PARSED}
-		-DEXECUTABLE_ARGS=${AddTest_EXECUTABLE_ARGS}
+		"-DEXECUTABLE_ARGS=${AddTest_EXECUTABLE_ARGS}"
 		-Dcase_path=${AddTest_SOURCE_PATH}
 		-DWRAPPER_COMMAND=${WRAPPER_COMMAND}
-		-DWRAPPER_ARGS=${AddTest_WRAPPER_ARGS}
+		"-DWRAPPER_ARGS=${AddTest_WRAPPER_ARGS}"
 		-P ${PROJECT_SOURCE_DIR}/scripts/cmake/test/AddTestWrapper.cmake
 	)
 
@@ -199,3 +199,4 @@ function (AddTest)
 		PROPERTIES DEPENDS ${AddTest_EXECUTABLE}-${AddTest_NAME}-${AddTest_WRAPPER})
 
 endfunction()
+
diff --git a/scripts/cmake/test/AddTestWrapper.cmake b/scripts/cmake/test/AddTestWrapper.cmake
index 17c1fd7e626..eb23e6d35c5 100644
--- a/scripts/cmake/test/AddTestWrapper.cmake
+++ b/scripts/cmake/test/AddTestWrapper.cmake
@@ -1,6 +1,5 @@
-string(REPLACE " " ";" WRAPPER_COMMAND ${WRAPPER_COMMAND})
-string(REPLACE " " ";" WRAPPER_ARGS ${WRAPPER_ARGS})
-string(REPLACE " " ";" EXECUTABLE_ARGS ${EXECUTABLE_ARGS})
+# IMPORTANT: multiple arguments in one variables have to be in list notation (;)
+# and have to be quoted when passed "-DEXECUTABLE_ARGS=${AddTest_EXECUTABLE_ARGS}"
 execute_process(
 	COMMAND ${WRAPPER_COMMAND} ${WRAPPER_ARGS} ${EXECUTABLE} ${EXECUTABLE_ARGS}
 	WORKING_DIRECTORY ${case_path}
-- 
GitLab