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

valentin.gatienbaron (Valentin Gatien-Baron) phabricator at mercurial-scm.org
Wed Nov 21 18:13:27 UTC 2018


valentin.gatienbaron created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  It fails for me with (among other things):
  
    tests/test-commandserver.t:19: relative import of stdlib module
    tests/test-lfs-serve.t:108: relative import of stdlib module
    tests/test-lfs-serve.t:255: relative import of stdlib module
    tests/test-lfs-serve.t:362: relative import of stdlib module
    tests/test-lfs-serve.t:406: relative import of stdlib module
  
  This is because every module is considered a stdlib module, because
  the stdlib_prefixes is /usr, and my repo is in /usr/local/home (so
  sys.path[0] is /usr/local/home/../hg/contrib since import-checker.py
  lives there). So remove the import-checker directory.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  contrib/import-checker.py

CHANGE DETAILS

diff --git a/contrib/import-checker.py b/contrib/import-checker.py
--- a/contrib/import-checker.py
+++ b/contrib/import-checker.py
@@ -260,9 +260,9 @@
                 break
         else:
             stdlib_prefixes.add(dirname)
-    for libpath in sys.path:
-        # We want to walk everything in sys.path that starts with
-        # something in stdlib_prefixes.
+    for libpath in sys.path[1:]:
+        # We want to walk everything in sys.path (other than the directory of
+        # the current script) that starts with something in stdlib_prefixes.
         if not any(libpath.startswith(p) for p in stdlib_prefixes):
             continue
         for top, dirs, files in os.walk(libpath):



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


More information about the Mercurial-devel mailing list