From 9382558dc4aba70b1912d1bcdd10047edee900be Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Wed, 18 Sep 2013 21:35:26 -0700 Subject: [PATCH] XML results for hudson. --- Cython/Build/Dependencies.py | 62 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 10 deletions(-) diff --git a/Cython/Build/Dependencies.py b/Cython/Build/Dependencies.py index 9b5d34a..d37ce6f 100644 --- a/Cython/Build/Dependencies.py +++ b/Cython/Build/Dependencies.py @@ -2,7 +2,7 @@ import cython from Cython import __version__ from glob import glob -import re, os, sys +import re, os, sys, time try: import gzip gzip_open = gzip.open @@ -337,6 +337,20 @@ def resolve_depend(depend, include_dirs): return None @cached_function +def package(filename): + dir = os.path.dirname(os.path.abspath(str(filename))) + if dir != filename and path_exists(join_path(dir, '__init__.py')): + return package(dir) + (os.path.basename(dir),) + else: + return () + +@cached_function +def fully_qualifeid_name(filename): + module = os.path.splitext(os.path.basename(filename))[0] + return '.'.join(package(filename) + (module,)) + + +@cached_function def parse_dependencies(source_filename): # Actual parsing is way to slow, so we use regular expressions. # The only catch is that we must strip comments and string @@ -411,18 +425,11 @@ class DependencyTree(object): def cimports(self, filename): return self.cimports_and_externs(filename)[0] - @cached_method def package(self, filename): - dir = os.path.dirname(os.path.abspath(str(filename))) - if dir != filename and path_exists(join_path(dir, '__init__.py')): - return self.package(dir) + (os.path.basename(dir),) - else: - return () + return package(filename) - @cached_method def fully_qualifeid_name(self, filename): - module = os.path.splitext(os.path.basename(filename))[0] - return '.'.join(self.package(filename) + (module,)) + return fully_qualifeid_name(filename) @cached_method def find_pxd(self, module, filename=None): @@ -789,7 +796,42 @@ def cythonize(module_list, exclude=[], nthreads=0, aliases=None, quiet=False, fo sys.stdout.flush() return module_list + +if os.environ['XML_RESULTS']: + compile_result_dir = os.environ['XML_RESULTS'] + def record_results(func): + def with_record(*args): + try: + t = time.time() + success = True + func(*args) + except: + success = False + finally: + t = time.time() - t + module = fully_qualifeid_name(args[0]) + name = "cythonize." + module + failures = 1 - success + if success: + failure_item = "" + else: + failure_item = "failure" + output = open(os.path.join(compile_result_dir, name + ".xml"), "w") + output.write(""" + + + + %(failure_item)s + + + """.strip() % locals()) + output.close() + return with_record +else: + record_results = lambda x: x + # TODO: Share context? Issue: pyx processing leaks into pxd module +@record_results def cythonize_one(pyx_file, c_file, fingerprint, quiet, options=None, raise_on_failure=True): from Cython.Compiler.Main import compile, default_options from Cython.Compiler.Errors import CompileError, PyrexError -- 2.7.4