Skip to content

Commit

Permalink
Update test to run PythonQt test in static initializer
Browse files Browse the repository at this point in the history
  • Loading branch information
jcfr committed Feb 16, 2016
1 parent 2f35310 commit 287806b
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion tests/PythonQtDynamicLoaderSharedLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#define MY_EXPORT
#endif

#define RUN_TEST_IN_STATIC_INITIALIZER

extern "C"
{

Expand All @@ -17,7 +19,7 @@ extern "C"
return 42;
}

int MY_EXPORT run_pythonqt_tests(int argc, char* argv[])
int _run_pythonqt_tests(int argc, char* argv[])
{
// Copied from PythonQtTestMain.cpp
int failCount = 0;
Expand All @@ -37,6 +39,18 @@ extern "C"
return failCount;
}


int MY_EXPORT run_pythonqt_tests(int argc, char* argv[])
{
#ifndef RUN_TEST_IN_STATIC_INITIALIZER
return _run_pythonqt_tests(argc, argv);
#else
Q_UNUSED(argc);
Q_UNUSED(argv);
return 0;
#endif
}

}

struct StaticInitializer
Expand All @@ -45,6 +59,12 @@ struct StaticInitializer
{
std::cout << "PythonQtDynamicLoaderSharedLibrary::StaticInitializer" << std::endl;
PythonQt::init(PythonQt::IgnoreSiteModule | PythonQt::RedirectStdOut);

#ifdef RUN_TEST_IN_STATIC_INITIALIZER
int argc = 1;
char * argv [] = {"RunTestInStaticInitializer"};
_run_pythonqt_tests(argc, argv);
#endif
}
};

Expand Down

0 comments on commit 287806b

Please sign in to comment.