summary refs log tree commit diff
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-08-26 12:45:29 +0100
committerMark Haines <mark.haines@matrix.org>2015-08-26 12:45:29 +0100
commit4f6fa981ec9035b2708ba0dc9db21d5dd629f389 (patch)
treebec80d07093987b4287c0e26aa496f6309fcc10f
parentMerge pull request #253 from matrix-org/tox (diff)
downloadsynapse-4f6fa981ec9035b2708ba0dc9db21d5dd629f389.tar.xz
Make 'setup.py test' run tox
-rw-r--r--setup.cfg3
-rwxr-xr-xsetup.py27
-rw-r--r--tox.ini2
3 files changed, 27 insertions, 5 deletions
diff --git a/setup.cfg b/setup.cfg
index abb649958e..ba027c7d13 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -3,9 +3,6 @@ source-dir = docs/sphinx
 build-dir  = docs/build
 all_files  = 1
 
-[aliases]
-test = trial
-
 [trial]
 test_suite = tests
 
diff --git a/setup.py b/setup.py
index 8ad20df7cb..adc3316928 100755
--- a/setup.py
+++ b/setup.py
@@ -16,7 +16,8 @@
 
 import glob
 import os
-from setuptools import setup, find_packages
+from setuptools import setup, find_packages, Command
+import sys
 
 
 here = os.path.abspath(os.path.dirname(__file__))
@@ -37,6 +38,28 @@ def exec_file(path_segments):
     exec(code, result)
     return result
 
+
+class Tox(Command):
+    user_options = [('tox-args=', 'a', "Arguments to pass to tox")]
+
+    def initialize_options(self):
+        self.tox_args = None
+
+    def finalize_options(self):
+        self.test_args = []
+        self.test_suite = True
+
+    def run(self):
+        #import here, cause outside the eggs aren't loaded
+        import tox
+        import shlex
+        args = self.tox_args
+        if args:
+            args = shlex.split(self.tox_args)
+        errno = tox.cmdline(args=args)
+        sys.exit(errno)
+
+
 version = exec_file(("synapse", "__init__.py"))["__version__"]
 dependencies = exec_file(("synapse", "python_dependencies.py"))
 long_description = read_file(("README.rst",))
@@ -52,4 +75,6 @@ setup(
     zip_safe=False,
     long_description=long_description,
     scripts=["synctl"] + glob.glob("scripts/*"),
+    tests_require=['tox'],
+    cmdclass={'test': Tox},
 )
diff --git a/tox.ini b/tox.ini
index 370a63cbb8..3f0649b628 100644
--- a/tox.ini
+++ b/tox.ini
@@ -9,7 +9,7 @@ deps =
 setenv =
     PYTHONDONTWRITEBYTECODE = no_byte_code
 commands =
-    coverage run --source=./synapse {envbindir}/trial {posargs:tests}
+    coverage run --source=synapse {envbindir}/trial {posargs:tests}
     coverage report -m
 install_command =
     pip install --process-dependency-links --pre {opts} {packages}