2017-03-29 22:20:42 +00:00
|
|
|
// The Catch implementation is compiled here. This is a standalone
|
2017-03-23 16:27:32 +00:00
|
|
|
// translation unit to avoid recompiling it for every test change.
|
|
|
|
|
2017-03-29 22:20:42 +00:00
|
|
|
#include <pybind11/embed.h>
|
|
|
|
|
2022-02-10 20:17:07 +00:00
|
|
|
// 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).
|
2022-11-28 15:39:38 +00:00
|
|
|
PYBIND11_WARNING_DISABLE_MSVC(4996)
|
2017-12-15 14:15:25 +00:00
|
|
|
|
tests: update catch to 2.13.5 to fix glibc 2.34 failures (#3679)
* Download catch for MinGw
* Fix rest of MinGW
* fix: update catch to 2.13.5 to fix glibc 2.34 failures
Update the downloaded Catch version to 2.13.5, in order to fix build
failure on glibc 2.34:
```
In file included from /usr/include/signal.h:328,
from /tmp/pybind11/.nox/tests-3-9/tmp/tests/catch/catch.hpp:8030,
from /tmp/pybind11/tests/test_embed/catch.cpp:13:
/tmp/pybind11/.nox/tests-3-9/tmp/tests/catch/catch.hpp:10818:58: error: call to non-‘constexpr’ function ‘long int sysconf(int)’
10818 | static constexpr std::size_t sigStackSize = 32768 >= MINSIGSTKSZ ? 32768 : MINSIGSTKSZ;
| ^~~~~~~~~~~
In file included from /usr/include/python3.9/Python.h:36,
from /tmp/pybind11/include/pybind11/detail/common.h:215,
from /tmp/pybind11/include/pybind11/pytypes.h:12,
from /tmp/pybind11/include/pybind11/cast.h:13,
from /tmp/pybind11/include/pybind11/attr.h:13,
from /tmp/pybind11/include/pybind11/pybind11.h:13,
from /tmp/pybind11/include/pybind11/embed.h:12,
from /tmp/pybind11/tests/test_embed/catch.cpp:4:
/usr/include/unistd.h:640:17: note: ‘long int sysconf(int)’ declared here
640 | extern long int sysconf (int __name) __THROW;
| ^~~~~~~
In file included from /tmp/pybind11/tests/test_embed/catch.cpp:13:
/tmp/pybind11/.nox/tests-3-9/tmp/tests/catch/catch.hpp:10877:45: error: size of array ‘altStackMem’ is not an integral constant-expression
10877 | char FatalConditionHandler::altStackMem[sigStackSize] = {};
| ^~~~~~~~~~~~
```
The newest Catch version cannot be used yet because of regression:
https://github.com/catchorg/Catch2/pull/2364
* fix: add option for _ check, only define on pybind11
* Revert "fix: add option for _ check, only define on pybind11"
This reverts commit 86817db488c547816e21e20d678db318bb286384.
* fix: only undef _ for catch cpp creation.
Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>
Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
2022-02-06 04:53:02 +00:00
|
|
|
// Catch uses _ internally, which breaks gettext style defines
|
|
|
|
#ifdef _
|
2022-02-10 20:17:07 +00:00
|
|
|
# undef _
|
tests: update catch to 2.13.5 to fix glibc 2.34 failures (#3679)
* Download catch for MinGw
* Fix rest of MinGW
* fix: update catch to 2.13.5 to fix glibc 2.34 failures
Update the downloaded Catch version to 2.13.5, in order to fix build
failure on glibc 2.34:
```
In file included from /usr/include/signal.h:328,
from /tmp/pybind11/.nox/tests-3-9/tmp/tests/catch/catch.hpp:8030,
from /tmp/pybind11/tests/test_embed/catch.cpp:13:
/tmp/pybind11/.nox/tests-3-9/tmp/tests/catch/catch.hpp:10818:58: error: call to non-‘constexpr’ function ‘long int sysconf(int)’
10818 | static constexpr std::size_t sigStackSize = 32768 >= MINSIGSTKSZ ? 32768 : MINSIGSTKSZ;
| ^~~~~~~~~~~
In file included from /usr/include/python3.9/Python.h:36,
from /tmp/pybind11/include/pybind11/detail/common.h:215,
from /tmp/pybind11/include/pybind11/pytypes.h:12,
from /tmp/pybind11/include/pybind11/cast.h:13,
from /tmp/pybind11/include/pybind11/attr.h:13,
from /tmp/pybind11/include/pybind11/pybind11.h:13,
from /tmp/pybind11/include/pybind11/embed.h:12,
from /tmp/pybind11/tests/test_embed/catch.cpp:4:
/usr/include/unistd.h:640:17: note: ‘long int sysconf(int)’ declared here
640 | extern long int sysconf (int __name) __THROW;
| ^~~~~~~
In file included from /tmp/pybind11/tests/test_embed/catch.cpp:13:
/tmp/pybind11/.nox/tests-3-9/tmp/tests/catch/catch.hpp:10877:45: error: size of array ‘altStackMem’ is not an integral constant-expression
10877 | char FatalConditionHandler::altStackMem[sigStackSize] = {};
| ^~~~~~~~~~~~
```
The newest Catch version cannot be used yet because of regression:
https://github.com/catchorg/Catch2/pull/2364
* fix: add option for _ check, only define on pybind11
* Revert "fix: add option for _ check, only define on pybind11"
This reverts commit 86817db488c547816e21e20d678db318bb286384.
* fix: only undef _ for catch cpp creation.
Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>
Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
2022-02-06 04:53:02 +00:00
|
|
|
#endif
|
|
|
|
|
2017-03-29 22:20:42 +00:00
|
|
|
#define CATCH_CONFIG_RUNNER
|
2017-03-23 16:27:32 +00:00
|
|
|
#include <catch.hpp>
|
2017-03-29 22:20:42 +00:00
|
|
|
|
|
|
|
namespace py = pybind11;
|
|
|
|
|
2018-07-19 18:03:26 +00:00
|
|
|
int main(int argc, char *argv[]) {
|
2022-08-21 16:44:01 +00:00
|
|
|
// 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
|
|
|
|
|
2017-03-29 22:20:42 +00:00
|
|
|
py::scoped_interpreter guard{};
|
2022-08-21 16:44:01 +00:00
|
|
|
|
2017-03-29 22:20:42 +00:00
|
|
|
auto result = Catch::Session().run(argc, argv);
|
|
|
|
|
|
|
|
return result < 0xff ? result : 0xff;
|
|
|
|
}
|