...
 
...@@ -140,9 +140,13 @@ void PythonInterpreter::initPython() { ...@@ -140,9 +140,13 @@ void PythonInterpreter::initPython() {
std::cerr << "Redirect Outputs ..."; std::cerr << "Redirect Outputs ...";
#endif #endif
// Redirect python output to integrated logger functions // Redirect python output to integrated logger functions
tyti::pylog::redirect_stderr([this](const char*w) {this->pyError(w); }); // Try to redirect python output only when we are in gui mode. Otherwise just leave it on the console
tyti::pylog::redirect_stdout([this](const char* w) {this->pyOutput(w); }); if ( OpenFlipper::Options::gui() ) {
tyti::pylog::redirect_stderr([this](const char*w) {this->pyError(w); });
tyti::pylog::redirect_stdout([this](const char* w) {this->pyOutput(w); });
}
#ifdef PYTHON_DEBUG #ifdef PYTHON_DEBUG
std::cerr << " Done" << std::endl; std::cerr << " Done" << std::endl;
......
...@@ -170,6 +170,42 @@ function( run_local_script_test TEST_SCRIPT ) ...@@ -170,6 +170,42 @@ function( run_local_script_test TEST_SCRIPT )
endfunction() endfunction()
# This function is similar to run_local_script_test() but accepts an additional
# parameter that identifies a file to be loaded from the TestData/Plugin-<Name>
# directory.
#
# TEST_SCRIPT variable with the name (path) of the OpenFlipper script that is to be executed
# If TEST_SCRIPT does not exist in the tests directory of the plugin, no test will be generated!
# INPUT_FILE name of the input file that will be loaded from the TestData/Plugin-<Name> directory
# If INPUT_FILE does not exist no test will be generated!
#
# The test script will be configured such that the following variables get replaced automatically:
# @OPENFLIPPER_TEST_INPUT_FILE@ : The file that should be loaded to run the algorithm on
#
function( run_local_script_test_with_input_file TEST_SCRIPT INPUT_FILE )
# Only get the plugins name without possible collection stuff:
string (REGEX MATCH "Plugin-.+[/\\]?$" _plugin_name ${_plugin_dir})
# Check if we have the TestData directory
if ( NOT EXISTS ${CMAKE_SOURCE_DIR}/TestData )
return()
endif()
# Check if we find the input file
if ( NOT EXISTS ${CMAKE_SOURCE_DIR}/TestData/${_plugin_name}/${INPUT_FILE} )
message("No Input File: ${CMAKE_SOURCE_DIR}/TestData/${_plugin_name}/${INPUT_FILE}")
return()
endif()
set(OPENFLIPPER_TEST_INPUT_FILE "${CMAKE_SOURCE_DIR}/TestData/${_plugin_name}/${INPUT_FILE}")
run_local_script_test( ${TEST_SCRIPT} )
endfunction()
# this function generates a test name and a specific test name from TESTFILE and TESTSCRIPT # this function generates a test name and a specific test name from TESTFILE and TESTSCRIPT
# the generated names are written into the variables, whose names are given by TESTNAME and # the generated names are written into the variables, whose names are given by TESTNAME and
# TESTSCRIPTNAME # TESTSCRIPTNAME
...@@ -320,24 +356,3 @@ function( run_algorithm_test TEST_SCRIPT INPUT_FILE INPUT_REFERENCE ) ...@@ -320,24 +356,3 @@ function( run_algorithm_test TEST_SCRIPT INPUT_FILE INPUT_REFERENCE )
PROCESSORS 1 PROCESSORS 1
) )
endfunction() endfunction()