diff tests/run-tests.py @ 45407:de9ec12ee53c

run-tests: refactor filtering logic for --retest flag How I got to this: While re-running failed tests using --retest I noticed that the output: "running x tests using y parallel processes". was not actually correct, because x was the total number of tests present in the directory, but it should be the number of failed tests. Although it would run only the failed tests and later will say that remaining tests were skipped. Changes in test files reflect the fixed behaviour. This patch change and move the logic for filtering failed test for --retest option and make sure that we create instances of class Test only for the tests we need to run. As mentioned in the deleted text (in this patch itself) the logic for --retest should be outside of TestSuite. Differential Revision: https://phab.mercurial-scm.org/D8938
author Sushil khanchi <sushilkhanchi97@gmail.com>
date Sat, 22 Aug 2020 16:31:34 +0530
parents a659d5a4d2d5
children 543e446204c6
line wrap: on
line diff
--- a/tests/run-tests.py	Thu Aug 27 12:24:57 2020 +0530
+++ b/tests/run-tests.py	Sat Aug 22 16:31:34 2020 +0530
@@ -2336,7 +2336,6 @@
         jobs=1,
         whitelist=None,
         blacklist=None,
-        retest=False,
         keywords=None,
         loop=False,
         runs_per_test=1,
@@ -2364,9 +2363,6 @@
         backwards compatible behavior which reports skipped tests as part
         of the results.
 
-        retest denotes whether to retest failed tests. This arguably belongs
-        outside of TestSuite.
-
         keywords denotes key words that will be used to filter which tests
         to execute. This arguably belongs outside of TestSuite.
 
@@ -2377,7 +2373,6 @@
         self._jobs = jobs
         self._whitelist = whitelist
         self._blacklist = blacklist
-        self._retest = retest
         self._keywords = keywords
         self._loop = loop
         self._runs_per_test = runs_per_test
@@ -2407,10 +2402,6 @@
                     result.addSkip(test, 'blacklisted')
                     continue
 
-                if self._retest and not os.path.exists(test.errpath):
-                    result.addIgnore(test, 'not retesting')
-                    continue
-
                 if self._keywords:
                     with open(test.path, 'rb') as f:
                         t = f.read().lower() + test.bname.lower()
@@ -3253,6 +3244,22 @@
                     tests.append({'path': t})
             else:
                 tests.append({'path': t})
+
+        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)
+
+                if os.path.exists(errpath):
+                    retest_args.append(test)
+            tests = retest_args
         return tests
 
     def _runtests(self, testdescs):
@@ -3298,7 +3305,6 @@
                 jobs=jobs,
                 whitelist=self.options.whitelisted,
                 blacklist=self.options.blacklist,
-                retest=self.options.retest,
                 keywords=kws,
                 loop=self.options.loop,
                 runs_per_test=self.options.runs_per_test,