changeset 45422:543e446204c6

run-tests: extract logic to get errpath in a utility func Differential Revision: https://phab.mercurial-scm.org/D8979
author Sushil khanchi <sushilkhanchi97@gmail.com>
date Wed, 02 Sep 2020 23:09:45 +0530
parents de9ec12ee53c
children a28da102fd36
files tests/run-tests.py
diffstat 1 files changed, 14 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/tests/run-tests.py	Sat Aug 22 16:31:34 2020 +0530
+++ b/tests/run-tests.py	Wed Sep 02 23:09:45 2020 +0530
@@ -3248,15 +3248,7 @@
         if self.options.retest:
             retest_args = []
             for test in tests:
-                if 'case' in test:
-                    # for multiple dimensions test cases
-                    casestr = b'#'.join(test['case'])
-                    errpath = b'%s#%s.err' % (test['path'], casestr)
-                else:
-                    errpath = b'%s.err' % test['path']
-                if self.options.outputdir:
-                    errpath = os.path.join(self.options.outputdir, errpath)
-
+                errpath = self._geterrpath(test)
                 if os.path.exists(errpath):
                     retest_args.append(test)
             tests = retest_args
@@ -3276,13 +3268,7 @@
                 orig = list(testdescs)
                 while testdescs:
                     desc = testdescs[0]
-                    # desc['path'] is a relative path
-                    if 'case' in desc:
-                        casestr = b'#'.join(desc['case'])
-                        errpath = b'%s#%s.err' % (desc['path'], casestr)
-                    else:
-                        errpath = b'%s.err' % desc['path']
-                    errpath = os.path.join(self._outputdir, errpath)
+                    errpath = self._geterrpath(desc)
                     if os.path.exists(errpath):
                         break
                     testdescs.pop(0)
@@ -3352,6 +3338,18 @@
         if failed:
             return 1
 
+    def _geterrpath(self, test):
+        # test['path'] is a relative path
+        if 'case' in test:
+            # for multiple dimensions test cases
+            casestr = b'#'.join(test['case'])
+            errpath = b'%s#%s.err' % (test['path'], casestr)
+        else:
+            errpath = b'%s.err' % test['path']
+        if self.options.outputdir:
+            errpath = os.path.join(self.options.outputdir, errpath)
+        return errpath
+
     def _getport(self, count):
         port = self._ports.get(count)  # do we have a cached entry?
         if port is None: