diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..92b85db1 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,10 @@ +matrix: + include: + - sudo: required + services: + - docker + - os: osx + +script: + - pip install . + - python ./run_tests.py diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..2c7debeb --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,3 @@ +build_script: + - pip install . + - python ./run_tests.py diff --git a/run_tests.py b/run_tests.py new file mode 100644 index 00000000..d61be2d5 --- /dev/null +++ b/run_tests.py @@ -0,0 +1,20 @@ +from __future__ import print_function +import os, sys, subprocess +from glob import glob + +# move cwd to the project root +os.chdir(os.path.dirname(os.path.abspath(__file__))) + +test_projects = glob('test/??_*') + +if len(test_projects) == 0: + print('No test projects found. Aborting.', file=sys.stderr) + exit(2) + +print('Testing projects:', test_projects) + +for project_path in test_projects: + subprocess.check_call(['cibuildwheel', project_path]) + print('%s built successfully.' % project_path) + +print('%d projects built successfully.' % len(test_projects)) diff --git a/test/01_basic/setup.py b/test/01_basic/setup.py new file mode 100644 index 00000000..866fa22c --- /dev/null +++ b/test/01_basic/setup.py @@ -0,0 +1,7 @@ +from setuptools import setup, Extension + +setup( + name="spam", + ext_modules=[Extension('spam', sources=['spam.c'])], + version="0.1.0", +) diff --git a/test/01_basic/spam.c b/test/01_basic/spam.c new file mode 100644 index 00000000..6caa3a25 --- /dev/null +++ b/test/01_basic/spam.c @@ -0,0 +1,48 @@ +#include + +static PyObject * +spam_system(PyObject *self, PyObject *args) +{ + const char *command; + int sts; + + if (!PyArg_ParseTuple(args, "s", &command)) + return NULL; + sts = system(command); + return PyLong_FromLong(sts); +} + +/* Module initialization */ + +#if PY_MAJOR_VERSION >= 3 + #define MOD_INIT(name) PyMODINIT_FUNC PyInit_##name(void) + #define MOD_DEF(m, name, doc, methods, module_state_size) \ + static struct PyModuleDef moduledef = { \ + PyModuleDef_HEAD_INIT, name, doc, module_state_size, methods, }; \ + m = PyModule_Create(&moduledef); + #define MOD_RETURN(m) return m; +#else + #define MOD_INIT(name) PyMODINIT_FUNC init##name(void) + #define MOD_DEF(m, name, doc, methods, module_state_size) \ + m = Py_InitModule3(name, methods, doc); + #define MOD_RETURN(m) return; +#endif + +static PyMethodDef module_methods[] = { + {"system", (PyCFunction)spam_system, METH_VARARGS, + "Execute a shell command."}, + {NULL} /* Sentinel */ +}; + +MOD_INIT(pyinstrument_cext) +{ + PyObject* m; + + MOD_DEF(m, + "spam", + "Example module", + module_methods, + -1) + + MOD_RETURN(m) +} diff --git a/test/README.md b/test/README.md new file mode 100644 index 00000000..d95aacea --- /dev/null +++ b/test/README.md @@ -0,0 +1,3 @@ +This folder contains repos that are built by cibuildwheel to test cibuildwheel. Confusing, I know. + +Basically, if cibuildwheel can build these projects, we're good.