Skip to content

Commit

Permalink
Merge pull request grpc#5629 from jtattermusch/python_custom_test
Browse files Browse the repository at this point in the history
Add test_lite custom command for parallel test running.
  • Loading branch information
soltanmm committed Mar 8, 2016
2 parents e713659 + 17908c1 commit 838531e
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ def cython_extensions(package_names, module_names, extra_sources, include_dirs,
'build_tagged_ext': precompiled.BuildTaggedExt,
'gather': commands.Gather,
'run_interop': commands.RunInterop,
'test_lite': commands.TestLite
}

# Ensure that package data is copied over before any commands have been run:
Expand Down
36 changes: 36 additions & 0 deletions src/python/grpcio/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,42 @@ def run(self):
self.distribution.fetch_build_eggs(self.distribution.tests_require)


class TestLite(setuptools.Command):
"""Command to run tests without fetching or building anything."""

description = 'run tests without fetching or building anything.'
user_options = []

def initialize_options(self):
pass

def finalize_options(self):
# distutils requires this override.
pass

def run(self):
self._add_eggs_to_path()

import tests
loader = tests.Loader()
loader.loadTestsFromNames(['tests'])
runner = tests.Runner()
result = runner.run(loader.suite)
if not result.wasSuccessful():
sys.exit('Test failure')

def _add_eggs_to_path(self):
"""Adds all egg files under .eggs to sys.path"""
# TODO(jtattemusch): there has to be a cleaner way to do this
import pkg_resources
eggs_dir = os.path.join(PYTHON_STEM, '../../../.eggs')
eggs = [os.path.join(eggs_dir, filename)
for filename in os.listdir(eggs_dir)
if filename.endswith('.egg')]
for egg in eggs:
sys.path.insert(0, pkg_resources.normalize_path(egg))


class RunInterop(test.test):

description = 'run interop test client/server'
Expand Down
2 changes: 1 addition & 1 deletion tools/run_tests/run_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ if [ "$CONFIG" = "gcov" ]
then
tox
else
$ROOT/.tox/py27/bin/python $ROOT/setup.py test
$ROOT/.tox/py27/bin/python $ROOT/setup.py test_lite
fi

mkdir -p $ROOT/reports
Expand Down

0 comments on commit 838531e

Please sign in to comment.