changeset 45521: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 b4abfe142ff6
children 93a0f3ba36bb
files tests/run-tests.py
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/tests/run-tests.py	Fri Sep 18 15:10:14 2020 -0700
+++ b/tests/run-tests.py	Wed Sep 16 19:32:53 2020 +0200
@@ -967,6 +967,7 @@
         if slowtimeout is None:
             slowtimeout = defaults['slowtimeout']
         self.path = path
+        self.relpath = os.path.relpath(path)
         self.bname = os.path.basename(path)
         self.name = _bytes2sys(self.bname)
         self._testdir = os.path.dirname(path)
@@ -2397,11 +2398,17 @@
                 result.addSkip(test, "Doesn't exist")
                 continue
 
-            if not (self._whitelist and test.bname in self._whitelist):
-                if self._blacklist and test.bname in self._blacklist:
+            is_whitelisted = self._whitelist and (
+                test.relpath in self._whitelist or test.bname in self._whitelist
+            )
+            if not is_whitelisted:
+                is_blacklisted = self._blacklist and (
+                    test.relpath in self._blacklist
+                    or test.bname in self._blacklist
+                )
+                if is_blacklisted:
                     result.addSkip(test, 'blacklisted')
                     continue
-
                 if self._keywords:
                     with open(test.path, 'rb') as f:
                         t = f.read().lower() + test.bname.lower()