diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-07-13 09:09:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-13 09:09:06 (GMT) |
commit | ffbd6ae37c427061adae09956cd9388c86264bb7 (patch) | |
tree | a4dabe84300282838035c278b6d3ed25d573391b /Lib/test/_testcppext.cpp | |
parent | 3c91f429181ca9620ffcf049c1e8d5039e9691ee (diff) | |
download | cpython-ffbd6ae37c427061adae09956cd9388c86264bb7.zip cpython-ffbd6ae37c427061adae09956cd9388c86264bb7.tar.gz cpython-ffbd6ae37c427061adae09956cd9388c86264bb7.tar.bz2 |
gh-94751: Install, import and run the test C++ extension (MVP) (GH-94754) (#94780)
This is a quick-and-dirty way to run the C++ tests.
It can definitely be improved in the future, but it should fail when things go wrong.
- Run test functions on import (yes, this can definitely be improved)
- Fudge setuptools metadata (name & version) to make the extension installable
- Install and import the extension in test_cppext
(cherry picked from commit ec5db539b9df99c8b96149768dc2e8598dce2afa)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Diffstat (limited to 'Lib/test/_testcppext.cpp')
-rw-r--r-- | Lib/test/_testcppext.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/_testcppext.cpp b/Lib/test/_testcppext.cpp index b6d3540..be75388 100644 --- a/Lib/test/_testcppext.cpp +++ b/Lib/test/_testcppext.cpp @@ -128,6 +128,9 @@ static PyMethodDef _testcppext_methods[] = { {"add", _testcppext_add, METH_VARARGS, _testcppext_add_doc}, {"test_api_casts", test_api_casts, METH_NOARGS, _Py_NULL}, {"test_unicode", test_unicode, METH_NOARGS, _Py_NULL}, + // Note: _testcppext_exec currently runs all test functions directly. + // When adding a new one, add a call there. + {_Py_NULL, _Py_NULL, 0, _Py_NULL} /* sentinel */ }; @@ -138,6 +141,17 @@ _testcppext_exec(PyObject *module) if (PyModule_AddIntMacro(module, __cplusplus) < 0) { return -1; } + + PyObject *result; + + result = PyObject_CallMethod(module, "test_api_casts", ""); + if (!result) return -1; + Py_DECREF(result); + + result = PyObject_CallMethod(module, "test_unicode", ""); + if (!result) return -1; + Py_DECREF(result); + return 0; } |