Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stack Of Tasks
dynamic-graph-python
Commits
4c192704
Commit
4c192704
authored
Mar 18, 2014
by
Francois Keith
Browse files
Add a working python file to test the interpreter.
parent
1d505bed
Changes
3
Hide whitespace changes
Inline
Side-by-side
unitTesting/CMakeLists.txt
View file @
4c192704
...
...
@@ -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
)
...
...
unitTesting/interpreter-test-runfile.cc
View file @
4c192704
// 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
;
...
...
unitTesting/test_python_ok.py
0 → 100644
View file @
4c192704
import
sys
,
os
import
re
pkgConfigPath
=
os
.
environ
.
get
(
"PKG_CONFIG_PATH"
)
if
pkgConfigPath
==
None
:
pkgConfigPath
=
''
pathList
=
re
.
split
(
':'
,
pkgConfigPath
)
print
pathList
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment