Commit 5b7aaa54 authored by Robert Bradshaw's avatar Robert Bradshaw

Add option to use common utility code dir to runtests.py

parent deb34879
...@@ -487,7 +487,8 @@ class ErrorWriter(object): ...@@ -487,7 +487,8 @@ class ErrorWriter(object):
class TestBuilder(object): class TestBuilder(object):
def __init__(self, rootdir, workdir, selectors, exclude_selectors, annotate, def __init__(self, rootdir, workdir, selectors, exclude_selectors, annotate,
cleanup_workdir, cleanup_sharedlibs, cleanup_failures, cleanup_workdir, cleanup_sharedlibs, cleanup_failures,
with_pyregr, cython_only, languages, test_bugs, fork, language_level): with_pyregr, cython_only, languages, test_bugs, fork, language_level,
common_utility_dir):
self.rootdir = rootdir self.rootdir = rootdir
self.workdir = workdir self.workdir = workdir
self.selectors = selectors self.selectors = selectors
...@@ -502,6 +503,7 @@ class TestBuilder(object): ...@@ -502,6 +503,7 @@ class TestBuilder(object):
self.test_bugs = test_bugs self.test_bugs = test_bugs
self.fork = fork self.fork = fork
self.language_level = language_level self.language_level = language_level
self.common_utility_dir = common_utility_dir
def build_suite(self): def build_suite(self):
suite = unittest.TestSuite() suite = unittest.TestSuite()
...@@ -631,13 +633,15 @@ class TestBuilder(object): ...@@ -631,13 +633,15 @@ class TestBuilder(object):
cython_only=self.cython_only, cython_only=self.cython_only,
fork=self.fork, fork=self.fork,
language_level=self.language_level, language_level=self.language_level,
warning_errors=warning_errors) warning_errors=warning_errors,
common_utility_dir=self.common_utility_dir)
class CythonCompileTestCase(unittest.TestCase): class CythonCompileTestCase(unittest.TestCase):
def __init__(self, test_directory, workdir, module, tags, language='c', preparse='id', def __init__(self, test_directory, workdir, module, tags, language='c', preparse='id',
expect_errors=False, annotate=False, cleanup_workdir=True, expect_errors=False, annotate=False, cleanup_workdir=True,
cleanup_sharedlibs=True, cleanup_failures=True, cython_only=False, cleanup_sharedlibs=True, cleanup_failures=True, cython_only=False,
fork=True, language_level=2, warning_errors=False): fork=True, language_level=2, warning_errors=False,
common_utility_dir=None):
self.test_directory = test_directory self.test_directory = test_directory
self.tags = tags self.tags = tags
self.workdir = workdir self.workdir = workdir
...@@ -654,6 +658,7 @@ class CythonCompileTestCase(unittest.TestCase): ...@@ -654,6 +658,7 @@ class CythonCompileTestCase(unittest.TestCase):
self.fork = fork self.fork = fork
self.language_level = language_level self.language_level = language_level
self.warning_errors = warning_errors self.warning_errors = warning_errors
self.common_utility_dir = common_utility_dir
unittest.TestCase.__init__(self) unittest.TestCase.__init__(self)
def shortDescription(self): def shortDescription(self):
...@@ -813,6 +818,7 @@ class CythonCompileTestCase(unittest.TestCase): ...@@ -813,6 +818,7 @@ class CythonCompileTestCase(unittest.TestCase):
from Cython.Compiler.Main import CompilationOptions from Cython.Compiler.Main import CompilationOptions
from Cython.Compiler.Main import compile as cython_compile from Cython.Compiler.Main import compile as cython_compile
from Cython.Compiler.Main import default_options from Cython.Compiler.Main import default_options
common_utility_include_dir = self.common_utility_dir
options = CompilationOptions( options = CompilationOptions(
default_options, default_options,
...@@ -824,6 +830,7 @@ class CythonCompileTestCase(unittest.TestCase): ...@@ -824,6 +830,7 @@ class CythonCompileTestCase(unittest.TestCase):
language_level = self.language_level, language_level = self.language_level,
generate_pxi = False, generate_pxi = False,
evaluate_tree_assertions = True, evaluate_tree_assertions = True,
common_utility_include_dir = common_utility_include_dir,
**extra_compile_options **extra_compile_options
) )
cython_compile(source, options=options, cython_compile(source, options=options,
...@@ -1763,6 +1770,7 @@ def main(): ...@@ -1763,6 +1770,7 @@ def main():
help="use pyximport to automatically compile imported .pyx and .py files") help="use pyximport to automatically compile imported .pyx and .py files")
parser.add_option("--watermark", dest="watermark", default=None, parser.add_option("--watermark", dest="watermark", default=None,
help="deterministic generated by string") help="deterministic generated by string")
parser.add_option("--use_common_utility_dir", default=False, action="store_true")
options, cmd_args = parser.parse_args() options, cmd_args = parser.parse_args()
...@@ -1976,6 +1984,13 @@ def runtests(options, cmd_args, coverage=None): ...@@ -1976,6 +1984,13 @@ def runtests(options, cmd_args, coverage=None):
sys.stderr.write("Backends: %s\n" % ','.join(backends)) sys.stderr.write("Backends: %s\n" % ','.join(backends))
languages = backends languages = backends
if options.use_common_utility_dir:
common_utility_dir = os.path.join(WORKDIR, 'utility_code')
if not os.path.exists(common_utility_dir):
os.makedirs(common_utility_dir)
else:
common_utility_dir = None
sys.stderr.write("\n") sys.stderr.write("\n")
test_suite = unittest.TestSuite() test_suite = unittest.TestSuite()
...@@ -1992,7 +2007,8 @@ def runtests(options, cmd_args, coverage=None): ...@@ -1992,7 +2007,8 @@ def runtests(options, cmd_args, coverage=None):
options.cleanup_sharedlibs, options.cleanup_failures, options.cleanup_sharedlibs, options.cleanup_failures,
options.pyregr, options.pyregr,
options.cython_only, languages, test_bugs, options.cython_only, languages, test_bugs,
options.fork, options.language_level) options.fork, options.language_level,
common_utility_dir)
test_suite.addTest(filetests.build_suite()) test_suite.addTest(filetests.build_suite())
if options.system_pyregr and languages: if options.system_pyregr and languages:
...@@ -2021,6 +2037,9 @@ def runtests(options, cmd_args, coverage=None): ...@@ -2021,6 +2037,9 @@ def runtests(options, cmd_args, coverage=None):
result = test_runner.run(test_suite) result = test_runner.run(test_suite)
if common_utility_dir and options.shard_num < 0 and options.cleanup_workdir:
shutil.rmtree(common_utility_dir)
if coverage is not None: if coverage is not None:
coverage.stop() coverage.stop()
ignored_modules = set( ignored_modules = set(
......
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