Patchwork D5294: tests: make test-check-module-imports more robust

login
register
mail settings
Submitter phabricator
Date Nov. 21, 2018, 6:26 p.m.
Message ID <dba06f00fea9196c5eb733794cd4e675@localhost.localdomain>
Download mbox | patch
Permalink /patch/36697/
State Not Applicable
Headers show

Comments

phabricator - Nov. 21, 2018, 6:26 p.m.
valentin.gatienbaron updated this revision to Diff 12580.
valentin.gatienbaron edited the summary of this revision.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5294?vs=12579&id=12580

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

AFFECTED FILES
  contrib/import-checker.py

CHANGE DETAILS




To: valentin.gatienbaron, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/contrib/import-checker.py b/contrib/import-checker.py
--- a/contrib/import-checker.py
+++ b/contrib/import-checker.py
@@ -260,10 +260,12 @@ 
                 break
         else:
             stdlib_prefixes.add(dirname)
+    sourceroot = os.path.dirname(sys.path[0])
     for libpath in sys.path:
-        # We want to walk everything in sys.path that starts with
-        # something in stdlib_prefixes.
-        if not any(libpath.startswith(p) for p in stdlib_prefixes):
+        # We want to walk everything in sys.paththat starts with something in
+        # stdlib_prefixes, but not directories from the hg sources.
+        if (libpath.startswith(sourceroot)
+            or not any(libpath.startswith(p) for p in stdlib_prefixes)):
             continue
         for top, dirs, files in os.walk(libpath):
             for i, d in reversed(list(enumerate(dirs))):