diff options
author | Cosimo Lupo <cosimo.lupo@daltonmaag.com> | 2015-03-30 10:20:50 +0100 |
---|---|---|
committer | Cosimo Lupo <cosimo.lupo@daltonmaag.com> | 2015-03-30 10:20:50 +0100 |
commit | 4865fd1d4f4b9b28890bab0caf1d6348f524c2c9 (patch) | |
tree | 11d1ee148e978045f3ddbff76a1f1fc73c910de9 /python | |
parent | fea88b8609a86a82b021f235b93d49bdedb88b54 (diff) | |
download | brotli-4865fd1d4f4b9b28890bab0caf1d6348f524c2c9.zip brotli-4865fd1d4f4b9b28890bab0caf1d6348f524c2c9.tar.gz brotli-4865fd1d4f4b9b28890bab0caf1d6348f524c2c9.tar.bz2 |
[python] add test command to setup.py
Diffstat (limited to 'python')
-rw-r--r-- | python/setup.py | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/python/setup.py b/python/setup.py index 71ee3ba..47563b5 100644 --- a/python/setup.py +++ b/python/setup.py @@ -1,8 +1,37 @@ from distutils.core import setup, Extension from distutils.command.build_ext import build_ext +from distutils.cmd import Command import platform from os.path import abspath + +class TestCommand(Command): + """ Run all *_test.py scripts in 'tests' folder with the same Python + interpreter used to run setup.py. + """ + + user_options = [] + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def run(self): + import sys, os, subprocess, glob + + curr_dir = os.path.abspath(os.path.dirname(os.path.realpath(__file__))) + test_dir = os.path.join(curr_dir, 'tests') + os.chdir(test_dir) + + for test in glob.glob("*_test.py"): + try: + subprocess.check_call([sys.executable, test]) + except subprocess.CalledProcessError: + raise SystemExit(1) + + class BuildExt(build_ext): def get_source_files(self): filenames = build_ext.get_source_files(self) @@ -128,5 +157,8 @@ setup( author_email="khaledhosny@eglug.org", license="Apache 2.0", ext_modules=[brotli], - cmdclass={'build_ext': BuildExt}, + cmdclass={ + 'build_ext': BuildExt, + 'test': TestCommand + }, ) |