diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..65767a37 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,19 @@ +language: python + +python: + - "2.6" + - "2.7" + +# command to install dependencies +install: pip install -r dev-requirements.txt + +before_script: + - "export DISPLAY=:99.0" + - "sh -e /etc/init.d/xvfb start" + - sleep 3 # give xvfb some time to start + +# command to run tests +script: nosetests --with-xunit --with-coverage --cover-html --cover-html-dir=Coverage_report --verbosity=3 test/testall.py + +after_success: + - codecov \ No newline at end of file diff --git a/README.md b/README.md index 4d697a2c..ddfb3344 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Build Status](https://travis-ci.org/python-xlib/python-xlib.svg?branch=master)](https://travis-ci.org/python-xlib/python-xlib) + # The Python X Library ### Copyright @@ -8,12 +10,13 @@ The main part of the code is Some contributed code is copyrighted by [the contributors](https://github.com/python-xlib/python-xlib/graphs/contributors), in these cases that is indicated in the source files in question. -The Python X Library is released under LGPL v2.1 or later, see the file LICENSE for details. +The Python X Library is released under LGPL v2.1 or later (since 2016), see the file LICENSE for details. +0.15rc1 and before were released under GPL v2. ### Requirements The Python X Library requires Python 1.5.2 or newer. It has been -tested to various extents with Python 1.5.2 and 2.0 through 2.6. +tested to various extents with Python 1.5.2 and 2.0 through 2.7. ### Installation diff --git a/dev-requirements.txt b/dev-requirements.txt new file mode 100644 index 00000000..403b034e --- /dev/null +++ b/dev-requirements.txt @@ -0,0 +1,2 @@ +coverage +codecov \ No newline at end of file diff --git a/test/testall.py b/test/testall.py new file mode 100644 index 00000000..2a1ee680 --- /dev/null +++ b/test/testall.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python + +from __future__ import print_function +import sys +import os +import unittest +import struct + +import coverage + +testfolder = os.path.abspath(os.path.dirname(__file__)) +package_root = os.path.abspath(os.path.join(testfolder, "..")) +sys.path.append(package_root) + +# needs to be called before importing the modules +cov = coverage.coverage(branch = True, omit = os.path.join(package_root, 'examples', '*.py')) +cov.start() + +from Xlib.protocol import request, rq, event +import Xlib.protocol.event + +def is_big_endian(): + "Check endianess (return True on big-endian system)" + return struct.unpack('BB', struct.pack('H', 0x0100))[0] != 0 + + +def run_tests(): + "Run all suitable tests" + + if is_big_endian(): + excludes = ['test_events_le', 'test_requests_le', ] + else: + excludes = ['test_events_be', 'test_requests_be', ] + + suite = unittest.TestSuite() + + sys.path.append(testfolder) + + for root, dirs, files in os.walk(testfolder): + test_modules = [ + file.replace('.py', '') for file in files if + file.startswith('test_') and + file.endswith('.py')] + + test_modules = [mod for mod in test_modules if mod.lower() not in excludes] + print('test_modules:') + print(test_modules) + for mod in test_modules: + + imported_mod = __import__(mod, globals(), locals()) + + suite.addTests( + unittest.defaultTestLoader.loadTestsFromModule(imported_mod)) + + unittest.TextTestRunner(verbosity=3).run(suite) + cov.stop() + #print(cov.analysis()) + print(cov.report()) + cov.html_report( + directory = os.path.join(package_root, "Coverage_report"), + omit = [os.path.join(package_root, 'examples', '*.py'), + os.path.join(package_root, 'utils', '*.py'), + os.path.join(package_root, 'test', '*.py'), ] + ) + + +if __name__ == '__main__': + run_tests() \ No newline at end of file