Patchwork D8979: run-tests: extract logic to get errpath in a utility func

login
register
mail settings
Submitter phabricator
Date Sept. 2, 2020, 5:43 p.m.
Message ID <differential-rev-PHID-DREV-qsuxcpxcvp34ehzwhu7q-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47088/
State Superseded
Headers show

Comments

phabricator - Sept. 2, 2020, 5:43 p.m.
khanchi97 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8979

AFFECTED FILES
  tests/run-tests.py

CHANGE DETAILS




To: khanchi97, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -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: