8 bool testFile(
const std::string& filename,
const std::string& expectedOutput,
12 for (
int i = 0; i < numTest; ++i) {
14 if (err != expectedOutput) {
15 std::cerr <<
"At iteration " << i
16 <<
", the output was not the one expected:" << std::endl;
17 std::cerr <<
" expected: " << expectedOutput << std::endl;
18 std::cerr <<
" err: " << err << std::endl;
26 const std::string& expectedOutput) {
35 if (err != expectedOutput) {
36 std::cerr <<
"The output was not the one expected:" << std::endl;
37 std::cerr <<
" expected: " << expectedOutput << std::endl;
38 std::cerr <<
" err: " << err << std::endl;
45 int main(
int argc,
char** argv) {
50 if (argc > 1) numTest = atoi(argv[1]);
56 res =
testFile(PATH
"test_python-name_error.py",
58 "Traceback (most recent call last):\n" 60 "test_python-name_error.py\", line 7, in <module>\n" 61 " pathList = re.split(\":\", pkgConfigPath) # noqa\n" 62 "NameError: name 're' is not defined\n"),
66 res =
testFile(PATH
"test_python-ok.py",
"", numTest) && res;
67 res =
testFile(PATH
"unexistant_file.py",
68 PATH
"unexistant_file.py cannot be open", numTest) &&
70 res =
testFile(PATH
"test_python-syntax_error.py",
71 std::string(
" File \"" PATH
72 "test_python-syntax_error.py\", line 2\n" 74 #
if PY_MINOR_VERSION >= 10
76 #elif PY_MINOR_VERSION >= 8
81 "SyntaxError: invalid syntax\n"),
bool testFile(const std::string &filename, const std::string &expectedOutput, int numTest)
int main(int argc, char **argv)
bool testInterpreterDestructor(const std::string &filename, const std::string &expectedOutput)
void runPythonFile(std::string filename)
Method to exectue a python script.