Commit 4c192704 authored by Francois Keith's avatar Francois Keith
Browse files

Add a working python file to test the interpreter.

parent 1d505bed
......@@ -38,6 +38,8 @@ TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} dynamic-graph-python)
ADD_TEST(${EXECUTABLE_NAME} ${EXECUTABLE_NAME})
ADD_CUSTOM_COMMAND(TARGET interpreter-test-runfile POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/unitTesting/test_python_ok.py
${CMAKE_BINARY_DIR}/unitTesting
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/unitTesting/test_python_error.py
${CMAKE_BINARY_DIR}/unitTesting
)
......
// The purpose of this unit test is to check the interpreter::runPythonFile method
#include <cstring>
#include <iostream>
#include "dynamic-graph/python/interpreter.hh"
int main(int argc, char ** argv)
{
// execute numerous time the same file.
......@@ -10,11 +14,34 @@ int main(int argc, char ** argv)
if (argc > 1)
numTest = atoi(argv[1]);
std::string empty_err = "";
dynamicgraph::python::Interpreter interp;
for (int i=0; i<numTest; ++i)
{
interp.runPythonFile("test_python_error.py");
interp.runPythonFile("test_python_ok.py", empty_err);
if (empty_err != "")
{
std::cerr << "At iteration " << i << ", the error was not empty:" << std::endl;
std::cerr << " err " << empty_err << std::endl;
return -1;
}
}
// check that the error remains the same, despite of the number of executions
std::string old_err;
interp.runPythonFile("test_python_error.py", old_err);
std::string new_err = old_err;
for (int i=0; i<numTest; ++i)
{
interp.runPythonFile("test_python_error.py", new_err);
if (old_err != new_err)
{
std::cerr << "At iteration " << i << ", the error changed:" << std::endl;
std::cerr << " old " << old_err << std::endl;
std::cerr << " new " << new_err << std::endl;
return -1;
}
}
return 0;
......
import sys, os
import re
pkgConfigPath = os.environ.get("PKG_CONFIG_PATH")
if pkgConfigPath == None:
pkgConfigPath = ''
pathList = re.split(':', pkgConfigPath)
print pathList
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment