From ff8c03241f5d318e7bbeb1d1de55fa40efcd8111 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de>
Date: Tue, 8 Dec 2020 15:29:31 +0100
Subject: [PATCH] PyExamples test: output_idr as arg, not @-var

---
 Tests/Functional/Python/PyExamples/CMakeLists.txt      |  5 ++---
 ...heck_functionality.in.py => check_functionality.py} | 10 ++++------
 2 files changed, 6 insertions(+), 9 deletions(-)
 rename Tests/Functional/Python/PyExamples/{check_functionality.in.py => check_functionality.py} (91%)

diff --git a/Tests/Functional/Python/PyExamples/CMakeLists.txt b/Tests/Functional/Python/PyExamples/CMakeLists.txt
index 8d3d23ce1c7..e00f1a45fb0 100644
--- a/Tests/Functional/Python/PyExamples/CMakeLists.txt
+++ b/Tests/Functional/Python/PyExamples/CMakeLists.txt
@@ -12,13 +12,12 @@ file(GLOB sim_examples ${PY_EXAMPLES_DIR}/sim*/*.py)
 file(GLOB fit_examples ${PY_EXAMPLES_DIR}/fit55_Specular/FitSpecularBasics.py)
 set(examples ${sim_examples} ${fit_examples})
 
-set(test_script ${output_dir}/check_functionality.py)
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/check_functionality.in.py ${test_script} @ONLY)
+set(test_script ${CMAKE_CURRENT_SOURCE_DIR}/check_functionality.py)
 
 foreach(example_path ${examples})
     get_filename_component(example_name ${example_path} NAME_WE)
     set(test_name PyExamples.${example_name})
     add_test(${test_name}
         env PYTHONPATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
-        ${Python3_EXECUTABLE} ${test_script} ${example_path})
+        ${Python3_EXECUTABLE} ${test_script} ${example_path} ${output_dir})
 endforeach()
diff --git a/Tests/Functional/Python/PyExamples/check_functionality.in.py b/Tests/Functional/Python/PyExamples/check_functionality.py
similarity index 91%
rename from Tests/Functional/Python/PyExamples/check_functionality.in.py
rename to Tests/Functional/Python/PyExamples/check_functionality.py
index 51f6055be49..bd4e620d6fb 100644
--- a/Tests/Functional/Python/PyExamples/check_functionality.in.py
+++ b/Tests/Functional/Python/PyExamples/check_functionality.py
@@ -13,8 +13,6 @@ import matplotlib
 matplotlib.use('Agg')
 from matplotlib import pyplot as plt
 
-output_dir = "@output_dir@"
-
 
 def get_figure(filename):
     """
@@ -45,7 +43,7 @@ def exec_full(filepath):
         exec(compile(file.read(), filepath, 'exec'), global_namespace)
 
 
-def run_example(filename):
+def run_example(filename, output_dir):
     """
     Tries to run python example and produce a *.png image
     """
@@ -75,7 +73,7 @@ def run_example(filename):
 
 if __name__ == '__main__':
 
-    if len(sys.argv) != 2:
-        exit("check_functionality called with wrong number of arguments")
+    if len(sys.argv) != 3:
+        exit("Usage: check_functionality <script_to_test> <output_dir>")
 
-    run_example(sys.argv[1])
+    run_example(sys.argv[1], sys.argv[2])
-- 
GitLab