diff options
author | Alexey Borzenkov <snaury@gmail.com> | 2014-06-25 22:16:47 +0400 |
---|---|---|
committer | Alexey Borzenkov <snaury@gmail.com> | 2014-06-25 22:16:47 +0400 |
commit | daa1ec1a2c175317ebefdea79cddc5683e6dc520 (patch) | |
tree | 3b4c250c1a242e4c464b7665424a4f3dacf0a470 | |
parent | 3299cf1962171aa1b33f8cdb05d8de268592b20f (diff) | |
download | greenlet-daa1ec1a2c175317ebefdea79cddc5683e6dc520.tar.gz |
Add support for custom build directory for tests
-rwxr-xr-x | run-tests.py | 7 | ||||
-rw-r--r-- | tests/__init__.py | 10 |
2 files changed, 11 insertions, 6 deletions
diff --git a/run-tests.py b/run-tests.py index 525dc9b..fdca171 100755 --- a/run-tests.py +++ b/run-tests.py @@ -5,6 +5,7 @@ from distutils.spawn import spawn build = True verbosity = 2 +build_base = None here = os.path.dirname(os.path.abspath(__file__)) os.chdir(here) @@ -16,7 +17,7 @@ def bits(): # -- parse options try: - opts, args = getopt.getopt(sys.argv[1:], "nq") + opts, args = getopt.getopt(sys.argv[1:], "nqb:") if args: raise getopt.GetoptError("too many arguments") except getopt.GetoptError: @@ -27,6 +28,8 @@ for o, a in opts: verbosity = 0 elif o == "-n": build = False + elif o == "-b": + build_base = a # -- build greenlet if build: @@ -55,5 +58,5 @@ sys.stdout.flush() # -- run tests from tests import test_collector -if unittest.TextTestRunner(verbosity=verbosity).run(test_collector()).failures: +if unittest.TextTestRunner(verbosity=verbosity).run(test_collector(build_base)).failures: sys.exit(1) diff --git a/tests/__init__.py b/tests/__init__.py index 2f73330..fb95c8d 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -20,11 +20,11 @@ else: TEST_EXTENSIONS_CPP = [] -def test_collector(): +def test_collector(build_base=None): """Collect all tests under the tests directory and return a unittest.TestSuite """ - build_test_extensions() + build_test_extensions(build_base) tests_dir = os.path.realpath(os.path.dirname(__file__)) test_module_list = [ 'tests.%s' % os.path.splitext(os.path.basename(t))[0] @@ -34,7 +34,7 @@ def test_collector(): return unittest.TestLoader().loadTestsFromNames(test_module_list) -def build_test_extensions(): +def build_test_extensions(build_base=None): """Because distutils sucks, it just copies the entire contents of the build results dir (e.g. build/lib.linux-i686-2.6) during installation. That means that we can't put any files there that we don't want to distribute. @@ -44,10 +44,12 @@ def build_test_extensions(): multiple Python release and pydebug versions works and test extensions are not distributed. """ + if build_base is None: + build_base = os.path.join('build', 'tests') from my_build_ext import build_ext setup( options={ - 'build': {'build_base': os.path.join('build', 'tests')}, + 'build': {'build_base': build_base}, }, cmdclass=dict(build_ext=build_ext), script_args=['-q', 'build_ext', '-q'], |