catch.cpp
Go to the documentation of this file.
1 // The Catch implementation is compiled here. This is a standalone
2 // translation unit to avoid recompiling it for every test change.
3 
4 #include <pybind11/embed.h>
5 
6 // Silence MSVC C++17 deprecation warning from Catch regarding std::uncaught_exceptions (up to
7 // catch 2.0.1; this should be fixed in the next catch release after 2.0.1).
9 
10 // Catch uses _ internally, which breaks gettext style defines
11 #ifdef _
12 # undef _
13 #endif
14 
15 #define CATCH_CONFIG_RUNNER
16 #include <catch.hpp>
17 
18 namespace py = pybind11;
19 
20 int main(int argc, char *argv[]) {
21  // Setup for TEST_CASE in test_interpreter.cpp, tagging on a large random number:
22  std::string updated_pythonpath("pybind11_test_embed_PYTHONPATH_2099743835476552");
23  const char *preexisting_pythonpath = getenv("PYTHONPATH");
24  if (preexisting_pythonpath != nullptr) {
25 #if defined(_WIN32)
26  updated_pythonpath += ';';
27 #else
28  updated_pythonpath += ':';
29 #endif
30  updated_pythonpath += preexisting_pythonpath;
31  }
32 #if defined(_WIN32)
33  _putenv_s("PYTHONPATH", updated_pythonpath.c_str());
34 #else
35  setenv("PYTHONPATH", updated_pythonpath.c_str(), /*replace=*/1);
36 #endif
37 
38  py::scoped_interpreter guard{};
39 
40  auto result = Catch::Session().run(argc, argv);
41 
42  return result < 0xff ? result : 0xff;
43 }
result
Values result
Definition: OdometryOptimize.cpp:8
embed.h
PYBIND11_WARNING_DISABLE_MSVC
PYBIND11_WARNING_PUSH PYBIND11_WARNING_DISABLE_MSVC(5054) PYBIND11_WARNING_POP static_assert(EIGEN_VERSION_AT_LEAST(3
pybind11
Definition: wrap/pybind11/pybind11/__init__.py:1
main
int main(int argc, char *argv[])
Definition: catch.cpp:20


gtsam
Author(s):
autogenerated on Tue Jun 25 2024 03:00:34