comparison 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
comparison
equal deleted inserted replaced
45406:fa1a5527f642 45407:de9ec12ee53c
2334 self, 2334 self,
2335 testdir, 2335 testdir,
2336 jobs=1, 2336 jobs=1,
2337 whitelist=None, 2337 whitelist=None,
2338 blacklist=None, 2338 blacklist=None,
2339 retest=False,
2340 keywords=None, 2339 keywords=None,
2341 loop=False, 2340 loop=False,
2342 runs_per_test=1, 2341 runs_per_test=1,
2343 loadtest=None, 2342 loadtest=None,
2344 showchannels=False, 2343 showchannels=False,
2362 Instead, whitelist and blacklist should be handled by the thing that 2361 Instead, whitelist and blacklist should be handled by the thing that
2363 populates the TestSuite with tests. They are present to preserve 2362 populates the TestSuite with tests. They are present to preserve
2364 backwards compatible behavior which reports skipped tests as part 2363 backwards compatible behavior which reports skipped tests as part
2365 of the results. 2364 of the results.
2366 2365
2367 retest denotes whether to retest failed tests. This arguably belongs
2368 outside of TestSuite.
2369
2370 keywords denotes key words that will be used to filter which tests 2366 keywords denotes key words that will be used to filter which tests
2371 to execute. This arguably belongs outside of TestSuite. 2367 to execute. This arguably belongs outside of TestSuite.
2372 2368
2373 loop denotes whether to loop over tests forever. 2369 loop denotes whether to loop over tests forever.
2374 """ 2370 """
2375 super(TestSuite, self).__init__(*args, **kwargs) 2371 super(TestSuite, self).__init__(*args, **kwargs)
2376 2372
2377 self._jobs = jobs 2373 self._jobs = jobs
2378 self._whitelist = whitelist 2374 self._whitelist = whitelist
2379 self._blacklist = blacklist 2375 self._blacklist = blacklist
2380 self._retest = retest
2381 self._keywords = keywords 2376 self._keywords = keywords
2382 self._loop = loop 2377 self._loop = loop
2383 self._runs_per_test = runs_per_test 2378 self._runs_per_test = runs_per_test
2384 self._loadtest = loadtest 2379 self._loadtest = loadtest
2385 self._showchannels = showchannels 2380 self._showchannels = showchannels
2403 continue 2398 continue
2404 2399
2405 if not (self._whitelist and test.bname in self._whitelist): 2400 if not (self._whitelist and test.bname in self._whitelist):
2406 if self._blacklist and test.bname in self._blacklist: 2401 if self._blacklist and test.bname in self._blacklist:
2407 result.addSkip(test, 'blacklisted') 2402 result.addSkip(test, 'blacklisted')
2408 continue
2409
2410 if self._retest and not os.path.exists(test.errpath):
2411 result.addIgnore(test, 'not retesting')
2412 continue 2403 continue
2413 2404
2414 if self._keywords: 2405 if self._keywords:
2415 with open(test.path, 'rb') as f: 2406 with open(test.path, 'rb') as f:
2416 t = f.read().lower() + test.bname.lower() 2407 t = f.read().lower() + test.bname.lower()
3251 tests += [{'path': t, 'case': c} for c in sorted(cases)] 3242 tests += [{'path': t, 'case': c} for c in sorted(cases)]
3252 else: 3243 else:
3253 tests.append({'path': t}) 3244 tests.append({'path': t})
3254 else: 3245 else:
3255 tests.append({'path': t}) 3246 tests.append({'path': t})
3247
3248 if self.options.retest:
3249 retest_args = []
3250 for test in tests:
3251 if 'case' in test:
3252 # for multiple dimensions test cases
3253 casestr = b'#'.join(test['case'])
3254 errpath = b'%s#%s.err' % (test['path'], casestr)
3255 else:
3256 errpath = b'%s.err' % test['path']
3257 if self.options.outputdir:
3258 errpath = os.path.join(self.options.outputdir, errpath)
3259
3260 if os.path.exists(errpath):
3261 retest_args.append(test)
3262 tests = retest_args
3256 return tests 3263 return tests
3257 3264
3258 def _runtests(self, testdescs): 3265 def _runtests(self, testdescs):
3259 def _reloadtest(test, i): 3266 def _reloadtest(test, i):
3260 # convert a test back to its description dict 3267 # convert a test back to its description dict
3296 suite = TestSuite( 3303 suite = TestSuite(
3297 self._testdir, 3304 self._testdir,
3298 jobs=jobs, 3305 jobs=jobs,
3299 whitelist=self.options.whitelisted, 3306 whitelist=self.options.whitelisted,
3300 blacklist=self.options.blacklist, 3307 blacklist=self.options.blacklist,
3301 retest=self.options.retest,
3302 keywords=kws, 3308 keywords=kws,
3303 loop=self.options.loop, 3309 loop=self.options.loop,
3304 runs_per_test=self.options.runs_per_test, 3310 runs_per_test=self.options.runs_per_test,
3305 showchannels=self.options.showchannels, 3311 showchannels=self.options.showchannels,
3306 tests=tests, 3312 tests=tests,