From d6def081c2570661a991399b82905b01311c8d2c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20M=C3=B6bius?= <moebius@cs.rwth-aachen.de>
Date: Thu, 7 Mar 2019 11:13:18 +0100
Subject: [PATCH 1/2] Introduce python tests

---
 tests/CMakeLists.txt        | 11 +++++++++++
 tests/run_script_test.cmake |  2 ++
 tests/testGenerators.cmake  |  9 ++++++---
 3 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 03e8bf25..c0e6a1f4 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -143,6 +143,17 @@ SET (CTEST_DROP_SITE_CDASH FALSE)
       add_subdirectory(${CMAKE_SOURCE_DIR}/${_plugin_dir}/tests ${CMAKE_BINARY_DIR}/tests/${_plugin_name} )
     endif()
 
+     # If a PythonTests subdir exists, we add it here
+    if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/${_plugin_dir}/PythonTests)
+
+      # Only get the plugins name without possible collection:
+      string (REGEX MATCH "Plugin-.+[/\\]?$" _plugin_name ${_plugin_dir})
+
+      add_subdirectory(${CMAKE_SOURCE_DIR}/${_plugin_dir}/PythonTests ${CMAKE_BINARY_DIR}/PythonTests/${_plugin_name} )
+    endif()
+
+
+
    endforeach ()
 
 endif()
diff --git a/tests/run_script_test.cmake b/tests/run_script_test.cmake
index ffdedf5a..e4b162cd 100644
--- a/tests/run_script_test.cmake
+++ b/tests/run_script_test.cmake
@@ -16,6 +16,8 @@ if ( NOT EXISTS ${test_cmd} )
     message(SEND_ERROR "Test Executable missing!")
 endif()
 
+message("Running : ${test_cmd} ${test_args}")
+
 # Execute the process with the given arguments
 # Timeout after 5 minutes
 execute_process(
diff --git a/tests/testGenerators.cmake b/tests/testGenerators.cmake
index 81c13e21..b5ad3973 100644
--- a/tests/testGenerators.cmake
+++ b/tests/testGenerators.cmake
@@ -129,8 +129,11 @@ endfunction()
 #            If TEST_SCRIPT does not exist in the tests directory of the plugin, no test will be generated!
 function( run_local_script_test TEST_SCRIPT )
 
+  
+
   # check if TEST_SCRIPT is at the correct place
-  if ( NOT EXISTS ${CMAKE_SOURCE_DIR}/${_plugin_dir}/tests/${TEST_SCRIPT})
+  if ( NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${TEST_SCRIPT})
+      message("Error, unable to locate test script: ${CMAKE_CURRENT_SOURCE_DIR}/${TEST_SCRIPT}")
       return()
   endif()
 
@@ -139,8 +142,8 @@ function( run_local_script_test TEST_SCRIPT )
 
   # Configure the test script from the current directory with the given filenames and variables into the test directory
   configure_file(
-    ${CMAKE_SOURCE_DIR}/${_plugin_dir}/tests/${TEST_SCRIPT}
-    ${CMAKE_BINARY_DIR}/tests/${_plugin_name}/${TEST_SCRIPT_NAME} @ONLY
+    ${CMAKE_CURRENT_SOURCE_DIR}/${TEST_SCRIPT}
+    ${CMAKE_CURRENT_BINARY_DIR}/${TEST_SCRIPT_NAME} @ONLY
   )
 
   # Execute the script by OpenFlipper
-- 
GitLab


From 715e424f03962ad7f3fdfea0c5f630d00edf02fc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20M=C3=B6bius?= <moebius@cs.rwth-aachen.de>
Date: Thu, 7 Mar 2019 13:12:40 +0100
Subject: [PATCH 2/2] Exit OpenFlipper on python script error in batch mode

---
 PythonInterpreter/PythonInterpreter.cc | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/PythonInterpreter/PythonInterpreter.cc b/PythonInterpreter/PythonInterpreter.cc
index 46119ee3..bcce2f24 100644
--- a/PythonInterpreter/PythonInterpreter.cc
+++ b/PythonInterpreter/PythonInterpreter.cc
@@ -329,6 +329,10 @@ void PythonInterpreter::pyOutput(const char* w)
 void PythonInterpreter::pyError(const char* w)
 {
   if (externalLogging_) {
+    if (OpenFlipper::Options::nogui()) {
+      std::cerr << "Python Error! " << w << std::endl;
+      exit(1);
+    }
     emit log(LOGERR, QString(w));
   } else {
     LogErr += QString::fromUtf8(w);
-- 
GitLab