Patchwork D9024: run-test: make `--blacklist` and `--whitelist` behave like `--test-list`

login
register
mail settings
Submitter phabricator
Date Sept. 17, 2020, 8:57 a.m.
Message ID <differential-rev-PHID-DREV-a6q5vehmyfayzj3qrkk7-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47178/
State Superseded
Headers show

Comments

phabricator - Sept. 17, 2020, 8:57 a.m.
acezar created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Allows to specify a relative file path like `--test-list` for `--blacklist`
  and `--whitelist`
  
  Issue: https://bz.mercurial-scm.org/show_bug.cgi?id=6351

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/run-tests.py

CHANGE DETAILS




To: acezar, #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
@@ -999,6 +999,10 @@ 
 
         self._refout = self.readrefout()
 
+    @property
+    def relpath(self):
+        return os.path.relpath(self.path)
+
     def readrefout(self):
         """read reference output"""
         # If we're not in --debug mode and reference output file exists,
@@ -2397,11 +2401,18 @@ 
                 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()