Commit e0a7c267 authored by Jason Madden's avatar Jason Madden

Stop changing directories and store the coveragesite in gevent.testing.

This lets us use the natural location for .coveragerc
parent f65adcde
...@@ -35,7 +35,7 @@ Makefile.ext ...@@ -35,7 +35,7 @@ Makefile.ext
MANIFEST MANIFEST
*_flymake.py *_flymake.py
src/gevent/tests/.coverage\.* .coverage\.*
htmlcov/ htmlcov/
.coverage .coverage
......
...@@ -111,9 +111,9 @@ travis_test_linters: ...@@ -111,9 +111,9 @@ travis_test_linters:
make cffibackendtest make cffibackendtest
coverage_combine: coverage_combine:
coverage combine . src/gevent/tests/ coverage combine .
coverage report -i coverage report -i
-coveralls --rcfile=src/gevent/tests/.coveragerc -coveralls
.PHONY: clean doc prospector lint travistest travis .PHONY: clean doc prospector lint travistest travis
......
...@@ -200,6 +200,11 @@ def run_many(tests, configured_failing_tests=(), failfast=False, quiet=False): ...@@ -200,6 +200,11 @@ def run_many(tests, configured_failing_tests=(), failfast=False, quiet=False):
report(total, failed, passed, took=time.time() - start, report(total, failed, passed, took=time.time() - start,
configured_failing_tests=configured_failing_tests) configured_failing_tests=configured_failing_tests)
def _dir_from_package_name(package):
package_mod = importlib.import_module(package)
package_dir = os.path.dirname(package_mod.__file__)
return package_dir
def discover(tests=None, ignore_files=None, def discover(tests=None, ignore_files=None,
ignored=(), coverage=False, ignored=(), coverage=False,
...@@ -215,12 +220,12 @@ def discover(tests=None, ignore_files=None, ...@@ -215,12 +220,12 @@ def discover(tests=None, ignore_files=None,
if coverage: if coverage:
ignore.update(IGNORE_COVERAGE) ignore.update(IGNORE_COVERAGE)
if not tests:
if package: if package:
package_mod = importlib.import_module(package) package_dir = _dir_from_package_name(package)
package_dir = os.path.dirname(package_mod.__file__)
# We need to glob relative names, our config is based on filenames still # We need to glob relative names, our config is based on filenames still
os.chdir(package_dir) os.chdir(package_dir)
if not tests:
tests = set(glob.glob('test_*.py')) - set(['test_support.py']) tests = set(glob.glob('test_*.py')) - set(['test_support.py'])
else: else:
tests = set(tests) tests = set(tests)
...@@ -437,21 +442,27 @@ def main(): ...@@ -437,21 +442,27 @@ def main():
coverage = False coverage = False
if options.coverage or os.environ.get("GEVENTTEST_COVERAGE"): if options.coverage or os.environ.get("GEVENTTEST_COVERAGE"):
coverage = True coverage = True
# NOTE: This must be run from the greentest directory
os.environ['COVERAGE_PROCESS_START'] = os.path.abspath(".coveragerc") os.environ['COVERAGE_PROCESS_START'] = os.path.abspath(".coveragerc")
if PYPY: if PYPY:
os.environ['COVERAGE_PROCESS_START'] = os.path.abspath(".coveragerc-pypy") os.environ['COVERAGE_PROCESS_START'] = os.path.abspath(".coveragerc-pypy")
os.environ['PYTHONPATH'] = os.path.abspath("coveragesite") + os.pathsep + os.environ.get("PYTHONPATH", "") this_dir = os.path.dirname(__file__)
site_dir = os.path.join(this_dir, 'coveragesite')
site_dir = os.path.abspath(site_dir)
os.environ['PYTHONPATH'] = site_dir + os.pathsep + os.environ.get("PYTHONPATH", "")
# We change directory often, use an absolute path to keep all the # We change directory often, use an absolute path to keep all the
# coverage files (which will have distinct suffixes because of parallel=true in .coveragerc # coverage files (which will have distinct suffixes because of parallel=true in .coveragerc
# in this directory; makes them easier to combine and use with coverage report) # in this directory; makes them easier to combine and use with coverage report)
os.environ['COVERAGE_FILE'] = os.path.abspath(".") + os.sep + ".coverage" os.environ['COVERAGE_FILE'] = os.path.abspath(".") + os.sep + ".coverage"
print("Enabling coverage to", os.environ['COVERAGE_FILE']) print("Enabling coverage to", os.environ['COVERAGE_FILE'], "with site", site_dir)
_setup_environ(debug=options.debug) _setup_environ(debug=options.debug)
if options.config: if options.config:
config = {} config = {}
if not os.path.isfile(options.config) and options.package:
# Ok, try to locate it as a module in the package
package_dir = _dir_from_package_name(options.package)
options.config = os.path.join(package_dir, options.config)
with open(options.config) as f: with open(options.config) as f:
config_data = f.read() config_data = f.read()
six.exec_(config_data, config) six.exec_(config_data, config)
......
...@@ -2,17 +2,5 @@ ...@@ -2,17 +2,5 @@
from __future__ import print_function, absolute_import, division from __future__ import print_function, absolute_import, division
if __name__ == '__main__': if __name__ == '__main__':
# We expect to be running in this directory, to do test discovery
# etc, automatically.
import os
import os.path
this_dir = os.path.dirname(os.path.abspath(__file__))
os.chdir(this_dir)
# We also expect this directory to be on the path, because we
# try to import some test files by their bare name
import sys
sys.path.append(this_dir)
from gevent.testing import testrunner from gevent.testing import testrunner
testrunner.main() testrunner.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment