summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Bradshaw <robertwb@gmail.com>2014-02-13 11:00:21 -0800
committerRobert Bradshaw <robertwb@gmail.com>2014-02-13 11:00:21 -0800
commita0ec9c541f76bab9332d53637d7ebab91a116145 (patch)
tree56a8a88bbb8c58c225611ddb95716f71cffff988
parentbda901385ab62d604d7b585cd3f74cc7f434b36d (diff)
downloadcython-a0ec9c541f76bab9332d53637d7ebab91a116145.tar.gz
Allow distutils directives in test files.
-rw-r--r--Cython/Build/Dependencies.py28
-rwxr-xr-xruntests.py10
2 files changed, 28 insertions, 10 deletions
diff --git a/Cython/Build/Dependencies.py b/Cython/Build/Dependencies.py
index 43c0f9af2..885bc50f9 100644
--- a/Cython/Build/Dependencies.py
+++ b/Cython/Build/Dependencies.py
@@ -148,14 +148,18 @@ distutils_settings = {
@cython.locals(start=long, end=long)
def line_iter(source):
- start = 0
- while True:
- end = source.find('\n', start)
- if end == -1:
- yield source[start:]
- return
- yield source[start:end]
- start = end+1
+ if isinstance(source, file):
+ for line in source:
+ yield line
+ else:
+ start = 0
+ while True:
+ end = source.find('\n', start)
+ if end == -1:
+ yield source[start:]
+ return
+ yield source[start:end]
+ start = end+1
class DistutilsInfo(object):
@@ -225,6 +229,14 @@ class DistutilsInfo(object):
resolved.values[key] = value
return resolved
+ def apply(self, extension):
+ for key, value in self.values.items():
+ type = distutils_settings[key]
+ if type in [list, transitive_list]:
+ getattr(extension, key).extend(value)
+ else:
+ setattr(extension, key, value)
+
@cython.locals(start=long, q=long, single_q=long, double_q=long, hash_mark=long,
end=long, k=long, counter=long, quote_len=long)
def strip_string_literals(code, prefix='__Pyx_L'):
diff --git a/runtests.py b/runtests.py
index 5b4095ae3..f61a44036 100755
--- a/runtests.py
+++ b/runtests.py
@@ -75,6 +75,7 @@ from distutils.command.build_ext import build_ext as _build_ext
from distutils import sysconfig
distutils_distro = Distribution()
+
if sys.platform == 'win32':
# TODO: Figure out why this hackery (see http://thread.gmane.org/gmane.comp.python.cython.devel/8280/).
config_files = distutils_distro.find_config_files()
@@ -204,7 +205,7 @@ EXCLUDE_EXT = object()
EXT_EXTRAS = {
'tag:numpy' : update_numpy_extension,
'tag:openmp': update_openmp_extension,
- 'tag:trace': update_linetrace_extension,
+ 'tag:trace' : update_linetrace_extension,
}
@@ -334,7 +335,7 @@ def parse_tags(filepath):
if tag == 'tags':
tag = 'tag'
print("WARNING: test tags use the 'tag' directive, not 'tags' (%s)" % filepath)
- if tag not in ('mode', 'tag', 'ticket', 'cython'):
+ if tag not in ('mode', 'tag', 'ticket', 'cython', 'distutils'):
print("WARNING: unknown test directive '%s' found (%s)" % (tag, filepath))
values = values.split(',')
tags[tag].extend(filter(None, [value.strip() for value in values]))
@@ -772,6 +773,11 @@ class CythonCompileTestCase(unittest.TestCase):
# Set the language now as the fixer might need it
extension.language = 'c++'
+ if 'distutils' in self.tags:
+ from Cython.Build.Dependencies import DistutilsInfo
+ pyx_path = os.path.join(self.test_directory, self.module + ".pyx")
+ DistutilsInfo(open(pyx_path)).apply(extension)
+
for matcher, fixer in list(EXT_EXTRAS.items()):
if isinstance(matcher, str):
# lazy init