comparison tests/run-tests.py @ 45513:22140fd783d2

run-test: allow relative path in `--blacklist` and `--whitelist` (issue6351) When specifying a test with `--blacklist` or `--whitelist` with path relatives to the repository root (eg: `tests/test-check-commit.t`) the file is not taken into account. It only works when the name of the test is given. It would be better if `--blacklist` and `--whitelist` behaviors where compatible with `--test-list`. This patch allows to use relative path with `--blacklist` and `--whitelist` while staying compatible with the old behavior by checking the test relative path in addition to its name. Differential Revision: https://phab.mercurial-scm.org/D9024
author Antoine cezar<acezar@chwitlabs.fr>
date Wed, 16 Sep 2020 19:32:53 +0200
parents c6e332a451d0
children 21733e8c924f
comparison
equal deleted inserted replaced
45512:b4abfe142ff6 45513:22140fd783d2
965 if startport is None: 965 if startport is None:
966 startport = defaults['port'] 966 startport = defaults['port']
967 if slowtimeout is None: 967 if slowtimeout is None:
968 slowtimeout = defaults['slowtimeout'] 968 slowtimeout = defaults['slowtimeout']
969 self.path = path 969 self.path = path
970 self.relpath = os.path.relpath(path)
970 self.bname = os.path.basename(path) 971 self.bname = os.path.basename(path)
971 self.name = _bytes2sys(self.bname) 972 self.name = _bytes2sys(self.bname)
972 self._testdir = os.path.dirname(path) 973 self._testdir = os.path.dirname(path)
973 self._outputdir = outputdir 974 self._outputdir = outputdir
974 self._tmpname = os.path.basename(path) 975 self._tmpname = os.path.basename(path)
2395 2396
2396 if not os.path.exists(test.path): 2397 if not os.path.exists(test.path):
2397 result.addSkip(test, "Doesn't exist") 2398 result.addSkip(test, "Doesn't exist")
2398 continue 2399 continue
2399 2400
2400 if not (self._whitelist and test.bname in self._whitelist): 2401 is_whitelisted = self._whitelist and (
2401 if self._blacklist and test.bname in self._blacklist: 2402 test.relpath in self._whitelist or test.bname in self._whitelist
2403 )
2404 if not is_whitelisted:
2405 is_blacklisted = self._blacklist and (
2406 test.relpath in self._blacklist
2407 or test.bname in self._blacklist
2408 )
2409 if is_blacklisted:
2402 result.addSkip(test, 'blacklisted') 2410 result.addSkip(test, 'blacklisted')
2403 continue 2411 continue
2404
2405 if self._keywords: 2412 if self._keywords:
2406 with open(test.path, 'rb') as f: 2413 with open(test.path, 'rb') as f:
2407 t = f.read().lower() + test.bname.lower() 2414 t = f.read().lower() + test.bname.lower()
2408 ignored = False 2415 ignored = False
2409 for k in self._keywords.lower().split(): 2416 for k in self._keywords.lower().split():