Skip to content

Commit 287806b

Browse files
committed
Update test to run PythonQt test in static initializer
1 parent 2f35310 commit 287806b

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

tests/PythonQtDynamicLoaderSharedLibrary.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#define MY_EXPORT
1010
#endif
1111

12+
#define RUN_TEST_IN_STATIC_INITIALIZER
13+
1214
extern "C"
1315
{
1416

@@ -17,7 +19,7 @@ extern "C"
1719
return 42;
1820
}
1921

20-
int MY_EXPORT run_pythonqt_tests(int argc, char* argv[])
22+
int _run_pythonqt_tests(int argc, char* argv[])
2123
{
2224
// Copied from PythonQtTestMain.cpp
2325
int failCount = 0;
@@ -37,6 +39,18 @@ extern "C"
3739
return failCount;
3840
}
3941

42+
43+
int MY_EXPORT run_pythonqt_tests(int argc, char* argv[])
44+
{
45+
#ifndef RUN_TEST_IN_STATIC_INITIALIZER
46+
return _run_pythonqt_tests(argc, argv);
47+
#else
48+
Q_UNUSED(argc);
49+
Q_UNUSED(argv);
50+
return 0;
51+
#endif
52+
}
53+
4054
}
4155

4256
struct StaticInitializer
@@ -45,6 +59,12 @@ struct StaticInitializer
4559
{
4660
std::cout << "PythonQtDynamicLoaderSharedLibrary::StaticInitializer" << std::endl;
4761
PythonQt::init(PythonQt::IgnoreSiteModule | PythonQt::RedirectStdOut);
62+
63+
#ifdef RUN_TEST_IN_STATIC_INITIALIZER
64+
int argc = 1;
65+
char * argv [] = {"RunTestInStaticInitializer"};
66+
_run_pythonqt_tests(argc, argv);
67+
#endif
4868
}
4969
};
5070

0 commit comments

Comments
 (0)