Bug 1240723 - Harmonise xpcshell head- and tail list computation; r?ted draft
authorAndreas Tolfsen <ato@mozilla.com>
Tue, 19 Jan 2016 13:48:53 +0000
changeset 323477 ec76b10e9e65fb86c6f5ac3c79feb5100dedd04c
parent 322386 a77b73c7723e1060993045fb31eb2f0a30473486
child 513221 86626e8f7a04bbc9b4f1be5fa8c9fe77b419d893
push id9728
push useratolfsen@mozilla.com
push dateWed, 20 Jan 2016 11:21:39 +0000
reviewersted
bugs1240723
milestone46.0a1
Bug 1240723 - Harmonise xpcshell head- and tail list computation; r?ted Head- and tail entries in manifest files are not mandatory on local/desktop xpcshell tests, and they should not be on remote/B2G either. This change makes remotexpcshelltests and runxpcshelltests agree on how to get head- and tail files.
testing/xpcshell/remotexpcshelltests.py
testing/xpcshell/runxpcshelltests.py
--- a/testing/xpcshell/remotexpcshelltests.py
+++ b/testing/xpcshell/remotexpcshelltests.py
@@ -82,35 +82,40 @@ class RemoteXPCShellTestThread(xpcshell.
         return mozInfoJSPath
 
     def logCommand(self, name, completeCmd, testdir):
         self.log.info("%s | full command: %r" % (name, completeCmd))
         self.log.info("%s | current directory: %r" % (name, self.remoteHere))
         self.log.info("%s | environment: %s" % (name, self.env))
 
     def getHeadAndTailFiles(self, test):
-        """Override parent method to find files on remote device."""
+        """Override parent method to find files on remote device.
+
+        Obtains lists of head- and tail files.  Returns a tuple containing
+        a list of head files and a list of tail files.
+        """
         def sanitize_list(s, kind):
             for f in s.strip().split(' '):
                 f = f.strip()
                 if len(f) < 1:
                     continue
 
                 path = remoteJoin(self.remoteHere, f)
 
                 # skip check for file existence: the convenience of discovering
                 # a missing file does not justify the time cost of the round trip
                 # to the device
-
                 yield path
 
         self.remoteHere = self.remoteForLocal(test['here'])
 
-        return (list(sanitize_list(test['head'], 'head')),
-                list(sanitize_list(test['tail'], 'tail')))
+        headlist = test.get('head', '')
+        taillist = test.get('tail', '')
+        return (list(sanitize_list(headlist, 'head')),
+                list(sanitize_list(taillist, 'tail')))
 
     def buildXpcsCmd(self):
         # change base class' paths to remote paths and use base class to build command
         self.xpcshell = remoteJoin(self.remoteBinDir, "xpcw")
         self.headJSPath = remoteJoin(self.remoteScriptsDir, 'head.js')
         self.httpdJSPath = remoteJoin(self.remoteComponentsDir, 'httpd.js')
         self.httpdManifest = remoteJoin(self.remoteComponentsDir, 'httpd.manifest')
         self.testingModulesDir = self.remoteModulesDir
--- a/testing/xpcshell/runxpcshelltests.py
+++ b/testing/xpcshell/runxpcshelltests.py
@@ -385,39 +385,37 @@ class XPCShellTestThread(Thread):
 
         return xpcscmd + \
                 ['-e', 'const _SERVER_ADDR = "localhost"',
                  '-e', 'const _HEAD_FILES = [%s];' % cmdH,
                  '-e', 'const _TAIL_FILES = [%s];' % cmdT,
                  '-e', 'const _JSDEBUGGER_PORT = %d;' % dbgport,
                 ]
 
-    def getHeadAndTailFiles(self, test_object):
-        """Obtain the list of head and tail files.
-
-        Returns a 2-tuple. The first element is a list of head files. The second
-        is a list of tail files.
+    def getHeadAndTailFiles(self, test):
+        """Obtain lists of head- and tail files.  Returns a tuple
+        containing a list of head files and a list of tail files.
         """
         def sanitize_list(s, kind):
             for f in s.strip().split(' '):
                 f = f.strip()
                 if len(f) < 1:
                     continue
 
-                path = os.path.normpath(os.path.join(test_object['here'], f))
+                path = os.path.normpath(os.path.join(test['here'], f))
                 if not os.path.exists(path):
                     raise Exception('%s file does not exist: %s' % (kind, path))
 
                 if not os.path.isfile(path):
                     raise Exception('%s file is not a file: %s' % (kind, path))
 
                 yield path
 
-        headlist = test_object['head'] if 'head' in test_object else ''
-        taillist = test_object['tail'] if 'tail' in test_object else ''
+        headlist = test.get('head', '')
+        taillist = test.get('tail', '')
         return (list(sanitize_list(headlist, 'head')),
                 list(sanitize_list(taillist, 'tail')))
 
     def buildXpcsCmd(self):
         """
           Load the root head.js file as the first file in our test path, before other head, test, and tail files.
           On a remote system, we overload this to add additional command line arguments, so this gets overloaded.
         """