Bug 1143932 - Factor out test harness files processing code from emit_from_context; r=gps
authorMs2ger <ms2ger@gmail.com>
Tue, 17 Mar 2015 10:39:08 +0100
changeset 251102 845715f861dfaf34e771118545e3f4ab84d13b64
parent 251101 9e27b05b961f0ec67a33b9ecf261c2672ca695fd
child 251103 bb97bc37bf3b70ae3e023578a66c2c33a8398561
push id1096
push userbcampen@mozilla.com
push dateTue, 17 Mar 2015 18:28:18 +0000
reviewersgps
bugs1143932
milestone39.0a1
Bug 1143932 - Factor out test harness files processing code from emit_from_context; r=gps
python/mozbuild/mozbuild/frontend/emitter.py
--- a/python/mozbuild/mozbuild/frontend/emitter.py
+++ b/python/mozbuild/mozbuild/frontend/emitter.py
@@ -575,52 +575,18 @@ class TreeMetadataEmitter(LoggingMixin):
         exports = context.get('EXPORTS')
         if exports:
             yield Exports(context, exports,
                 dist_install=not context.get('NO_DIST_INSTALL', False))
 
         for obj in self._process_generated_files(context):
             yield obj
 
-        test_harness_files = context.get('TEST_HARNESS_FILES')
-        if test_harness_files:
-            srcdir_files = defaultdict(list)
-            srcdir_pattern_files = defaultdict(list)
-            objdir_files = defaultdict(list)
-
-            for path, strings in test_harness_files.walk():
-                if not path and strings:
-                    raise SandboxValidationError(
-                        'Cannot install files to the root of TEST_HARNESS_FILES', context)
-
-                for s in strings:
-                    if context.is_objdir_path(s):
-                        if s.startswith('!/'):
-                            objdir_files[path].append('$(DEPTH)/%s' % s[2:])
-                        else:
-                            objdir_files[path].append(s[1:])
-                    else:
-                        resolved = context.resolve_path(s)
-                        if '*' in s:
-                            if s[0] == '/':
-                                pattern_start = resolved.index('*')
-                                base_path = mozpath.dirname(resolved[:pattern_start])
-                                pattern = resolved[len(base_path)+1:]
-                            else:
-                                base_path = context.srcdir
-                                pattern = s
-                            srcdir_pattern_files[path].append((base_path, pattern));
-                        elif not os.path.exists(resolved):
-                            raise SandboxValidationError(
-                                'File listed in TEST_HARNESS_FILES does not exist: %s' % s, context)
-                        else:
-                            srcdir_files[path].append(resolved)
-
-            yield TestHarnessFiles(context, srcdir_files,
-                                   srcdir_pattern_files, objdir_files)
+        for obj in self._process_test_harness_files(context):
+            yield obj
 
         defines = context.get('DEFINES')
         if defines:
             yield Defines(context, defines)
 
         resources = context.get('RESOURCE_FILES')
         if resources:
             yield Resources(context, resources, defines)
@@ -839,16 +805,56 @@ class TreeMetadataEmitter(LoggingMixin):
                             'Input for generating %s does not exist: %s'
                             % (f, i), context)
             else:
                 script = None
                 method = None
                 inputs = []
             yield GeneratedFile(context, script, method, output, inputs)
 
+    def _process_test_harness_files(self, context):
+        test_harness_files = context.get('TEST_HARNESS_FILES')
+        if not test_harness_files:
+            return
+
+        srcdir_files = defaultdict(list)
+        srcdir_pattern_files = defaultdict(list)
+        objdir_files = defaultdict(list)
+
+        for path, strings in test_harness_files.walk():
+            if not path and strings:
+                raise SandboxValidationError(
+                    'Cannot install files to the root of TEST_HARNESS_FILES', context)
+
+            for s in strings:
+                if context.is_objdir_path(s):
+                    if s.startswith('!/'):
+                        objdir_files[path].append('$(DEPTH)/%s' % s[2:])
+                    else:
+                        objdir_files[path].append(s[1:])
+                else:
+                    resolved = context.resolve_path(s)
+                    if '*' in s:
+                        if s[0] == '/':
+                            pattern_start = resolved.index('*')
+                            base_path = mozpath.dirname(resolved[:pattern_start])
+                            pattern = resolved[len(base_path)+1:]
+                        else:
+                            base_path = context.srcdir
+                            pattern = s
+                        srcdir_pattern_files[path].append((base_path, pattern));
+                    elif not os.path.exists(resolved):
+                        raise SandboxValidationError(
+                            'File listed in TEST_HARNESS_FILES does not exist: %s' % s, context)
+                    else:
+                        srcdir_files[path].append(resolved)
+
+        yield TestHarnessFiles(context, srcdir_files,
+                               srcdir_pattern_files, objdir_files)
+
     def _handle_programs(self, context):
         for kind, cls in [('PROGRAM', Program), ('HOST_PROGRAM', HostProgram)]:
             program = context.get(kind)
             if program:
                 if program in self._binaries:
                     raise SandboxValidationError(
                         'Cannot use "%s" as %s name, '
                         'because it is already used in %s' % (program, kind,