summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Pierre <benoit.pierre@gmail.com>2019-01-28 22:57:20 +0100
committerJason R. Coombs <jaraco@jaraco.com>2019-01-28 18:04:29 -0500
commitf7447817b65c12dfe508249cea019c41ce0dc23f (patch)
tree7e3e67621556aeba50c5302928181558b60bb2b8
parent78fd73026ad7284819936b651f7cfbe8a1ec98c8 (diff)
downloadpython-setuptools-git-f7447817b65c12dfe508249cea019c41ce0dc23f.tar.gz
test: add a simple regression test for `build_ext`
-rw-r--r--setuptools/tests/environment.py2
-rw-r--r--setuptools/tests/test_build_ext.py70
2 files changed, 72 insertions, 0 deletions
diff --git a/setuptools/tests/environment.py b/setuptools/tests/environment.py
index c67898ca..bd3119ef 100644
--- a/setuptools/tests/environment.py
+++ b/setuptools/tests/environment.py
@@ -46,6 +46,8 @@ def run_setup_py(cmd, pypath=None, path=None,
cmd, stdout=_PIPE, stderr=_PIPE, shell=shell, env=env,
)
+ if isinstance(data_stream, tuple):
+ data_stream = slice(*data_stream)
data = proc.communicate()[data_stream]
except OSError:
return 1, ''
diff --git a/setuptools/tests/test_build_ext.py b/setuptools/tests/test_build_ext.py
index 60257154..3dc87ca3 100644
--- a/setuptools/tests/test_build_ext.py
+++ b/setuptools/tests/test_build_ext.py
@@ -8,6 +8,10 @@ from setuptools.command.build_ext import build_ext, get_abi3_suffix
from setuptools.dist import Distribution
from setuptools.extension import Extension
+from . import environment
+from .files import build_files
+from .textwrap import DALS
+
class TestBuildExt:
def test_get_ext_filename(self):
@@ -43,3 +47,69 @@ class TestBuildExt:
assert res.endswith('eggs.pyd')
else:
assert 'abi3' in res
+
+
+def test_build_ext_config_handling(tmpdir_cwd):
+ files = {
+ 'setup.py': DALS(
+ """
+ from setuptools import Extension, setup
+ setup(
+ name='foo',
+ version='0.0.0',
+ ext_modules=[Extension('foo', ['foo.c'])],
+ )
+ """),
+ 'foo.c': DALS(
+ """
+ #include "Python.h"
+
+ #if PY_MAJOR_VERSION >= 3
+
+ static struct PyModuleDef moduledef = {
+ PyModuleDef_HEAD_INIT,
+ "foo",
+ NULL,
+ 0,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ };
+
+ #define INITERROR return NULL
+
+ PyMODINIT_FUNC PyInit_foo(void)
+
+ #else
+
+ #define INITERROR return
+
+ void initfoo(void)
+
+ #endif
+ {
+ #if PY_MAJOR_VERSION >= 3
+ PyObject *module = PyModule_Create(&moduledef);
+ #else
+ PyObject *module = Py_InitModule("extension", NULL);
+ #endif
+ if (module == NULL)
+ INITERROR;
+ #if PY_MAJOR_VERSION >= 3
+ return module;
+ #endif
+ }
+ """),
+ 'setup.cfg': DALS(
+ """
+ [build]
+ build-base = foo_build
+ """),
+ }
+ build_files(files)
+ code, output = environment.run_setup_py(
+ cmd=['build'], data_stream=(0, 2),
+ )
+ assert code == 0, '\nSTDOUT:\n%s\nSTDERR:\n%s' % output