diff options
Diffstat (limited to '3rdparty/pybind11/tests/test_embed/catch.cpp')
-rw-r--r-- | 3rdparty/pybind11/tests/test_embed/catch.cpp | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/3rdparty/pybind11/tests/test_embed/catch.cpp b/3rdparty/pybind11/tests/test_embed/catch.cpp index dd137385..a03a8b37 100644 --- a/3rdparty/pybind11/tests/test_embed/catch.cpp +++ b/3rdparty/pybind11/tests/test_embed/catch.cpp @@ -4,9 +4,14 @@ #include <pybind11/embed.h> #ifdef _MSC_VER -// Silence MSVC C++17 deprecation warning from Catch regarding std::uncaught_exceptions (up to catch -// 2.0.1; this should be fixed in the next catch release after 2.0.1). -# pragma warning(disable: 4996) +// Silence MSVC C++17 deprecation warning from Catch regarding std::uncaught_exceptions (up to +// catch 2.0.1; this should be fixed in the next catch release after 2.0.1). +# pragma warning(disable : 4996) +#endif + +// Catch uses _ internally, which breaks gettext style defines +#ifdef _ +# undef _ #endif #define CATCH_CONFIG_RUNNER @@ -15,7 +20,25 @@ namespace py = pybind11; int main(int argc, char *argv[]) { + // Setup for TEST_CASE in test_interpreter.cpp, tagging on a large random number: + std::string updated_pythonpath("pybind11_test_embed_PYTHONPATH_2099743835476552"); + const char *preexisting_pythonpath = getenv("PYTHONPATH"); + if (preexisting_pythonpath != nullptr) { +#if defined(_WIN32) + updated_pythonpath += ';'; +#else + updated_pythonpath += ':'; +#endif + updated_pythonpath += preexisting_pythonpath; + } +#if defined(_WIN32) + _putenv_s("PYTHONPATH", updated_pythonpath.c_str()); +#else + setenv("PYTHONPATH", updated_pythonpath.c_str(), /*replace=*/1); +#endif + py::scoped_interpreter guard{}; + auto result = Catch::Session().run(argc, argv); return result < 0xff ? result : 0xff; |