From 2e31dd2ad3bdb67a2b66ad1227110c1c29a1add6 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Mon, 24 Aug 2015 17:17:31 +0100 Subject: Add tox.ini file for synapse --- tox.ini | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tox.ini (limited to 'tox.ini') diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000000..a1e0ac70d3 --- /dev/null +++ b/tox.ini @@ -0,0 +1,25 @@ +[tox] +envlist = packaging, py27, pep8 + +[testenv] +deps = + coverage + Twisted>=15.1 + mock +commands = + coverage run --source=./synapse {envbindir}/trial tests + coverage report -m +install_command = + pip install --process-dependency-links --pre {opts} {packages} + +[testenv:packaging] +deps = + check-manifest +commands = + check-manifest + +[testenv:pep8] +basepython = python2.7 +deps = + flake8 +commands = flake8 synapse -- cgit 1.4.1 From d046adf4ecf0737dc111a93d1f1ae7f41bc1bccb Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Tue, 25 Aug 2015 15:44:05 +0100 Subject: Set PYTHONDONTWRITEBYTECODE in the tox environment so that we don't spew .pyc files everywhere --- tox.ini | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tox.ini') diff --git a/tox.ini b/tox.ini index a1e0ac70d3..58cf9613cb 100644 --- a/tox.ini +++ b/tox.ini @@ -6,6 +6,8 @@ deps = coverage Twisted>=15.1 mock +setenv = + PYTHONDONTWRITEBYTECODE = no_byte_code commands = coverage run --source=./synapse {envbindir}/trial tests coverage report -m -- cgit 1.4.1 From e768d7b3a6f925dbd7c5466fa86a4a21432d0d1d Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Wed, 26 Aug 2015 11:41:42 +0100 Subject: Allow tests to be filter when using tox `tox` will run all tests `tox tests.api.test_auth.AuthTestCase` will run just the tests in AuthTestCase --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tox.ini') diff --git a/tox.ini b/tox.ini index 58cf9613cb..370a63cbb8 100644 --- a/tox.ini +++ b/tox.ini @@ -9,7 +9,7 @@ deps = setenv = PYTHONDONTWRITEBYTECODE = no_byte_code commands = - coverage run --source=./synapse {envbindir}/trial tests + coverage run --source=./synapse {envbindir}/trial {posargs:tests} coverage report -m install_command = pip install --process-dependency-links --pre {opts} {packages} -- cgit 1.4.1 From 4f6fa981ec9035b2708ba0dc9db21d5dd629f389 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Wed, 26 Aug 2015 12:45:29 +0100 Subject: Make 'setup.py test' run tox --- setup.cfg | 3 --- setup.py | 27 ++++++++++++++++++++++++++- tox.ini | 2 +- 3 files changed, 27 insertions(+), 5 deletions(-) (limited to 'tox.ini') 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} -- cgit 1.4.1 From 57df6fffa7c3dd71f07012f62c4d63909adcade7 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Tue, 1 Sep 2015 14:47:57 +0100 Subject: Use the version of "matrix-angular-sdk" hosted on pypi --- synapse/python_dependencies.py | 5 ----- tox.ini | 2 -- 2 files changed, 7 deletions(-) (limited to 'tox.ini') diff --git a/synapse/python_dependencies.py b/synapse/python_dependencies.py index 8ec272fd5f..795ef27182 100644 --- a/synapse/python_dependencies.py +++ b/synapse/python_dependencies.py @@ -56,11 +56,6 @@ def github_link(project, version, egg): return "https://github.com/%s/tarball/%s/#egg=%s" % (project, version, egg) DEPENDENCY_LINKS = { - "matrix-angular-sdk": github_link( - project="matrix-org/matrix-angular-sdk", - version="v0.6.6", - egg="matrix_angular_sdk-0.6.6", - ), } diff --git a/tox.ini b/tox.ini index 3f0649b628..a69948484f 100644 --- a/tox.ini +++ b/tox.ini @@ -11,8 +11,6 @@ setenv = commands = coverage run --source=synapse {envbindir}/trial {posargs:tests} coverage report -m -install_command = - pip install --process-dependency-links --pre {opts} {packages} [testenv:packaging] deps = -- cgit 1.4.1 From d58edd98e91ad041a31a96980002c2d8899a2580 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Fri, 30 Oct 2015 11:15:37 +0000 Subject: Update the other place check_joined_room is called --- synapse/events/utils.py | 3 ++- synapse/handlers/sync.py | 2 +- tox.ini | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) (limited to 'tox.ini') diff --git a/synapse/events/utils.py b/synapse/events/utils.py index 48548f8c40..9989b76591 100644 --- a/synapse/events/utils.py +++ b/synapse/events/utils.py @@ -154,7 +154,8 @@ def serialize_event(e, time_now_ms, as_client_event=True, if "redacted_because" in e.unsigned: d["unsigned"]["redacted_because"] = serialize_event( - e.unsigned["redacted_because"], time_now_ms + e.unsigned["redacted_because"], time_now_ms, + event_format=event_format ) if token_id is not None: diff --git a/synapse/handlers/sync.py b/synapse/handlers/sync.py index 04f2d46d15..4c5a2353b2 100644 --- a/synapse/handlers/sync.py +++ b/synapse/handlers/sync.py @@ -520,7 +520,7 @@ class SyncHandler(BaseHandler): current_state=current_state_events, ) - state_events_delta = yield self.check_joined_room( + state_events_delta, _ = yield self.check_joined_room( sync_config, room_id, state_events_delta ) diff --git a/tox.ini b/tox.ini index a69948484f..01b23e6bd9 100644 --- a/tox.ini +++ b/tox.ini @@ -19,6 +19,7 @@ commands = check-manifest [testenv:pep8] +skip_install = True basepython = python2.7 deps = flake8 -- cgit 1.4.1 From 233af7c74bff9815a282bdd43d9979b081189544 Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Fri, 13 Nov 2015 16:22:51 +0000 Subject: Pull out jenkins script into a checked in script --- MANIFEST.in | 2 ++ jenkins.sh | 4 ++++ tox.ini | 4 +++- 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100755 jenkins.sh (limited to 'tox.ini') diff --git a/MANIFEST.in b/MANIFEST.in index 573e21f41d..5668665db7 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -20,4 +20,6 @@ recursive-include synapse/static *.gif recursive-include synapse/static *.html recursive-include synapse/static *.js +exclude jenkins.sh + prune demo/etc diff --git a/jenkins.sh b/jenkins.sh new file mode 100755 index 0000000000..2680d16b42 --- /dev/null +++ b/jenkins.sh @@ -0,0 +1,4 @@ +#!/bin/bash -eu + +export PYTHONDONTWRITEBYTECODE=yep +TOXSUFFIX="--reporter=subunit | subunit-1to2 | subunit2junitxml --no-passthrough --output-to=results.xml" tox diff --git a/tox.ini b/tox.ini index 01b23e6bd9..cf54ebb0ac 100644 --- a/tox.ini +++ b/tox.ini @@ -6,10 +6,12 @@ deps = coverage Twisted>=15.1 mock + python-subunit + junitxml setenv = PYTHONDONTWRITEBYTECODE = no_byte_code commands = - coverage run --source=synapse {envbindir}/trial {posargs:tests} + /bin/bash -c "coverage run --source=synapse {envbindir}/trial {posargs:tests} {env:TOXSUFFIX:}" coverage report -m [testenv:packaging] -- cgit 1.4.1 From 09bb5cf02fa26ac798ce5f89274eb6a047872bb9 Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Mon, 16 Nov 2015 14:30:18 -0500 Subject: Output results files on jenkins Outputs: * results.xml * coverage.xml * violations.flake8.log --- jenkins.sh | 16 +++++++++++++++- tox.ini | 6 +++--- 2 files changed, 18 insertions(+), 4 deletions(-) (limited to 'tox.ini') diff --git a/jenkins.sh b/jenkins.sh index 2680d16b42..0a8bde933d 100755 --- a/jenkins.sh +++ b/jenkins.sh @@ -1,4 +1,18 @@ #!/bin/bash -eu export PYTHONDONTWRITEBYTECODE=yep -TOXSUFFIX="--reporter=subunit | subunit-1to2 | subunit2junitxml --no-passthrough --output-to=results.xml" tox + +# Output test results as junit xml +export TRIAL_FLAGS="--reporter=subunit" +export TOXSUFFIX="| subunit-1to2 | subunit2junitxml --no-passthrough --output-to=results.xml" + +# Output coverage to coverage.xml +export DUMP_COVERAGE_COMMAND="coverage xml -o coverage.xml" + +# Output flake8 violations to violations.flake8.log +# Don't exit with non-0 status code on Jenkins, +# so that the build steps continue and a later step can decided whether to +# UNSTABLE or FAILURE this build. +export PEP8SUFFIX="--output-file=violations.flake8.log || echo flake8 finished with status code \$?" + +exec tox diff --git a/tox.ini b/tox.ini index cf54ebb0ac..95424765c3 100644 --- a/tox.ini +++ b/tox.ini @@ -11,8 +11,8 @@ deps = setenv = PYTHONDONTWRITEBYTECODE = no_byte_code commands = - /bin/bash -c "coverage run --source=synapse {envbindir}/trial {posargs:tests} {env:TOXSUFFIX:}" - coverage report -m + /bin/bash -c "coverage run --source=synapse {envbindir}/trial {env:TRIAL_FLAGS:} {posargs:tests} {env:TOXSUFFIX:}" + {env:DUMP_COVERAGE_COMMAND:coverage report -m} [testenv:packaging] deps = @@ -25,4 +25,4 @@ skip_install = True basepython = python2.7 deps = flake8 -commands = flake8 synapse +commands = /bin/bash -c "flake8 synapse {env:PEP8SUFFIX:}" -- cgit 1.4.1