Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:17:51

0001 // The Catch implementation is compiled here. This is a standalone
0002 // translation unit to avoid recompiling it for every test change.
0003 
0004 #include <pybind11/embed.h>
0005 
0006 // Silence MSVC C++17 deprecation warning from Catch regarding std::uncaught_exceptions (up to
0007 // catch 2.0.1; this should be fixed in the next catch release after 2.0.1).
0008 PYBIND11_WARNING_DISABLE_MSVC(4996)
0009 
0010 // Catch uses _ internally, which breaks gettext style defines
0011 #ifdef _
0012 #    undef _
0013 #endif
0014 
0015 #define CATCH_CONFIG_RUNNER
0016 #include <catch.hpp>
0017 
0018 namespace py = pybind11;
0019 
0020 int main(int argc, char *argv[]) {
0021     // Setup for TEST_CASE in test_interpreter.cpp, tagging on a large random number:
0022     std::string updated_pythonpath("pybind11_test_embed_PYTHONPATH_2099743835476552");
0023     const char *preexisting_pythonpath = getenv("PYTHONPATH");
0024     if (preexisting_pythonpath != nullptr) {
0025 #if defined(_WIN32)
0026         updated_pythonpath += ';';
0027 #else
0028         updated_pythonpath += ':';
0029 #endif
0030         updated_pythonpath += preexisting_pythonpath;
0031     }
0032 #if defined(_WIN32)
0033     _putenv_s("PYTHONPATH", updated_pythonpath.c_str());
0034 #else
0035     setenv("PYTHONPATH", updated_pythonpath.c_str(), /*replace=*/1);
0036 #endif
0037 
0038     py::scoped_interpreter guard{};
0039 
0040     auto result = Catch::Session().run(argc, argv);
0041 
0042     return result < 0xff ? result : 0xff;
0043 }